Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Support UnSqueeze (#3960)
Browse files Browse the repository at this point in the history
  • Loading branch information
zheng-ningxin authored Jul 21, 2021
1 parent 442342c commit b65830e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nni/compression/pytorch/speedup/jit_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ def squeeze_python(node, speedup):
new_squeeze = partial(torch.squeeze, dim=dim)
return new_squeeze

def unsqueeze_python(node, speedup):
c_node = node.key_node
inputs = list(c_node.inputs())
dim = parse_constant(inputs[1], speedup)
new_unsqueeze = partial(torch.unsqueeze, dim=dim)
return new_unsqueeze

##########################################################
# Split Line
# Following module/functions cannot be translated into a
Expand Down Expand Up @@ -517,6 +524,7 @@ def forward(self, *args):
'aten::upsample_bilinear2d': upsample_bilinear2d_python,
'aten::exp': exp_python,
'aten::squeeze': squeeze_python,
'aten::unsqueeze': unsqueeze_python,
'prim::TupleUnpack': tupleunpack_python,
'prim::ListUnpack': tupleunpack_python,
'prim::NumToTensor': num2tensor_python,
Expand Down

0 comments on commit b65830e

Please sign in to comment.