We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 597cd4b commit 82407beCopy full SHA for 82407be
dpctl/tensor/libtensor/include/kernels/elementwise_functions/abs.hpp
@@ -65,15 +65,16 @@ template <typename argT, typename resT> struct AbsFunctor
65
{
66
67
if constexpr (std::is_same_v<argT, bool> ||
68
- (std::is_integral<argT>::value &&
69
- std::is_unsigned<argT>::value))
70
- {
+ std::is_unsigned<argT>::value) {
71
static_assert(std::is_same_v<resT, argT>);
72
return x;
73
}
74
- else {
+ else if (std::is_integral<argT>::value || is_complex<argT>::value) {
75
return std::abs(x);
76
+ else {
+ return (x == argT(0)) ? resT(0) : resT(std::abs(x));
77
+ }
78
79
};
80
0 commit comments