Skip to content

Commit

Permalink
[Pytorch] fix translation of transpose when axis argument is as a list (
Browse files Browse the repository at this point in the history
  • Loading branch information
n-nez authored Apr 27, 2020
1 parent 639358e commit 16d0d56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ def _impl(inputs, input_types):
axes[src] = dst
axes[dst] = src
else:
axes = inputs[1]
axes = _infer_shape(inputs[1], prelude.mod)
return _op.transform.transpose(data, axes)
return _impl

Expand Down
5 changes: 5 additions & 0 deletions tests/python/frontend/pytorch/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,14 @@ class Transpose2(Module):
def forward(self, *args):
return args[0].transpose(-2, -1)

class Transpose3(Module):
def forward(self, *args):
return args[0].permute(0,2,3,1)

input_data = torch.rand(input_shape).float()
verify_model(Transpose1().float().eval(), input_data=input_data)
verify_model(Transpose2().float().eval(), input_data=input_data)
verify_model(Transpose3().float().eval(), input_data=input_data)

def test_forward_size():
torch.set_grad_enabled(False)
Expand Down

0 comments on commit 16d0d56

Please sign in to comment.