Skip to content

Commit 6ba319b

Browse files
authored
Merge 35ddd91 into 80af9c3
2 parents 80af9c3 + 35ddd91 commit 6ba319b

File tree

14 files changed

+1764
-17
lines changed

14 files changed

+1764
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This release changes the license from `BSD-2-Clause` to `BSD-3-Clause`.
1212

1313
* Added the docstrings to `dpnp.linalg.LinAlgError` exception [#2613](https://github.com/IntelPython/dpnp/pull/2613)
1414
* Added implementation of `dpnp.linalg.lu_solve` for batch inputs (SciPy-compatible) [#2619](https://github.com/IntelPython/dpnp/pull/2619)
15+
* Added implementation of `dpnp.special.erfcx` [#2596](https://github.com/IntelPython/dpnp/pull/2596)
1516

1617
### Changed
1718

doc/reference/scipy_special.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ Error function and Fresnel integrals
1515
erf
1616
erfc
1717
erfcx
18-
erfi
1918
erfinv
2019
erfcinv

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/extensions/vm/erf_funcs.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ using ew_cmn_ns::unary_contig_impl_fn_ptr_t;
133133

134134
MACRO_DEFINE_IMPL(erf, Erf);
135135
MACRO_DEFINE_IMPL(erfc, Erfc);
136+
MACRO_DEFINE_IMPL(erfcx, Erfcx);
136137

137138
template <template <typename fnT, typename T> typename factoryT>
138139
static void populate(py::module_ m,
@@ -187,5 +188,11 @@ void init_erf_funcs(py::module_ m)
187188
"Call `erfc` function from OneMKL VM library to compute the "
188189
"complementary error function value of vector elements",
189190
impl::erfc_contig_dispatch_vector);
191+
192+
impl::populate<impl::ErfcxContigFactory>(
193+
m, "_erfcx",
194+
"Call `erfcx` function from OneMKL VM library to compute the scaled "
195+
"complementary error function value of vector elements",
196+
impl::erfcx_contig_dispatch_vector);
190197
}
191198
} // namespace dpnp::extensions::vm

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(__SPIR__) || defined(__SPIRV__)) && 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 "erfcx.hpp"
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+
impl::erfcx,
95+
#endif
96+
Erfcx);
7797
} // namespace dpnp::kernels::erfs

0 commit comments

Comments
 (0)