-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Optional out parameter for numpy.dot #33
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
Closed
Closed
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 avoids the memory allocation. It is very strict in checking that the types are correct, but since it is intended as an optimisation, it should only be used when the user knows what they are doing.
Using the toy example in the test as a benchmark, I clocked 63ms with an `out` parameter, versus 91ms without. Here is the full benchmark (requires ipython):: import numpy as np np.random.seed(22) f = np.random.rand(1024*128, 16) v = np.random.rand(16,32) r = np.empty((1024*128, 32)) _ip.magic("timeit np.dot(f,v,r)") _ip.magic("timeit np.dot(f,v)")
(Pointed out by pv on github)
This allows `np.dot(a, b, out=r)`. Suggested by pv.
…ture in PyArray_MatrixProduct2
This indicates that the function takes 3 arguments
Can this be merged in? If more changes are needed, I'm willing to work on them. |
Thanks, it's applied in af1e833 |
This is great, thank you! |
bashtage
referenced
this pull request
in bashtage/numpy
May 27, 2019
Revert "MAINT: Implement API changes for randomgen-derived code"
fangerer
added a commit
to hpyproject/numpy-hpy
that referenced
this pull request
Jul 7, 2022
… instead of legacy function Merge in ~STEPAN.SINDELAR_ORACLE.COM/numpy-hpy from fa/init_numeric_casts to labs-hpy-port * commit 'ad0a23fe9df1c6b869314d3d593e58ef25dcedf3': Fix: Use HPyArray_AddCastingImplementation_FromSpec instead of legacy function
luyahan
pushed a commit
to plctlab/numpy
that referenced
this pull request
Apr 25, 2024
chore: Add macro guard for inclusion
This pull request was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 adds an optional output argument for np.dot, for extra performance (I measured a significant different for very large matrices).
I had submitted this before, but there were a few suggestions for improvement. Iimplemented some, pv helped a lot and wrote some code too; all of the suggestions have now been incorportated.