Fixed SVD ignoring "some/full_matrices" flag for empty inputs#51109
Closed
IvanYashchuk wants to merge 1 commit intopytorch:masterfrom
Closed
Fixed SVD ignoring "some/full_matrices" flag for empty inputs#51109IvanYashchuk wants to merge 1 commit intopytorch:masterfrom
IvanYashchuk wants to merge 1 commit intopytorch:masterfrom
Conversation
Contributor
💊 CI failures summary and remediationsAs of commit a877b8c (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
Codecov Report
@@ Coverage Diff @@
## master #51109 +/- ##
=======================================
Coverage 80.91% 80.91%
=======================================
Files 1926 1926
Lines 210014 210013 -1
=======================================
Hits 169942 169942
+ Misses 40072 40071 -1 |
mruberry
approved these changes
Feb 1, 2021
Collaborator
mruberry
left a comment
There was a problem hiding this comment.
Sorry for the delay in review, @IvanYashchuk. Thanks for the fix!
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Contributor
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
…h#51109) Summary: For empty inputs `torch.svd` (and `torch.linalg.svd`) was returning incorrect results for `some=True` (`full_matrices=False`). Behaviour on master branch: ```python In [1]: import torch In [2]: a = torch.randn(0, 7) In [3]: a.svd() Out[3]: torch.return_types.svd( U=tensor([], size=(0, 0)), S=tensor([]), V=tensor([[0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.]])) In [4]: a.svd(some=False) Out[4]: torch.return_types.svd( U=tensor([], size=(0, 0)), S=tensor([]), V=tensor([[0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0., 0.]])) ``` `some` flag is ignored and 7x7 `V` matrix is returned in both cases. `V` should have 7x0 shape when `some=True`. This PR fixes that. Pull Request resolved: pytorch#51109 Reviewed By: ngimel Differential Revision: D26170897 Pulled By: mruberry fbshipit-source-id: 664c09ca27bb375fabef2a046d0a09ca57b01aac
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
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.
For empty inputs
torch.svd(andtorch.linalg.svd) was returning incorrect results forsome=True(full_matrices=False).Behaviour on master branch:
someflag is ignored and 7x7Vmatrix is returned in both cases.Vshould have 7x0 shape whensome=True.This PR fixes that.