-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use matmul, matvec instead of dot, avoiding reshapes. #18570
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
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
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.
LGTM.
While the code looks good, locally I see a degraded performance, which I didn't expect. I'll need to run some more tests before merging. |
Timings for two arrays of shape (2000, 2000): Timings for two arrays of shape (4000, 4000): The old code here does not look like it is subject to the future "shape" deprecations. It already uses |
@nden - wow, I would have thought my PR would have sped up, not slown down. I'd like to investigate, since perhaps this means that on the numpy side this could be improved a lot too. Just so I'm sure that I'm doing the right thing, could you give the full example you tested? In the meantime, I'll convert this to draft so it won't get merged accidentally. |
That is because it was already adjusted in #18562 - when reviewing that PR, I thought I could make a further improvement... |
@mhvk Thanks for following up! The test example is
|
Great, thanks both! |
This pull request is a quick follow up to #18562, where I noticed that a routine raveled and reshaped an array to work correctly with
np.dot
, when this is no longer necessary withmatmul
and the newermatvec
. Note that the routine will become even simpler once our minimal numpy version is 2.2, since then we can count onnp.matvec
being available.