-
Notifications
You must be signed in to change notification settings - Fork 286
Make NumpyOps CPU kernels generic #627
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
Merged
Merged
Conversation
This file contains hidden or 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 PR makes most CPU kernels generic, so that they can take both float32 and float64 arrays (and hopefully in the future float16). I experimented with kernels in Cython + fused types and kernels as C++ with templates, I found the C++ template route more promising: - More compact/ergonomic implementations with fewer compile-time conditionals. - Opens up the possibility to easily use SIMD intrinsics in the future. To allow genericity in the NumpyOps method arguments, we use: - Fused types when we require a specific dimensionality; - np.ndarray otherwise. Some of the kernels are not made generic: - cpu_scatter_add: needs tests to verify that the op still works correctly. - cpu_position_encode: the position_encode op doesn't take float array(s). - lstm kernels: I need to look more deeply into them.
shadeMe
reviewed
Apr 5, 2022
e9fb986 to
f5feb1c
Compare
svlandeg
reviewed
Apr 6, 2022
Contributor
|
Ugh - do we have a flaky test? |
Contributor
Author
Oh no, again the dreadful |
Contributor
|
Rerunning it 😐 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
Feature requests and improvements
feat / ops
Backends and maths
performance
Speed and memory use
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.
This PR makes most CPU kernels generic, so that they can take both
float32andfloat64arrays (and hopefully in the futurefloat16). I experimented with kernels in Cython + fused types and kernels as C++ with templates, I found the C++ template route more promising:To allow genericity in the
NumpyOpsmethod arguments, we use:np.ndarrayotherwise.Some of the kernels are not (yet) made generic:
cpu_scatter_add: needs tests to verify that the op still workscorrectly.
cpu_position_encode: the position_encode op doesn't take floatarray(s).