-
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
Fixes element-wise comparisons of mixed signed-unsigned integer inputs #1650
Conversation
Overloads for combinations of complex and real valued floats are unnecessary, as floats can be safely cast to complex
@oleksandr-pavlyk For |
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_303 ran successfully. |
Comparions between signed and unsigned integer data previously did not work correctly in some cases, as signed integers could be promoted to uint64 if one input was uint64 Additionally, `-1 < x` for some `x` with unsigned integer data type would always fail, as the -1 would initialize an array of `x.dtype` which would always underflow, leading to undefined behavior These problems were addressed by adding signed and unsigned 64-bit integer combinations to the type maps for the comparisons, and adding constexpr branches to the comparisons between mixed-kind integers
9429a64
to
2331c1c
Compare
Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_304 ran successfully. |
… utility function Per suggestion by @oleksandr-pavlyk
… arrays and Python scalars
@oleksandr-pavlyk As of Numpy 2, Numpy will no longer permit converting Python integers to integer arrays where the Python integer is out-of-bounds for the integer array's data type (at least in ufuncs). This is how they resolve the issues with Imitating that behavior would align with the future of Numpy (and therefore should be acceptable to DPNP) and seems like the most sensible path forward since array API disallows promotion for those functions, but will take a little more work. Therefore, I will handle it in a separate PR, and this is ready for review pending CI success. |
Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_312 ran successfully. |
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.
Thank you @ndgrigorian ! Looks good to me. Local testing worked well too.
This pull request addresses issues in comparison functions with mixed integral kinds (signed and unsigned) by explicitly adding overloads for combinations of
uint64
andint64
and adding a unique weak-type resolver function for the comparisons.The resolver function guarantees that negative Python scalars are not used to initialize an array with an unsigned integer data type in the binary comparisons, which makes comparisons between negative Python scalars and unsigned integer arrays work as expected.
Old behavior:
Now:
Also slips in a change removing an unnecessary overload to
not_equal
for mixed float and complex float data types, which are safe for basic casting and not present in other elementwise comparisons.