Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fontend][Pytorch] Fix translation of transpose when axis argument is as a list #5451

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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