Skip to content

Commit

Permalink
Merge d62e6f2 into bd6562a
Browse files Browse the repository at this point in the history
  • Loading branch information
antonwolfy authored Oct 11, 2024
2 parents bd6562a + d62e6f2 commit ec10c6e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
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: address the issue to OneDPL team
// return oneapi::dpl::lcm(in1, in2);
}
};
} // namespace dpnp::kernels::lcm

0 comments on commit ec10c6e

Please sign in to comment.