Skip to content

Commit

Permalink
Make Autopad static when available (#7755)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Brookhart authored Mar 29, 2021
1 parent c39a6e2 commit 34deb80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def autopad(data, strides, kernel_shape, dilations, ndim, pad_type="constant", d
# pad N and C with zeros
pad = _op.concatenate([_op.const(np.zeros([2, 2], dtype="int64"), dtype="int64"), pad], axis=0)

return _op.nn.pad(data, pad, _op.const(0.0), pad_type)
return _op.nn.pad(data, fold_constant(pad), _op.const(0.0), pad_type)


class Conv(OnnxOpConverter):
Expand Down Expand Up @@ -809,7 +809,6 @@ def _impl_v11(cls, inputs, attr, params):

pad_width_expr = fold_constant(_op.transpose(_op.reshape(pads, (2, -1))))
pad_mode = attr.get("mode", b"constant").decode("utf-8")

if not pad_mode in ["constant", "edge", "reflect"]:
raise tvm.error.OpAttributeInvalid(
"Value " + pad_mode + ' in attribute "mode" is invalid for operator Pad.'
Expand Down
2 changes: 1 addition & 1 deletion tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2703,7 +2703,7 @@ def verify_pooling(x_shape, kernel_shape, strides, pads, out_shape, mode, auto_p
)

model = helper.make_model(graph, producer_name="pooling_test")
verify_with_ort(model, [x_shape], [out_shape], use_vm=True, convert_to_static=True)
verify_with_ort(model, [x_shape], [out_shape], use_vm=False, convert_to_static=True)


@tvm.testing.uses_gpu
Expand Down

0 comments on commit 34deb80

Please sign in to comment.