Skip to content

Commit 0cec8c3

Browse files
Move ti.angel()/asin()/asinh() and reuse them
1 parent a548dbb commit 0cec8c3

File tree

4 files changed

+105
-6
lines changed

4 files changed

+105
-6
lines changed

dpctl_ext/tensor/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
abs,
8888
acos,
8989
acosh,
90+
angle,
91+
asin,
92+
asinh,
9093
)
9194
from ._reduction import (
9295
argmax,
@@ -115,12 +118,15 @@
115118
"acos",
116119
"acosh",
117120
"all",
121+
"angle",
118122
"any",
119123
"arange",
120124
"argmax",
121125
"argmin",
122126
"argsort",
123127
"asarray",
128+
"asin",
129+
"asinh",
124130
"asnumpy",
125131
"astype",
126132
"broadcast_arrays",

dpctl_ext/tensor/_elementwise_funcs.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,96 @@
119119
"acosh", ti._acosh_result_type, ti._acosh, _acosh_docstring
120120
)
121121
del _acosh_docstring
122+
123+
# U04: ===== ASIN (x)
124+
_asin_docstring = r"""
125+
asin(x, /, \*, out=None, order='K')
126+
127+
Computes inverse sine for each element `x_i` for input array `x`.
128+
129+
Args:
130+
x (usm_ndarray):
131+
Input array, expected to have a floating-point data type.
132+
out (Union[usm_ndarray, None], optional):
133+
Output array to populate.
134+
Array must have the correct shape and the expected data type.
135+
order ("C","F","A","K", optional):
136+
Memory layout of the new output array, if parameter
137+
`out` is ``None``.
138+
Default: "K".
139+
140+
Returns:
141+
usm_ndarray:
142+
An array containing the element-wise inverse sine, in radians
143+
and in the closed interval :math:`[-\pi/2, \pi/2]`. The data type
144+
of the returned array is determined by the Type Promotion Rules.
145+
"""
146+
147+
asin = UnaryElementwiseFunc(
148+
"asin", ti._asin_result_type, ti._asin, _asin_docstring
149+
)
150+
del _asin_docstring
151+
152+
# U05: ===== ASINH (x)
153+
_asinh_docstring = r"""
154+
asinh(x, /, \*, out=None, order='K')
155+
156+
Computes inverse hyperbolic sine for each element `x_i` for input array `x`.
157+
158+
Args:
159+
x (usm_ndarray):
160+
Input array, expected to have a floating-point data type.
161+
out (Union[usm_ndarray, None], optional):
162+
Output array to populate.
163+
Array must have the correct shape and the expected data type.
164+
order ("C","F","A","K", optional):
165+
Memory layout of the new output array, if parameter
166+
`out` is ``None``.
167+
Default: "K".
168+
169+
Returns:
170+
usm_ndarray:
171+
An array containing the element-wise inverse hyperbolic sine, in
172+
radians. The data type of the returned array is determined by
173+
the Type Promotion Rules.
174+
"""
175+
176+
asinh = UnaryElementwiseFunc(
177+
"asinh", ti._asinh_result_type, ti._asinh, _asinh_docstring
178+
)
179+
del _asinh_docstring
180+
181+
# U43: ==== ANGLE (x)
182+
_angle_docstring = r"""
183+
angle(x, /, \*, out=None, order='K')
184+
185+
Computes the phase angle (also called the argument) of each element `x_i` for
186+
input array `x`.
187+
188+
Args:
189+
x (usm_ndarray):
190+
Input array, expected to have a complex floating-point data type.
191+
out (Union[usm_ndarray, None], optional):
192+
Output array to populate.
193+
Array have the correct shape and the expected data type.
194+
order ("C","F","A","K", optional):
195+
Memory layout of the new output array, if parameter
196+
`out` is ``None``.
197+
Default: "K".
198+
199+
Returns:
200+
usm_ndarray:
201+
An array containing the element-wise phase angles.
202+
The returned array has a floating-point data type determined
203+
by the Type Promotion Rules.
204+
"""
205+
206+
angle = UnaryElementwiseFunc(
207+
"angle",
208+
ti._angle_result_type,
209+
ti._angle,
210+
_angle_docstring,
211+
)
212+
del _angle_docstring
213+
214+
del ti

dpnp/dpnp_iface_mathematical.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,8 @@ def _validate_interp_param(param, name, exec_q, usm_type, dtype=None):
541541

542542
angle = DPNPAngle(
543543
"angle",
544-
ti._angle_result_type,
545-
ti._angle,
544+
ti_ext._angle_result_type,
545+
ti_ext._angle,
546546
_ANGLE_DOCSTRING,
547547
mkl_fn_to_call="_mkl_arg_to_call",
548548
mkl_impl_fn="_arg",

dpnp/dpnp_iface_trigonometric.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ def _get_accumulation_res_dt(a, dtype):
311311

312312
asin = DPNPUnaryFunc(
313313
"asin",
314-
ti._asin_result_type,
315-
ti._asin,
314+
ti_ext._asin_result_type,
315+
ti_ext._asin,
316316
_ASIN_DOCSTRING,
317317
mkl_fn_to_call="_mkl_asin_to_call",
318318
mkl_impl_fn="_asin",
@@ -395,8 +395,8 @@ def _get_accumulation_res_dt(a, dtype):
395395

396396
asinh = DPNPUnaryFunc(
397397
"asinh",
398-
ti._asinh_result_type,
399-
ti._asinh,
398+
ti_ext._asinh_result_type,
399+
ti_ext._asinh,
400400
_ASINH_DOCSTRING,
401401
mkl_fn_to_call="_mkl_asinh_to_call",
402402
mkl_impl_fn="_asinh",

0 commit comments

Comments
 (0)