-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: Improve performance of numpy.nonzero for 1D/2D contiguous arrays #27519
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
Open
eendebakpt
wants to merge
20
commits into
numpy:main
Choose a base branch
from
eendebakpt:nonzero_optmize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d84439a
ENH: Improve performance of numpy.nonzero for 1D contiguous arrays
eendebakpt c29c232
refactor
eendebakpt 503ec14
remove assert
eendebakpt 60c9b88
Merge branch 'main' into nonzero_optmize
eendebakpt 82450ae
refactor
eendebakpt 5bbe2ce
Merge branch 'main' into nonzero_optmize
eendebakpt 4ca8220
Merge branch 'main' into nonzero_optmize
eendebakpt 76e0e41
use npy_bool
eendebakpt 53a9ef3
review comments
eendebakpt 5ec3c50
refactor
eendebakpt 6c320f3
fix setting executed
eendebakpt 1050920
add guard for mutating array
eendebakpt 8de9ff7
fix bool conversion
eendebakpt 5444f08
Merge branch 'main' into nonzero_optmize
eendebakpt b539299
Merge branch 'main' into nonzero_optmize
eendebakpt bc0a9ae
add check on alignment
eendebakpt 0b3ee4f
lint
eendebakpt f4fae21
fix test
eendebakpt a9905be
code style
eendebakpt 6636bbf
Merge branch 'main' into nonzero_optmize
eendebakpt 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
review comments
- Loading branch information
commit 53a9ef386d6f00230316821d1412fb151e288cd9
There are no files selected for viewing
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 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 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 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
Oops, something went wrong.
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.
This branch is missing the thresholded GIL release (internals of it I guess).
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.
Releasing the GIL (or running the cpython free-threading build) could result in a buffer overflow if another thread changes the number of non-zero entries in the array. I added a guard for that, but we should rerun the benchmarks (I still expect a good speedup though).
Should a test be added for this? (probably here: https://github.com/numpy/numpy/blob/main/numpy/_core/tests/test_multithreading.py)
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.
Interesting, a case where we would actually want to lock down a whole array (but I think this is super hard with buffer exchange, so in practice...).
Would be very cool if you add a test. Larger use of free-threading is in the future after-all, and maybe not a too distant one.
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.
Tests have been added in #28361