Skip to content

Commit 5314ddd

Browse files
committed
address reviewer comments
1 parent cc2604b commit 5314ddd

File tree

3 files changed

+166
-18
lines changed

3 files changed

+166
-18
lines changed

dpctl/tensor/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
cos,
9898
divide,
9999
equal,
100-
expm1,
101100
exp,
101+
expm1,
102102
isfinite,
103103
isinf,
104104
isnan,
@@ -189,15 +189,15 @@
189189
"abs",
190190
"add",
191191
"cos",
192+
"exp",
192193
"expm1",
193-
"sin",
194194
"isinf",
195195
"isnan",
196196
"isfinite",
197197
"log",
198198
"log1p",
199+
"sin",
199200
"sqrt",
200-
"exp",
201201
"divide",
202202
"multiply",
203203
"subtract",

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)
@@ -199,7 +263,22 @@
199263
_isfinite_docstring_ = """
200264
isfinite(x, out=None, order='K')
201265
202-
Computes if every element of input array is a finite number.
266+
Checks if each element of input array is a finite number.
267+
268+
Args:
269+
x (usm_ndarray):
270+
Input array, expected to have numeric data type.
271+
out ({None, usm_ndarray}, optional):
272+
Output array to populate.
273+
Array have the correct shape and the expected data type.
274+
order ("C","F","A","K", optional):
275+
Memory layout of the newly output array, if parameter `out` is `None`.
276+
Default: "K".
277+
Returns:
278+
usm_narray:
279+
An array which is True where `x` is not positive infinity,
280+
negative infinity, or NaN, False otherwise.
281+
The data type of the returned array is boolean.
203282
"""
204283

205284
isfinite = UnaryElementwiseFunc(
@@ -210,7 +289,21 @@
210289
_isinf_docstring_ = """
211290
isinf(x, out=None, order='K')
212291
213-
Computes if every element of input array is an infinity.
292+
Checks if each element of input array is an infinity.
293+
294+
Args:
295+
x (usm_ndarray):
296+
Input array, expected to have numeric data type.
297+
out ({None, usm_ndarray}, optional):
298+
Output array to populate.
299+
Array have the correct shape and the expected data type.
300+
order ("C","F","A","K", optional):
301+
Memory layout of the newly output array, if parameter `out` is `None`.
302+
Default: "K".
303+
Returns:
304+
usm_narray:
305+
An array which is True where `x` is positive or negative infinity,
306+
False otherwise. The data type of the returned array is boolean.
214307
"""
215308

216309
isinf = UnaryElementwiseFunc(
@@ -221,7 +314,21 @@
221314
_isnan_docstring_ = """
222315
isnan(x, out=None, order='K')
223316
224-
Computes if every element of input array is a NaN.
317+
Checks if each element of an input array is a NaN.
318+
319+
Args:
320+
x (usm_ndarray):
321+
Input array, expected to have numeric data type.
322+
out ({None, usm_ndarray}, optional):
323+
Output array to populate.
324+
Array have the correct shape and the expected data type.
325+
order ("C","F","A","K", optional):
326+
Memory layout of the newly output array, if parameter `out` is `None`.
327+
Default: "K".
328+
Returns:
329+
usm_narray:
330+
An array which is True where x is NaN, False otherwise.
331+
The data type of the returned array is boolean.
225332
"""
226333

227334
isnan = UnaryElementwiseFunc(
@@ -309,9 +416,15 @@
309416
First input array, expected to have numeric data type.
310417
x2 (usm_ndarray):
311418
Second input array, also expected to have numeric data type.
419+
out ({None, usm_ndarray}, optional):
420+
Output array to populate.
421+
Array have the correct shape and the expected data type.
422+
order ("C","F","A","K", optional):
423+
Memory layout of the newly output array, if parameter `out` is `None`.
424+
Default: "K".
312425
Returns:
313426
usm_narray:
314-
an array containing the element-wise products. The data type of
427+
An array containing the element-wise products. The data type of
315428
the returned array is determined by the Type Promotion Rules.
316429
"""
317430
multiply = BinaryElementwiseFunc(
@@ -344,9 +457,23 @@
344457

345458
# U30: ==== SIN (x)
346459
_sin_docstring = """
347-
sin(x, order='K')
460+
sin(x, out=None, order='K')
348461
349-
Computes sin for each element `x_i` for input array `x`.
462+
Computes sine for each element `x_i` of input array `x`.
463+
464+
Args:
465+
x (usm_ndarray):
466+
Input array, expected to have numeric data type.
467+
out ({None, usm_ndarray}, optional):
468+
Output array to populate.
469+
Array have the correct shape and the expected data type.
470+
order ("C","F","A","K", optional):
471+
Memory layout of the newly output array, if parameter `out` is `None`.
472+
Default: "K".
473+
Returns:
474+
usm_narray:
475+
An array containing the element-wise sine. The data type of the
476+
returned array is determined by the Type Promotion Rules.
350477
"""
351478

352479
sin = UnaryElementwiseFunc("sin", ti._sin_result_type, ti._sin, _sin_docstring)
@@ -361,7 +488,22 @@
361488
_sqrt_docstring_ = """
362489
sqrt(x, out=None, order='K')
363490
364-
Computes sqrt for each element `x_i` for input array `x`.
491+
Computes positive square-root for each element `x_i` for input array `x`.
492+
493+
Args:
494+
x (usm_ndarray):
495+
Input array, expected to have numeric data type.
496+
out ({None, usm_ndarray}, optional):
497+
Output array to populate.
498+
Array have the correct shape and the expected data type.
499+
order ("C","F","A","K", optional):
500+
Memory layout of the newly output array, if parameter `out` is `None`.
501+
Default: "K".
502+
Returns:
503+
usm_narray:
504+
An array containing the element-wise positive square-root.
505+
The data type of the returned array is determined by
506+
the Type Promotion Rules.
365507
"""
366508

367509
sqrt = UnaryElementwiseFunc(
@@ -380,9 +522,15 @@
380522
First input array, expected to have numeric data type.
381523
x2 (usm_ndarray):
382524
Second input array, also expected to have numeric data type.
525+
out ({None, usm_ndarray}, optional):
526+
Output array to populate.
527+
Array have the correct shape and the expected data type.
528+
order ("C","F","A","K", optional):
529+
Memory layout of the newly output array, if parameter `out` is `None`.
530+
Default: "K".
383531
Returns:
384532
usm_narray:
385-
an array containing the element-wise differences. The data type
533+
An array containing the element-wise differences. The data type
386534
of the returned array is determined by the Type Promotion Rules.
387535
"""
388536
subtract = BinaryElementwiseFunc(

dpctl/tensor/libtensor/source/elementwise_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include "kernels/elementwise_functions/add.hpp"
3737
#include "kernels/elementwise_functions/cos.hpp"
3838
#include "kernels/elementwise_functions/equal.hpp"
39-
#include "kernels/elementwise_functions/expm1.hpp"
4039
#include "kernels/elementwise_functions/exp.hpp"
40+
#include "kernels/elementwise_functions/expm1.hpp"
4141
#include "kernels/elementwise_functions/isfinite.hpp"
4242
#include "kernels/elementwise_functions/isinf.hpp"
4343
#include "kernels/elementwise_functions/isnan.hpp"

0 commit comments

Comments
 (0)