-
Notifications
You must be signed in to change notification settings - Fork 920
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
Support Unary Operations in Masked UDF #9409
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
143e65d
unary op declaration works
isVoid 91d3de4
Adding more unary ops and tests
isVoid 43036b9
Adding test everything
isVoid 874ca02
Merge branch 'branch-21.12' of https://github.com/rapidsai/cudf into …
isVoid 9e3c37e
Make unary test cases take row like inputs
isVoid 84f5346
Apply suggestions from code review
isVoid 1443609
actually test unary ops in test_everything
isVoid 72bab55
add more unary ops and test them
isVoid 67f970d
address reviews
isVoid 96f99ae
Add operator.invert
isVoid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
All the unary math ops supported by the CUDA target can be found in Numba's cudamath.py, starting at this line: https://github.com/numba/numba/blob/master/numba/cuda/cudamath.py#L10 - it may be worth adding the complete set?
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 was able to get many unary ops in, except
math.trunc
. It's suggestingI believe it should should've gotten
trunc(float64)->int64
, maybe something is not registered correctly?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.
Besides
math.log
appears to be both a binary op and a unary op. Can we simply registermath.log
in binaryop as well as in unaryop to support both its usage?Lastly, is there a place for all
operator
ops? Sorry for cramming all the questions in one place!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.
For
trunc
, the lack of implementation in CUDA might be a bug in Numba - I'll check into it and get back to you.For
log
with two arguments, this appears not to be supported by the CUDA target (probably not for any good technical reason) - if the CUDA target did support it, just registeringlog
as both a unary and binary op would work (because when one typing fails Numba will carry on trying others until it finds a successful one).For all the operators, there's https://github.com/numba/numba/blob/master/numba/cpython/numbers.py - you have to look for all the instances of
lower_builtin
in that file. It's using the exact same code as the CPU target, so it isn't duplicated in the CUDA target, but instead the CUDA target pulls it in by "magic"... I started trying to trace exactly why the typing is registered for the CUDA target but I ended up going through several layers and still didn't get to the bottom of it. However, the lowering is pulled in by a side effect of this import in the CUDA target context: https://github.com/numba/numba/blob/master/numba/cuda/target.py#L88There 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 for pointing out the
operator
locations. I was able to addinvert
. Forabs
, there's an error:Which seems strange because the lowering for integer types are here: https://github.com/numba/numba/blob/2a792155c3dce43f86b9ff93802f12d39a3752dc/numba/cpython/numbers.py#L565
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.
Unless... it's not for cuda target?