-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
ENH: linalg: add batch support for functions that accept a single array #22133
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
Conversation
Xref #21446 (comment) it might be worth checking if the decorator is needed for some of these functions Edit: oops should have read the additional info first |
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.
Maybe also worth passing the batched input a keyword argument in the tests?
Good idea, or if it's ok with you, I'll just inspect for the name of the argument? I didn't in the initial PR to keep things "simple", but I'll show that the overhead is negligible, and clearly it's less prone to error. Well, I'll start by adding it to the test. |
Not to block any of these nice additions; For the matrix functions, I have some time to finish up |
I think the idea is for any of these is, if batching in the compiled code materialises then the decorator can be removed. Plus this means there's already a test for batching there ready and waiting:) |
Agreed - just adding that something would need to be done for the documentation, since the decorator adds the standard note right now. scipy/scipy/linalg/_matfuncs.py Lines 316 to 318 in acf6736
Is that what you had in mind? I would not add more of that when the decorator does the same thing. |
One of the CI failures was a test that wanted to see an error with 3D input, so I removed that. The other involved CWT with sparse input. The decorator doesn't consider that right now, so I just removed it from CWT. |
That python loop is not affecting since the I just wanted to know if we can remove the decorator and still be consistent in case we do the batching internally. I guess we can with a bit of extra work. |
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.
Thanks!
Reference issue
Follow-up to gh-22127
Toward gh-21466
What does this implement/fix?
This adds support for n-dimensional batch input to
linalg
functionsdiagsvd
,inv
,null_space
,logm
,sinm
,cosm
,tanm
,sinhn
,coshm
,tanhm
,sqrtm
,funm
,signm
,fractional_matrix_power
,pinv
,pinvh
,matrix_balance
,bandwidth
,svd
,ldl
,cholesky
,polar
,qr
,rq
,hessenberg
,schur
,orth
,lu_factor
,eig_banded
, andeigvals_banded
because they all accept only one array input. (Please check me on this.)Additional information
Even though functions like
cosm
are expressed in terms ofexpm
, we might as well apply the decorator to them separately becauseexpm
just loops in Python, too. This is less work and we get the batch support documentation for free.