Fix zero-dim handling in torch.matmul (#63359)
authorRichard Zou <zou3519@gmail.com>
Tue, 17 Aug 2021 20:39:52 +0000 (13:39 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 17 Aug 2021 20:44:47 +0000 (13:44 -0700)
commit495e7e4815d3f9a4000a6671022fd2608440db75
tree3e4a219e594b6b00e8f378ffe1de35a008630e64
parent1dc2b52764a81288cb0e31bb7a72fe8c4cc826a1
Fix zero-dim handling in torch.matmul (#63359)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63359

Fixes #63352. The problem was that in e.g. `torch.matmul(A, B)` with A,
B having shapes [3, 2, 0] and [0, 2], the code attempts to call
`A.view(-1, 0)` which fails due to "-1 being ambiguous". The solution is
to manually compute what we want the shape of the view to be.

Test Plan: - new tests

Reviewed By: ngimel

Differential Revision: D30351583

Pulled By: zou3519

fbshipit-source-id: 7625691fe8b85d96a4073409596a932c303e3e8c
aten/src/ATen/native/LinearAlgebra.cpp
torch/testing/_internal/common_methods_invocations.py