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
CUDA: Add binary ufunc support #8974
Conversation
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.
From a first pass over this, I think this is looking good like the pattern for implementing ufuncs in CUDA is followed correctly - I have a suggestion and a comment on the diff for now, and will have another pass once I understand the responses.
numba/cuda/ufuncs.py
Outdated
@@ -272,4 +272,55 @@ def np_real_atanh_impl(context, builder, sig, args): | |||
|
|||
db[np.degrees] = db[np.rad2deg] | |||
|
|||
db[np.bitwise_and] = { | |||
'll->l': numbers.int_and_impl, |
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.
Why do we not have implementations for unsigned types?
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.
Thanks! I added the missing types from np.<ufunc>.types
except O
which is a generic python object
gpuci run tests |
gpuci run tests |
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.
Many thanks for the updates! A couple of quick questions / observations on the diff.
numba/cuda/ufuncs.py
Outdated
db[np.bitwise_not] = db[np.invert] | ||
|
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.
I think this is superflous, and just reassigns the same key in the dict - these two keys are the same:
$ python -c "import numpy as np; print(np.invert is np.bitwise_not)"
True
I think this can be removed.
gpuci run tests |
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.
Many thanks for the updates! This looks good now.
I think I'd like a buildfarm run for this, since it's the first set of new ufuncs we've added since the addition of the feature - maybe eventually these additions will seem "safe" / generally expected to work everywhere if they work in gpuCI, but I'm not confident there yet.
@stuartarchibald / @sklam Could this have a buildfarm run please?
I understand from an OOB message that |
Following from #8294, this PR adds support for binary ufuncs for the CUDA target (
bitwise_and
,bitwise_or
, etc.). Currently there aren't any unit tests fornp.left_shift
andnp.right_shift
. I didn't add them because there was a comment here saying the tests were not added for the CPU target either.