Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of less_equal, greater, greater_equal for dpctl.tensor #1239

Merged
merged 5 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@
exp,
expm1,
floor_divide,
greater,
greater_equal,
imag,
isfinite,
isinf,
isnan,
less,
less_equal,
log,
log1p,
multiply,
Expand Down Expand Up @@ -199,11 +202,14 @@
"cos",
"exp",
"expm1",
"greater",
"greater_equal",
"imag",
"isinf",
"isnan",
"isfinite",
"less",
"less_equal",
"log",
"log1p",
"proj",
Expand Down
86 changes: 83 additions & 3 deletions dpctl/tensor/_elementwise_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,62 @@
)

# B11: ==== GREATER (x1, x2)
# FIXME: implement B11
_greater_docstring_ = """
greater(x1, x2, out=None, order='K')
Computes the greater-than test results for each element `x1_i` of
the input array `x1` the respective element `x2_i` of the input array `x2`.
Args:
x1 (usm_ndarray):
First input array, expected to have numeric data type.
x2 (usm_ndarray):
Second input array, also expected to have numeric data type.
out ({None, usm_ndarray}, optional):
Output array to populate.
Array have the correct shape and the expected data type.
order ("C","F","A","K", optional):
Memory layout of the newly output array, if parameter `out` is `None`.
Default: "K".
Returns:
usm_narray:
An array containing the result of element-wise greater-than comparison.
The data type of the returned array is determined by the
Type Promotion Rules.
"""

greater = BinaryElementwiseFunc(
"greater", ti._greater_result_type, ti._greater, _greater_docstring_
)

# B12: ==== GREATER_EQUAL (x1, x2)
# FIXME: implement B12
_greater_equal_docstring_ = """
greater_equal(x1, x2, out=None, order='K')
Computes the greater-than or equal-to test results for each element `x1_i` of
the input array `x1` the respective element `x2_i` of the input array `x2`.
Args:
x1 (usm_ndarray):
First input array, expected to have numeric data type.
x2 (usm_ndarray):
Second input array, also expected to have numeric data type.
out ({None, usm_ndarray}, optional):
Output array to populate.
Array have the correct shape and the expected data type.
order ("C","F","A","K", optional):
Memory layout of the newly output array, if parameter `out` is `None`.
Default: "K".
Returns:
usm_narray:
An array containing the result of element-wise greater-than or equal-to
comparison.
The data type of the returned array is determined by the
Type Promotion Rules.
"""

greater_equal = BinaryElementwiseFunc(
"greater_equal",
ti._greater_equal_result_type,
ti._greater_equal,
_greater_equal_docstring_,
)

# U16: ==== IMAG (x)
_imag_docstring = """
Expand Down Expand Up @@ -434,7 +486,35 @@
)

# B14: ==== LESS_EQUAL (x1, x2)
# FIXME: implement B14
_less_equal_docstring_ = """
less_equal(x1, x2, out=None, order='K')
Computes the less-than or equal-to test results for each element `x1_i` of
the input array `x1` the respective element `x2_i` of the input array `x2`.
Args:
x1 (usm_ndarray):
First input array, expected to have numeric data type.
x2 (usm_ndarray):
Second input array, also expected to have numeric data type.
out ({None, usm_ndarray}, optional):
Output array to populate.
Array have the correct shape and the expected data type.
order ("C","F","A","K", optional):
Memory layout of the newly output array, if parameter `out` is `None`.
Default: "K".
Returns:
usm_narray:
An array containing the result of element-wise less-than or equal-to
comparison.
The data type of the returned array is determined by the
Type Promotion Rules.
"""

less_equal = BinaryElementwiseFunc(
"less_equal",
ti._less_equal_result_type,
ti._less_equal,
_less_equal_docstring_,
)

# U20: ==== LOG (x)
_log_docstring = """
Expand Down
Loading