pytorch
5e09ec65 - Fixed SVD ignoring "some/full_matrices" flag for empty inputs (#51109)

Commit
4 years ago
Fixed SVD ignoring "some/full_matrices" flag for empty inputs (#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: https://github.com/pytorch/pytorch/pull/51109 Reviewed By: ngimel Differential Revision: D26170897 Pulled By: mruberry fbshipit-source-id: 664c09ca27bb375fabef2a046d0a09ca57b01aac
Author
Parents
Loading