diff --git a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/imag.hpp b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/imag.hpp index 89adabff41..c5e0feea12 100644 --- a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/imag.hpp +++ b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/imag.hpp @@ -53,14 +53,16 @@ using dpctl::tensor::ssize_t; namespace td_ns = dpctl::tensor::type_dispatch; using dpctl::tensor::type_utils::is_complex; +using dpctl::tensor::type_utils::is_complex_v; template struct ImagFunctor { // is function constant for given argT - using is_constant = typename std::false_type; + using is_constant = + typename std::is_same, std::false_type>; // constant value, if constant - // constexpr resT constant_value = resT{}; + static constexpr resT constant_value = resT{0}; // is function defined for sycl::vec using supports_vec = typename std::false_type; // do both argTy and resTy support sugroup store/load operation @@ -69,12 +71,12 @@ template struct ImagFunctor resT operator()(const argT &in) const { - if constexpr (is_complex::value) { + if constexpr (is_complex_v) { return std::imag(in); } else { static_assert(std::is_same_v); - return resT{0}; + return constant_value; } } }; diff --git a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/real.hpp b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/real.hpp index bb22352907..9ecb822a20 100644 --- a/dpctl/tensor/libtensor/include/kernels/elementwise_functions/real.hpp +++ b/dpctl/tensor/libtensor/include/kernels/elementwise_functions/real.hpp @@ -53,6 +53,7 @@ using dpctl::tensor::ssize_t; namespace td_ns = dpctl::tensor::type_dispatch; using dpctl::tensor::type_utils::is_complex; +using dpctl::tensor::type_utils::is_complex_v; template struct RealFunctor { @@ -69,7 +70,7 @@ template struct RealFunctor resT operator()(const argT &in) const { - if constexpr (is_complex::value) { + if constexpr (is_complex_v) { return std::real(in); } else {