-
Notifications
You must be signed in to change notification settings - Fork 53
[Consistency] Default axes in linalg.diagonal
and linalg.trace
.
#215
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
Wouldn't it be better to just remove |
At least in PyTorch, it would be as efficient to transpose the diagonals to the back and then call diagonal than it would be calling it with this API. Now, this API may be convenient for some applications? That I do not know. I have never used diagonal with anything other than |
In CuPy it's also as efficient, given that transpose/swapaxes only return views (with different strides). I guess this suggests for both PyTorch and CuPy (and likely NumPy) removing |
+1 makes sense to me |
The functions
linalg.trace
andlinalg.diagonal
have as defaultaxis1=0, axis2=1
.This goes against the rest of the documentation, in which a batch of matrices is defined as a tensor with shape
(..., M, N)
.It would be more consistent with the rest of the API to have
axis1=-2, axis2=-1
to handle batches of matrices correctly by default.The text was updated successfully, but these errors were encountered: