Skip to content

Commit

Permalink
Fix stride default value None in torch.nn.functional.avg_pool (apache…
Browse files Browse the repository at this point in the history
…#4984)

* fix unordered dictionary problem for python version 3.5

* modify style

* default value of stride in torch.nn.functional.avg_pool is None

* delete prev modifications

* add testcase for nn.functional.avg_pool2d
  • Loading branch information
pyjhzwh authored and zhiics committed Apr 17, 2020
1 parent 3333c96 commit 65dd237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ def _impl(inputs, input_types):
data = inputs[0]

pool_size = _infer_shape(inputs[1])
strides = _infer_shape(inputs[2])
if inputs[2]:
strides = _infer_shape(inputs[2])
else:
strides = pool_size
padding = _infer_shape(inputs[3])

ceil_mode = int(inputs[4])
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 @@ -375,8 +375,13 @@ class AvgPool2D1(Module):
def forward(self, *args):
return torch.nn.AvgPool2d(kernel_size=[10, 10])(args[0])

class AvgPool2D2(Module):
def forward(self, *args):
return torch.nn.functional.avg_pool2d(args[0], kernel_size=[10, 10])

input_data = torch.rand(input_shape).float()
verify_model(AvgPool2D1().float().eval(), input_data=input_data)
verify_model(AvgPool2D2().float().eval(), input_data=input_data)

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

0 comments on commit 65dd237

Please sign in to comment.