Skip to content

Commit

Permalink
Adding aten::unsqueeze_ to PT Frontend (apache#7231)
Browse files Browse the repository at this point in the history
* Added Ops

* Regular

* Remove copy

* Remove copy

* Tests

* Black

Co-authored-by: Ubuntu <ubuntu@ip-172-31-27-149.us-east-2.compute.internal>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-19-34.us-east-2.compute.internal>
  • Loading branch information
3 people authored and Tushar Dey committed Jan 20, 2021
1 parent 316a132 commit 0a97177
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,7 @@ def create_convert_map(self):
"aten::to": self.to,
"aten::squeeze": self.squeeze,
"aten::unsqueeze": self.unsqueeze,
"aten::unsqueeze_": self.unsqueeze,
"aten::cat": self.concatenate,
"aten::slice": self.slice,
"aten::split": self.split,
Expand Down
8 changes: 8 additions & 0 deletions tests/python/frontend/pytorch/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,16 @@ class Unsqueeze1(Module):
def forward(self, *args):
return args[0].unsqueeze(2)

class Unsqueeze2(Module):
def forward(self, *args):
_ = args[0].unsqueeze_(2)
# Check whether operations after inplace unsqueeze works as expected
y = args[0].squeeze(2)
return torch.add(y, y)

input_data = torch.rand(input_shape).float()
verify_model(Unsqueeze1().float().eval(), input_data=input_data)
verify_model(Unsqueeze2().float().eval(), input_data=input_data)


@tvm.testing.uses_gpu
Expand Down

0 comments on commit 0a97177

Please sign in to comment.