Skip to content

Commit 234abd4

Browse files
committed
address reviewer comments
1 parent 0eb7a91 commit 234abd4

File tree

1 file changed

+162
-14
lines changed

1 file changed

+162
-14
lines changed

dpctl/tensor/_elementwise_funcs.py

Lines changed: 162 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,24 @@
2020

2121
# U01: ==== ABS (x)
2222
_abs_docstring_ = """
23-
Calculate the absolute value element-wise.
23+
abs(x, out=None, order='K')
24+
25+
Calculates the absolute value for each element `x_i` of input array `x`.
26+
27+
Args:
28+
x (usm_ndarray):
29+
Input array, expected to have numeric data type.
30+
out ({None, usm_ndarray}, optional):
31+
Output array to populate.
32+
Array have the correct shape and the expected data type.
33+
order ("C","F","A","K", optional):
34+
Memory layout of the newly output array, if parameter `out` is `None`.
35+
Default: "K".
36+
Returns:
37+
usm_narray:
38+
An array containing the element-wise absolute values.
39+
For complex input, the absolute value is its magnitude. The data type
40+
of the returned array is determined by the Type Promotion Rules.
2441
"""
2542

2643
abs = UnaryElementwiseFunc("abs", ti._abs_result_type, ti._abs, _abs_docstring_)
@@ -44,9 +61,15 @@
4461
First input array, expected to have numeric data type.
4562
x2 (usm_ndarray):
4663
Second input array, also expected to have numeric data type.
64+
out ({None, usm_ndarray}, optional):
65+
Output array to populate.
66+
Array have the correct shape and the expected data type.
67+
order ("C","F","A","K", optional):
68+
Memory layout of the newly output array, if parameter `out` is `None`.
69+
Default: "K".
4770
Returns:
4871
usm_narray:
49-
an array containing the element-wise sums. The data type of the
72+
An array containing the element-wise sums. The data type of the
5073
returned array is determined by the Type Promotion Rules.
5174
"""
5275
add = BinaryElementwiseFunc(
@@ -97,6 +120,20 @@
97120
cos(x, out=None, order='K')
98121
99122
Computes cosine for each element `x_i` for input array `x`.
123+
124+
Args:
125+
x (usm_ndarray):
126+
Input array, expected to have numeric data type.
127+
out ({None, usm_ndarray}, optional):
128+
Output array to populate.
129+
Array have the correct shape and the expected data type.
130+
order ("C","F","A","K", optional):
131+
Memory layout of the newly output array, if parameter `out` is `None`.
132+
Default: "K".
133+
Returns:
134+
usm_narray:
135+
An array containing the element-wise cosine. The data type
136+
of the returned array is determined by the Type Promotion Rules.
100137
"""
101138

102139
cos = UnaryElementwiseFunc("cos", ti._cos_result_type, ti._cos, _cos_docstring)
@@ -116,9 +153,15 @@
116153
First input array, expected to have numeric data type.
117154
x2 (usm_ndarray):
118155
Second input array, also expected to have numeric data type.
156+
out ({None, usm_ndarray}, optional):
157+
Output array to populate.
158+
Array have the correct shape and the expected data type.
159+
order ("C","F","A","K", optional):
160+
Memory layout of the newly output array, if parameter `out` is `None`.
161+
Default: "K".
119162
Returns:
120163
usm_narray:
121-
an array containing the result of element-wise division. The data type
164+
An array containing the result of element-wise division. The data type
122165
of the returned array is determined by the Type Promotion Rules.
123166
"""
124167

@@ -138,9 +181,15 @@
138181
First input array, expected to have numeric data type.
139182
x2 (usm_ndarray):
140183
Second input array, also expected to have numeric data type.
184+
out ({None, usm_ndarray}, optional):
185+
Output array to populate.
186+
Array have the correct shape and the expected data type.
187+
order ("C","F","A","K", optional):
188+
Memory layout of the newly output array, if parameter `out` is `None`.
189+
Default: "K".
141190
Returns:
142191
usm_narray:
143-
an array containing the result of element-wise equality comparison.
192+
An array containing the result of element-wise equality comparison.
144193
The data type of the returned array is determined by the
145194
Type Promotion Rules.
146195
"""
@@ -151,9 +200,24 @@
151200

152201
# U13: ==== EXP (x)
153202
_exp_docstring = """
154-
exp(x, order='K')
203+
exp(x, out=None, order='K')
204+
205+
Computes exponential for each element `x_i` of input array `x`.
155206
156-
Computes exponential for each element `x_i` for input array `x`.
207+
Args:
208+
x (usm_ndarray):
209+
Input array, expected to have numeric data type.
210+
out ({None, usm_ndarray}, optional):
211+
Output array to populate.
212+
Array have the correct shape and the expected data type.
213+
order ("C","F","A","K", optional):
214+
Memory layout of the newly output array, if parameter `out` is `None`.
215+
Default: "K".
216+
Returns:
217+
usm_narray:
218+
an array containing the element-wise exponential of x.
219+
The data type of the returned array is determined by
220+
the Type Promotion Rules.
157221
"""
158222

