Skip to content

Commit 785adf0

Browse files
committed
W/a issue with lcm kernel on Windows
1 parent 1837853 commit 785adf0

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

dpnp/backend/extensions/ufunc/elementwise_functions/gcd.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,6 @@ struct OutputType
9595
T2,
9696
std::int64_t,
9797
std::int64_t>,
98-
td_ns::BinaryTypeMapResultEntry<T1,
99-
std::uint64_t,
100-
T2,
101-
std::int64_t,
102-
std::uint64_t>,
103-
td_ns::BinaryTypeMapResultEntry<T1,
104-
std::int64_t,
105-
T2,
106-
std::uint64_t,
107-
std::int64_t>,
10898
td_ns::DefaultResultEntry<void>>::result_type;
10999
};
110100

dpnp/backend/extensions/ufunc/elementwise_functions/lcm.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,6 @@ struct OutputType
9595
T2,
9696
std::int64_t,
9797
std::int64_t>,
98-
td_ns::BinaryTypeMapResultEntry<T1,
99-
std::uint64_t,
100-
T2,
101-
std::int64_t,
102-
std::uint64_t>,
103-
td_ns::BinaryTypeMapResultEntry<T1,
104-
std::int64_t,
105-
T2,
106-
std::uint64_t,
107-
std::int64_t>,
10898
td_ns::DefaultResultEntry<void>>::result_type;
10999
};
110100

dpnp/backend/kernels/elementwise_functions/gcd.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ struct GcdFunctor
3838

3939
resT operator()(const argT1 &in1, const argT2 &in2) const
4040
{
41+
static_assert(std::is_same_v<argT1, argT2>,
42+
"Input types are expected to be the same");
43+
4144
return oneapi::dpl::gcd(in1, in2);
4245
}
4346
};

dpnp/backend/kernels/elementwise_functions/lcm.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,22 @@ struct LcmFunctor
3838

3939
resT operator()(const argT1 &in1, const argT2 &in2) const
4040
{
41-
return oneapi::dpl::lcm(in1, in2);
41+
static_assert(std::is_same_v<argT1, argT2>,
42+
"Input types are expected to be the same");
43+
44+
if (in1 == 0 || in2 == 0)
45+
return 0;
46+
47+
resT res = in1 / oneapi::dpl::gcd(in1, in2) * in2;
48+
if constexpr (std::is_signed_v<argT1>) {
49+
if (res < 0) {
50+
return -res;
51+
}
52+
}
53+
return res;
54+
55+
// TODO: address the issue to OneDPL team
56+
// return oneapi::dpl::lcm(in1, in2);
4257
}
4358
};
4459
} // namespace dpnp::kernels::lcm

0 commit comments

Comments
 (0)