Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions dpnp/backend/extensions/ufunc/elementwise_functions/gcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ struct OutputType
T2,
std::int64_t,
std::int64_t>,
td_ns::BinaryTypeMapResultEntry<T1,
std::uint64_t,
T2,
std::int64_t,
std::uint64_t>,
td_ns::BinaryTypeMapResultEntry<T1,
std::int64_t,
T2,
std::uint64_t,
std::int64_t>,
td_ns::DefaultResultEntry<void>>::result_type;
};

Expand Down
10 changes: 0 additions & 10 deletions dpnp/backend/extensions/ufunc/elementwise_functions/lcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ struct OutputType
T2,
std::int64_t,
std::int64_t>,
td_ns::BinaryTypeMapResultEntry<T1,
std::uint64_t,
T2,
std::int64_t,
std::uint64_t>,
td_ns::BinaryTypeMapResultEntry<T1,
std::int64_t,
T2,
std::uint64_t,
std::int64_t>,
td_ns::DefaultResultEntry<void>>::result_type;
};

Expand Down
3 changes: 3 additions & 0 deletions dpnp/backend/kernels/elementwise_functions/gcd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct GcdFunctor

resT operator()(const argT1 &in1, const argT2 &in2) const
{
static_assert(std::is_same_v<argT1, argT2>,
"Input types are expected to be the same");

return oneapi::dpl::gcd(in1, in2);
}
};
Expand Down
17 changes: 16 additions & 1 deletion dpnp/backend/kernels/elementwise_functions/lcm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,22 @@ struct LcmFunctor

resT operator()(const argT1 &in1, const argT2 &in2) const
{
return oneapi::dpl::lcm(in1, in2);
static_assert(std::is_same_v<argT1, argT2>,
"Input types are expected to be the same");

if (in1 == 0 || in2 == 0)
return 0;

resT res = in1 / oneapi::dpl::gcd(in1, in2) * in2;
if constexpr (std::is_signed_v<argT1>) {
if (res < 0) {
return -res;
}
}
return res;

// TODO: undo the w/a once ONEDPL-1320 is resolved
// return oneapi::dpl::lcm(in1, in2);
}
};
} // namespace dpnp::kernels::lcm
Loading