Skip to content

Commit 8a8411a

Browse files
Exposed dpctl.tensor.divide(x, y)
1 parent 6b56e99 commit 8a8411a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

dpctl/tensor/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@
9191
from dpctl.tensor._utility_functions import all, any
9292

9393
from ._constants import e, inf, nan, newaxis, pi
94-
from ._elementwise_funcs import abs, add, cos, isfinite, isinf, isnan, sqrt
94+
from ._elementwise_funcs import (
95+
abs,
96+
add,
97+
cos,
98+
divide,
99+
isfinite,
100+
isinf,
101+
isnan,
102+
sqrt,
103+
)
95104

96105
__all__ = [
97106
"Device",
@@ -175,4 +184,5 @@
175184
"isnan",
176185
"isfinite",
177186
"sqrt",
187+
"divide",
178188
]

dpctl/tensor/_elementwise_funcs.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@
3131
"add", ti._add_result_type, ti._add, _add_docstring_
3232
)
3333

34+
# DIVIDE
35+
36+
_divide_docstring_ = """
37+
divide(x1, x2, order='K')
38+
39+
Calculates the ratio for each element `x1_i` of the input array `x1` with
40+
the respective element `x2_i` of the input array `x2`.
41+
42+
Args:
43+
x1 (usm_ndarray):
44+
First input array, expected to have numeric data type.
45+
x2 (usm_ndarray):
46+
Second input array, also expected to have numeric data type.
47+
Returns:
48+
usm_narray:
49+
an array containing the result of element-wise division. The data type
50+
of the returned array is determined by the Type Promotion Rules.
51+
"""
52+
divide = BinaryElementwiseFunc(
53+
"divide", ti._divide_result_type, ti._divide, _divide_docstring_
54+
)
55+
3456

3557
# COS
3658

0 commit comments

Comments
 (0)