159223
exp = UnaryElementwiseFunc("exp", ti._exp_result_type, ti._exp, _exp_docstring)
@@ -180,7 +244,22 @@
180244
_isfinite_docstring_ = """
181245
isfinite(x, out=None, order='K')
182246
183-
Computes if every element of input array is a finite number.
247+
Checks if each element of input array is a finite number.
248+
249+
Args:
250+
x (usm_ndarray):
251+
Input array, expected to have numeric data type.
252+
out ({None, usm_ndarray}, optional):
253+
Output array to populate.
254+
Array have the correct shape and the expected data type.
255+
order ("C","F","A","K", optional):
256+
Memory layout of the newly output array, if parameter `out` is `None`.
257+
Default: "K".
258+
Returns:
259+
usm_narray:
260+
An array which is True where `x` is not positive infinity,
261+
negative infinity, or NaN, False otherwise.
262+
The data type of the returned array is boolean.
184263
"""
185264

186265
isfinite = UnaryElementwiseFunc(
@@ -191,7 +270,21 @@
191270
_isinf_docstring_ = """
192271
isinf(x, out=None, order='K')
193272
194-
Computes if every element of input array is an infinity.
273+
Checks if each element of input array is an infinity.
274+
275+
Args:
276+
x (usm_ndarray):
277+
Input array, expected to have numeric data type.
278+
out ({None, usm_ndarray}, optional):
279+
Output array to populate.
280+
Array have the correct shape and the expected data type.
281+
order ("C","F","A","K", optional):
282+
Memory layout of the newly output array, if parameter `out` is `None`.
283+
Default: "K".
284+
Returns:
285+
usm_narray:
286+
An array which is True where `x` is positive or negative infinity,
287+
False otherwise. The data type of the returned array is boolean.
195288
"""
196289

197290
isinf = UnaryElementwiseFunc(
@@ -202,7 +295,21 @@
202295
_isnan_docstring_ = """
203296
isnan(x, out=None, order='K')
204297
205-
Computes if every element of input array is a NaN.
298+
Checks if each element of an input array is a NaN.
299+
300+
Args:
301+
x (usm_ndarray):
302+
Input array, expected to have numeric data type.
303+
out ({None, usm_ndarray}, optional):
304+
Output array to populate.
305+
Array have the correct shape and the expected data type.
306+
order ("C","F","A","K", optional):
307+
Memory layout of the newly output array, if parameter `out` is `None`.
308+
Default: "K".
309+
Returns:
310+
usm_narray:
311+
An array which is True where x is NaN, False otherwise.
312+
The data type of the returned array is boolean.
206313
"""
207314

208315
isnan = UnaryElementwiseFunc(
@@ -254,9 +361,15 @@
254361
First input array, expected to have numeric data type.
255362
x2 (usm_ndarray):
256363
Second input array, also expected to have numeric data type.
364+
out ({None, usm_ndarray}, optional):
365+
Output array to populate.
366+
Array have the correct shape and the expected data type.
367+
order ("C","F","A","K", optional):
368+
Memory layout of the newly output array, if parameter `out` is `None`.
369+
Default: "K".
257370
Returns:
258371
usm_narray:
259-
an array containing the element-wise products. The data type of
372+
An array containing the element-wise products. The data type of
260373
the returned array is determined by the Type Promotion Rules.
261374
"""
262375
multiply = BinaryElementwiseFunc(
@@ -289,9 +402,23 @@
289402

290403
# U30: ==== SIN (x)
291404
_sin_docstring = """
292-
sin(x, order='K')
405+
sin(x, out=None, order='K')
293406
294-
Computes sin for each element `x_i` for input array `x`.
407+
Computes sine for each element `x_i` of input array `x`.
408+
409+
Args:
410+
x (usm_ndarray):
411+
Input array, expected to have numeric data type.
412+
out ({None, usm_ndarray}, optional):
413+
Output array to populate.
414+
Array have the correct shape and the expected data type.
415+
order ("C","F","A","K", optional):
416+
Memory layout of the newly output array, if parameter `out` is `None`.
417+
Default: "K".
418+
Returns:
419+
usm_narray:
420+
An array containing the element-wise sine. The data type of the
421+
returned array is determined by the Type Promotion Rules.
295422
"""
296423

297424
sin = UnaryElementwiseFunc("sin", ti._sin_result_type, ti._sin, _sin_docstring)
@@ -306,7 +433,22 @@
306433
_sqrt_docstring_ = """
307434
sqrt(x, out=None, order='K')
308435
309-
Computes sqrt for each element `x_i` for input array `x`.
436+
Computes positive square-root for each element `x_i` for input array `x`.
437+
438+
Args:
439+
x (usm_ndarray):
440+
Input array, expected to have numeric data type.
441+
out ({None, usm_ndarray}, optional):
442+
Output array to populate.
443+
Array have the correct shape and the expected data type.
444+
order ("C","F","A","K", optional):
445+
Memory layout of the newly output array, if parameter `out` is `None`.
446+
Default: "K".
447+
Returns:
448+
usm_narray:
449+
An array containing the element-wise positive square-root.
450+
The data type of the returned array is determined by
451+
the Type Promotion Rules.
310452
"""
311453

312454
sqrt = UnaryElementwiseFunc(
@@ -325,9 +467,15 @@
325467
First input array, expected to have numeric data type.
326468
x2 (usm_ndarray):
327469
Second input array, also expected to have numeric data type.
470+
out ({None, usm_ndarray}, optional):
471+
Output array to populate.
472+
Array have the correct shape and the expected data type.
473+
order ("C","F","A","K", optional):
474+
Memory layout of the newly output array, if parameter `out` is `None`.
475+
Default: "K".
328476
Returns:
329477
usm_narray:
330-
an array containing the element-wise differences. The data type
478+
An array containing the element-wise differences. The data type
331479
of the returned array is determined by the Type Promotion Rules.
332480
"""
333481
subtract = BinaryElementwiseFunc(

0 commit comments

Comments
 (0)