Skip to content
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
11 changes: 11 additions & 0 deletions test/test_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,17 @@ def test_keypoint_rcnn(self):
dynamic_axes={"images_tensors": [0, 1, 2]},
tolerate_small_mismatch=True)

def test_shufflenet_v2_dynamic_axes(self):
model = models.shufflenet_v2_x0_5(pretrained=True)
dummy_input = torch.randn(1, 3, 224, 224, requires_grad=True)
test_inputs = torch.cat([dummy_input, dummy_input, dummy_input], 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason to concatenate dummy_input to test_inputs? Can I use test_inputs = torch.randn(3, 3, 224, 224, requires_grad=True)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fatcat-z any thoughts on this? Is it so that we can compare the output by passing dummy_input and test_inputs (as they are equal on both dimensions)?


self.run_model(model, [(dummy_input,), (test_inputs,)],
input_names=["input_images"],
output_names=["output"],
dynamic_axes={"input_images": {0: 'batch_size'}, "output": {0: 'batch_size'}},
tolerate_small_mismatch=True)


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion torchvision/models/shufflenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


def channel_shuffle(x: Tensor, groups: int) -> Tensor:
batchsize, num_channels, height, width = x.data.size()
batchsize, num_channels, height, width = x.size()
channels_per_group = num_channels // groups

# reshape
Expand Down