Skip to content

torch.linalg.qr ignores zero batched dimensions #50576

@IvanYashchuk

Description

@IvanYashchuk

🐛 Bug

torch.linalg.qr does not work correctly when input is a batched tensor with some of the batch dimensions set to zero.

To Reproduce

In [1]: import torch
In [2]: shape = (1, 0, 2, 4, 5)
In [3]: A = torch.randn(shape)
In [4]: Q, R = torch.linalg.qr(A)
In [5]: Q.shape
Out[5]: torch.Size([4, 4])
In [6]: R.shape
Out[6]: torch.Size([4, 5])

Expected behavior

Q should have the shape (1, 0, 2, 4, 4) and R should have the shape (1, 0, 2, 4, 5) for the above example.

cc @jianyuh @nikitaved @pearu @mruberry @heitorschueroff @walterddr @IvanYashchuk @antocuni

Metadata

Metadata

Assignees

Labels

module: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions