-
Notifications
You must be signed in to change notification settings - Fork 30
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
Adds element-wise functions angle
and reciprocal
#1474
Conversation
This change was made to mirror promotion behavior of divide in reciprocal Adds getter method for the acceptance function Adds tests for reciprocal
_zero_like did not have logic accounting for 0D arrays, so `x.imag` failed for 0D x
This prevents unexpected behavior when calling `imag` i.e., for x with a real-valued data type `dpctl.tensor.atan2(x.imag, x.real)` would not work prior to this change
The logic in these properties did not work for float16 data types, returning None instead of `self` or an array of zeros
View rendered docs @ https://intelpython.github.io/dpctl/pulls/1474/index.html |
Array API standard conformance tests for dpctl=0.15.1dev2=py310h15de555_26 ran successfully. |
Array API standard conformance tests for dpctl=0.15.1dev2=py310h15de555_27 ran successfully. |
Array API standard conformance tests for dpctl=0.15.1dev2=py310h15de555_27 ran successfully. |
@@ -698,7 +699,8 @@ cdef class usm_ndarray: | |||
""" Returns imaginary component for arrays with complex data-types | |||
and returns zero array for all other data-types. | |||
""" | |||
if (self.typenum_ < UAR_CFLOAT): | |||
# explicitly check for UAR_HALF, which is greater than UAR_CFLOAT | |||
if (self.typenum_ < UAR_CFLOAT or self.typenum_ == UAR_HALF): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module the renaming suggestion this PR is in perfect shape. The renaming can be addressed in a separate PR though.
`_acceptance_fn_default1` and `_acceptance_fn_default2` are now `_acceptance_fn_default_unary` and `_acceptance_fn_default_binary`
I noticed a typo in the |
Array API standard conformance tests for dpctl=0.15.1dev2=py310h15de555_29 ran successfully. |
Internal CI failures are not related to this PR and will be investigated separately I will merge this |
This pull request implements two new element-wise functions,
dpctl.tensor.angle
anddpctl.tensor.reciprocal
.To support the inclusion of
reciprocal
, an acceptance function argument to theUnaryElementwiseFunc
class is added to align the behavior ofreciprocal
anddivide
.This pull request also slips in bug fixes to
usm_ndarray
-- namely, thereal
andimag
properties.imag
was not allocating to the same queue as the original array for real-valued types, and would raise an exception for real-valued 0D arrays.Both
real
andimag
would returnNone
forfloat16
arrays as a result of incorrect logic in the typenum checks.