Skip to content

Commit 6eb1b9a

Browse files
committed
Add ufunc implementation
1 parent a8aa65b commit 6eb1b9a

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static void populate(py::module_ m,
212212

213213
MACRO_DEFINE_IMPL(erf, Erf);
214214
MACRO_DEFINE_IMPL(erfc, Erfc);
215+
MACRO_DEFINE_IMPL(erfcx, Erfcx);
215216
} // namespace impl
216217

217218
void init_erf_funcs(py::module_ m)
@@ -231,5 +232,9 @@ void init_erf_funcs(py::module_ m)
231232
impl::populate<impl::ErfcContigFactory, impl::ErfcStridedFactory>(
232233
m, "_erfc", "", impl::erfc_contig_dispatch_vector,
233234
impl::erfc_strided_dispatch_vector);
235+
236+
impl::populate<impl::ErfcxContigFactory, impl::ErfcxStridedFactory>(
237+
m, "_erfcx", "", impl::erfcx_contig_dispatch_vector,
238+
impl::erfcx_strided_dispatch_vector);
234239
}
235240
} // namespace dpnp::extensions::ufunc

dpnp/backend/kernels/elementwise_functions/erf.hpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232

3333
#include <sycl/sycl.hpp>
3434

35+
/**
36+
* Include <sycl/ext/intel/math.hpp> only when targeting to Intel devices.
37+
*/
38+
#if defined(__INTEL_LLVM_COMPILER)
39+
#define __SYCL_EXT_INTEL_MATH_SUPPORT
40+
#endif
41+
42+
#if defined(__SYCL_EXT_INTEL_MATH_SUPPORT)
43+
#include <sycl/ext/intel/math.hpp>
44+
#else
45+
#include <cmath>
46+
#endif
47+
3548
namespace dpnp::kernels::erfs
3649
{
3750
template <typename OpT, typename ArgT, typename ResT>
@@ -65,13 +78,20 @@ struct BaseFunctor
6578
template <typename Tp> \
6679
static Tp apply(const Tp &x) \
6780
{ \
68-
return sycl::__name__(x); \
81+
return __name__(x); \
6982
} \
7083
}; \
7184
\
7285
template <typename ArgT, typename ResT> \
7386
using __f_name__##Functor = BaseFunctor<__f_name__##Op, ArgT, ResT>;
7487

75-
MACRO_DEFINE_FUNCTOR(erf, Erf);
76-
MACRO_DEFINE_FUNCTOR(erfc, Erfc);
88+
MACRO_DEFINE_FUNCTOR(sycl::erf, Erf);
89+
MACRO_DEFINE_FUNCTOR(sycl::erfc, Erfc);
90+
MACRO_DEFINE_FUNCTOR(
91+
#if defined(__SYCL_EXT_INTEL_MATH_SUPPORT)
92+
sycl::ext::intel::math::erfcx,
93+
#else
94+
std::erfc,
95+
#endif
96+
Erfcx);
7797
} // namespace dpnp::kernels::erfs

0 commit comments

Comments
 (0)