File tree Expand file tree Collapse file tree 7 files changed +34
-25
lines changed
dpctl/tensor/libtensor/include/kernels/elementwise_functions Expand file tree Collapse file tree 7 files changed +34
-25
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,11 @@ template <typename argT, typename resT> struct AcosFunctor
105
105
constexpr realT r_eps =
106
106
realT (1 ) / std::numeric_limits<realT>::epsilon ();
107
107
if (std::abs (x) > r_eps || std::abs (y) > r_eps) {
108
- argT log_in = std::log (in);
108
+ using sycl_complexT = exprm_ns::complex<realT>;
109
+ sycl_complexT log_in = exprm_ns::log (exprm_ns::complex<realT>(in));
109
110
110
- const realT wx = std:: real (log_in );
111
- const realT wy = std:: imag (log_in );
111
+ const realT wx = log_in. real ();
112
+ const realT wy = log_in. imag ();
112
113
const realT rx = std::abs (wy);
113
114
114
115
realT ry = wx + std::log (realT (2 ));
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ namespace acosh
48
48
49
49
namespace py = pybind11;
50
50
namespace td_ns = dpctl::tensor::type_dispatch;
51
- namespace cmplx_ns = sycl::ext::oneapi::experimental;
51
+ namespace exprm_ns = sycl::ext::oneapi::experimental;
52
52
53
53
using dpctl::tensor::type_utils::is_complex;
54
54
@@ -112,16 +112,18 @@ template <typename argT, typename resT> struct AcoshFunctor
112
112
* For large x or y including acos(+-Inf + I*+-Inf)
113
113
*/
114
114
if (std::abs (x) > r_eps || std::abs (y) > r_eps) {
115
- const realT wx = std::real (std::log (in));
116
- const realT wy = std::imag (std::log (in));
115
+ using sycl_complexT = typename exprm_ns::complex<realT>;
116
+ const sycl_complexT log_in = exprm_ns::log (sycl_complexT (in));
117
+ const realT wx = log_in.real ();
118
+ const realT wy = log_in.imag ();
117
119
const realT rx = std::abs (wy);
118
120
realT ry = wx + std::log (realT (2 ));
119
121
acos_in = resT{rx, (std::signbit (y)) ? ry : -ry};
120
122
}
121
123
else {
122
124
/* ordinary cases */
123
- acos_in = cmplx_ns ::acos (
124
- cmplx_ns ::complex<realT>(in)); // std::acos(in);
125
+ acos_in = exprm_ns ::acos (
126
+ exprm_ns ::complex<realT>(in)); // std::acos(in);
125
127
}
126
128
127
129
/* Now we calculate acosh(z) */
Original file line number Diff line number Diff line change @@ -119,17 +119,18 @@ template <typename argT, typename resT> struct AsinFunctor
119
119
constexpr realT r_eps =
120
120
realT (1 ) / std::numeric_limits<realT>::epsilon ();
121
121
if (std::abs (x) > r_eps || std::abs (y) > r_eps) {
122
- const resT z = {x, y};
122
+ using sycl_complexT = exprm_ns::complex<realT>;
123
+ const sycl_complexT z {x, y};
123
124
realT wx, wy;
124
125
if (!std::signbit (x)) {
125
- auto log_z = std ::log (z);
126
- wx = std:: real (log_z ) + std::log (realT (2 ));
127
- wy = std:: imag (log_z );
126
+ auto log_z = exprm_ns ::log (z);
127
+ wx = log_z. real () + std::log (realT (2 ));
128
+ wy = log_z. imag ();
128
129
}
129
130
else {
130
- auto log_mz = std ::log (-z);
131
- wx = std:: real (log_mz ) + std::log (realT (2 ));
132
- wy = std:: imag (log_mz );
131
+ auto log_mz = exprm_ns ::log (-z);
132
+ wx = log_mz. real () + std::log (realT (2 ));
133
+ wy = log_mz. imag ();
133
134
}
134
135
const realT asinh_re = std::copysign (wx, x);
135
136
const realT asinh_im = std::copysign (wy, y);
Original file line number Diff line number Diff line change @@ -108,9 +108,12 @@ template <typename argT, typename resT> struct AsinhFunctor
108
108
realT (1 ) / std::numeric_limits<realT>::epsilon ();
109
109
110
110
if (std::abs (x) > r_eps || std::abs (y) > r_eps) {
111
- resT log_in = (std::signbit (x)) ? std::log (-in) : std::log (in);
112
- realT wx = std::real (log_in) + std::log (realT (2 ));
113
- realT wy = std::imag (log_in);
111
+ using sycl_complexT = exprm_ns::complex<realT>;
112
+ sycl_complexT log_in = (std::signbit (x)) ?
113
+ exprm_ns::log (sycl_complexT (-in)) :
114
+ exprm_ns::log (sycl_complexT (in));
115
+ realT wx = log_in.real () + std::log (realT (2 ));
116
+ realT wy = log_in.imag ();
114
117
const realT res_re = std::copysign (wx, x);
115
118
const realT res_im = std::copysign (wy, y);
116
119
return resT{res_re, res_im};
Original file line number Diff line number Diff line change 24
24
// ===---------------------------------------------------------------------===//
25
25
26
26
#pragma once
27
- #include < CL/sycl.hpp>
28
27
#include < cmath>
29
28
#include < cstddef>
30
29
#include < cstdint>
30
+ #include < sycl/ext/oneapi/experimental/sycl_complex.hpp>
31
+ #include < sycl/sycl.hpp>
31
32
#include < type_traits>
32
33
33
34
#include " kernels/elementwise_functions/common.hpp"
@@ -48,6 +49,7 @@ namespace exp2
48
49
49
50
namespace py = pybind11;
50
51
namespace td_ns = dpctl::tensor::type_dispatch;
52
+ namespace exprm_ns = sycl::ext::oneapi::experimental;
51
53
52
54
using dpctl::tensor::type_utils::is_complex;
53
55
@@ -76,7 +78,7 @@ template <typename argT, typename resT> struct Exp2Functor
76
78
const realT y = std::imag (tmp);
77
79
if (std::isfinite (x)) {
78
80
if (std::isfinite (y)) {
79
- return std ::exp (tmp);
81
+ return exprm_ns ::exp (exprm_ns::complex<realT>( tmp) );
80
82
}
81
83
else {
82
84
return resT{q_nan, q_nan};
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ namespace sin
48
48
49
49
namespace py = pybind11;
50
50
namespace td_ns = dpctl::tensor::type_dispatch;
51
- namespace cmplx_ns = sycl::ext::oneapi::experimental;
51
+ namespace exprm_ns = sycl::ext::oneapi::experimental;
52
52
53
53
using dpctl::tensor::type_utils::is_complex;
54
54
@@ -81,8 +81,8 @@ template <typename argT, typename resT> struct SinFunctor
81
81
* real and imaginary parts of input are finite.
82
82
*/
83
83
if (in_re_finite && in_im_finite) {
84
- return cmplx_ns ::sin (
85
- cmplx_ns ::complex<realT>(in)); // std::sin(in);
84
+ return exprm_ns ::sin (
85
+ exprm_ns ::complex<realT>(in)); // std::sin(in);
86
86
}
87
87
88
88
/*
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ namespace sinh
48
48
49
49
namespace py = pybind11;
50
50
namespace td_ns = dpctl::tensor::type_dispatch;
51
- namespace cmplx_ns = sycl::ext::oneapi::experimental;
51
+ namespace exprm_ns = sycl::ext::oneapi::experimental;
52
52
53
53
using dpctl::tensor::type_utils::is_complex;
54
54
@@ -81,7 +81,7 @@ template <typename argT, typename resT> struct SinhFunctor
81
81
* real and imaginary parts of input are finite.
82
82
*/
83
83
if (xfinite && yfinite) {
84
- return std ::sinh (in );
84
+ return exprm_ns ::sinh (exprm_ns::complex<realT>(in) );
85
85
}
86
86
/*
87
87
* sinh(+-0 +- I Inf) = sign(d(+-0, dNaN))0 + I dNaN.
You can’t perform that action at this time.
0 commit comments