-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Avoid copy in matrix-vector dots with negative strides? #28909
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
Comments
I was inspecting Currently, the function checks for negative strides, broadcasts, and possible misalignment via An enhancement here could involve extending As @ricardoV94 mentioned, it’s unclear whether the gain is worth the added complexity. Still, I wanted to get a second opinion — if this seems useful, I’d be happy to take it on. cc: @eendebakpt |
Making a copy of the array with negative strides is also quite expensive( @niranjanorkat I cannot judge whether this is useful or not. It depends on how much complexity the additional code adds (probably hard to judge without actually implementing), and how often this case of negative strides occurs in actual code. |
Negative strides are common for us when computing gradient of Cumsum/Convolution functions |
Uh oh!
There was an error while loading. Please reload this page.
The following is ~5x slower when A has negative strides:
I suspect it's due to a copy before calling a blas GEMV as it doesn't allow negative strides. However, if this is the case, it is possible to just tell blas to iterate over A with a positive LDA but negative inc_y, to obtain the same results without having to perform a copy.
If the columns have negative strides, one needs to iterate in reverse over x as well
I don't know if this is easy/worth doing in numpy, just wanted to share.
The text was updated successfully, but these errors were encountered: