-
Notifications
You must be signed in to change notification settings - Fork 31
Use sycl experimental complex namespace for real
and imag
#2062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
#include <sycl/sycl.hpp> | ||
#include <type_traits> | ||
|
||
#include "sycl_complex.hpp" | ||
#include "vec_size_util.hpp" | ||
|
||
#include "kernels/dpctl_tensor_types.hpp" | ||
|
@@ -56,11 +57,11 @@ using dpctl::tensor::type_utils::is_complex; | |
|
||
template <typename argT, typename resT> struct ImagFunctor | ||
{ | ||
|
||
// is function constant for given argT | ||
using is_constant = typename std::false_type; | ||
using is_constant = | ||
typename std::is_same<is_complex<argT>, 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 | ||
|
@@ -70,11 +71,13 @@ template <typename argT, typename resT> struct ImagFunctor | |
resT operator()(const argT &in) const | ||
{ | ||
if constexpr (is_complex<argT>::value) { | ||
return std::imag(in); | ||
using realT = typename argT::value_type; | ||
using sycl_complexT = typename exprm_ns::complex<realT>; | ||
return exprm_ns::imag(sycl_complexT(in)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be unclear from the PR description what was the motivation to switch to experimental namespace and why other place where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initial motivation was old technical debt to add the constant value for In terms of why add in the experimental namespace change, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general, I think it would be best to slowly transition to full use of the sycl complex extension. We also have benchmarking now and can see if this PR brings regressions once we have some unary elementwise benchmarks in place. But it could be done in a separate PR, if you feel it makes more sense that way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see now, thank you. I'm totally with that. Just it was a bit unclear from the PR description. |
||
} | ||
else { | ||
static_assert(std::is_same_v<resT, argT>); | ||
return resT{0}; | ||
return constant_value; | ||
} | ||
} | ||
}; | ||
|
Uh oh!
There was an error while loading. Please reload this page.