Skip to content

Commit

Permalink
add a test for assymetric padding in ONNX conv and fix importer (apac…
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Brookhart authored and trevor-m committed Oct 19, 2020
1 parent 6739553 commit 14ec2e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 0 additions & 11 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,6 @@ def _impl_v1(cls, inputs, attr, params):
msg = 'Value {} in attribute "auto_pad" of operator Conv is invalid.'
raise tvm.error.OpAttributeInvalid(msg.format(attr["auto_pad"]))
attr.pop("auto_pad")
elif len(attr["kernel_shape"]) == 2:
sym_pad = True
if "pads" in attr:
padding = attr["pads"]
else:
padding = [0, 0, 0, 0]
for i in range(0, len(padding), 2):
sym_pad = sym_pad and padding[i] == padding[i + 1]

if sym_pad:
attr["pads"] = padding[0::2]

out = AttrCvt(
op_name=dimension_picker("conv"),
Expand Down
10 changes: 10 additions & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,16 @@ def repeat(N, D):
repeat(1, D),
repeat(1, D),
)
# Convolution with assymetric padding
verify_conv(
(1, 1) + repeat(5, D),
(1, 1) + repeat(3, D),
(1, 1) + repeat(4, D),
repeat(0, D) + repeat(1, D),
repeat(3, D),
repeat(1, D),
repeat(1, D),
)
# Convolution without padding
verify_conv(
(1, 1) + repeat(5, D),
Expand Down

0 comments on commit 14ec2e1

Please sign in to comment.