Skip to content

Commit

Permalink
[Relay][ONNX] Fix the Resize operator in ONNX frontend (apache#16626)
Browse files Browse the repository at this point in the history
* Update onnx.py

* Update test_forward.py
  • Loading branch information
jikechao authored Feb 23, 2024
1 parent fc4abee commit aa55528
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relay/frontend/onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3932,7 +3932,7 @@ class Resize(OnnxOpConverter):

@classmethod
def _impl_v10(cls, inputs, attr, params):
mode = attr.get("mode").decode("ascii")
mode = attr.get("mode", b"nearest").decode("ascii")
if mode == "nearest":
method = "nearest_neighbor"
elif mode == "linear":
Expand Down Expand Up @@ -4007,7 +4007,7 @@ def v11_13_common(cls, inputs, size, attr, params):
if roi is not None and infer_shape(roi)[0] == 0:
roi = None
ndims = len(infer_shape(inputs[0]))
mode = attr.get("mode").decode("ascii")
mode = attr.get("mode", b"nearest").decode("ascii")
if mode == "nearest":
method = "nearest_neighbor"
elif mode == "linear":
Expand Down
1 change: 1 addition & 0 deletions tests/python/frontend/onnx/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -4503,6 +4503,7 @@ def verify(ishape, oshape, scales, mode, coord_trans="asymmetric", alpha=0.5, ex
# scales are specified instead of sizes
verify([1, 16] + [32] * ndim, [], [1, 1] + [0.5] * ndim, method, coord_trans)
verify([1, 16] + [32] * ndim, [], [1, 1] + [2] * ndim, method, coord_trans)
verify([1, 16] + [32] * ndim, [], [1, 1] + [2] * ndim, None, coord_trans)

method = "linear"
# upsampling
Expand Down

0 comments on commit aa55528

Please sign in to comment.