Skip to content

Commit d4293a2

Browse files
Move ti.acos()/acosh() and reuse them in dpnp
1 parent ec74213 commit d4293a2

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

dpctl_ext/tensor/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
from ._clip import clip
8686
from ._elementwise_funcs import (
8787
abs,
88+
acos,
89+
acosh,
8890
)
8991
from ._reduction import (
9092
argmax,
@@ -110,6 +112,8 @@
110112

111113
__all__ = [
112114
"abs",
115+
"acos",
116+
"acosh",
113117
"all",
114118
"any",
115119
"arange",

dpctl_ext/tensor/_elementwise_funcs.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,61 @@
6161

6262
abs = UnaryElementwiseFunc("abs", ti._abs_result_type, ti._abs, _abs_docstring_)
6363
del _abs_docstring_
64+
65+
# U02: ==== ACOS (x)
66+
_acos_docstring = r"""
67+
acos(x, /, \*, out=None, order='K')
68+
69+
Computes inverse cosine for each element `x_i` for input array `x`.
70+
71+
Args:
72+
x (usm_ndarray):
73+
Input array, expected to have a floating-point data type.
74+
out (Union[usm_ndarray, None], optional):
75+
Output array to populate.
76+
Array must have the correct shape and the expected data type.
77+
order ("C","F","A","K", optional):
78+
Memory layout of the new output array, if parameter
79+
`out` is ``None``.
80+
Default: "K".
81+
82+
Returns:
83+
usm_ndarray:
84+
An array containing the element-wise inverse cosine, in radians
85+
and in the closed interval :math:`[0, \pi]`. The data type of the
86+
returned array is determined by the Type Promotion Rules.
87+
"""
88+
89+
acos = UnaryElementwiseFunc(
90+
"acos", ti._acos_result_type, ti._acos, _acos_docstring
91+
)
92+
del _acos_docstring
93+
94+
# U03: ===== ACOSH (x)
95+
_acosh_docstring = r"""
96+
acosh(x, /, \*, out=None, order='K')
97+
98+
Computes inverse hyperbolic cosine for each element `x_i` for input array `x`.
99+
100+
Args:
101+
x (usm_ndarray):
102+
Input array, expected to have a floating-point data type.
103+
out (Union[usm_ndarray, None], optional):
104+
Output array to populate.
105+
Array must have the correct shape and the expected data type.
106+
order ("C","F","A","K", optional):
107+
Memory layout of the new output array, if parameter
108+
`out` is ``None``.
109+
Default: "K".
110+
111+
Returns:
112+
usm_ndarray:
113+
An array containing the element-wise inverse hyperbolic cosine, in
114+
radians and in the half-closed interval :math:`[0, \infty)`. The data
115+
type of the returned array is determined by the Type Promotion Rules.
116+
"""
117+
118+
acosh = UnaryElementwiseFunc(
119+
"acosh", ti._acosh_result_type, ti._acosh, _acosh_docstring
120+
)
121+
del _acosh_docstring

dpnp/dpnp_iface_trigonometric.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
# TODO: revert to `import dpctl.tensor...`
4848
# when dpnp fully migrates dpctl/tensor
4949
import dpctl_ext.tensor as dpt
50+
import dpctl_ext.tensor._tensor_elementwise_impl as ti_ext
5051
import dpctl_ext.tensor._type_utils as dtu
5152
import dpnp
5253
import dpnp.backend.extensions.ufunc._ufunc_impl as ufi
@@ -138,8 +139,8 @@ def _get_accumulation_res_dt(a, dtype):
138139

139140
acos = DPNPUnaryFunc(
140141
"acos",
141-
ti._acos_result_type,
142-
ti._acos,
142+
ti_ext._acos_result_type,
143+
ti_ext._acos,
143144
_ACOS_DOCSTRING,
144145
mkl_fn_to_call="_mkl_acos_to_call",
145146
mkl_impl_fn="_acos",
@@ -224,8 +225,8 @@ def _get_accumulation_res_dt(a, dtype):
224225

225226
acosh = DPNPUnaryFunc(
226227
"acosh",
227-
ti._acosh_result_type,
228-
ti._acosh,
228+
ti_ext._acosh_result_type,
229+
ti_ext._acosh,
229230
_ACOSH_DOCSTRING,
230231
mkl_fn_to_call="_mkl_acosh_to_call",
231232
mkl_impl_fn="_acosh",

0 commit comments

Comments
 (0)