This is an automated email from the ASF dual-hosted git repository.

echuraev pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new aa55528714 [Relay][ONNX] Fix the Resize operator in ONNX frontend 
(#16626)
aa55528714 is described below

commit aa5552871415409d2696bc5864535c910ee12018
Author: Qingchao Shen <[email protected]>
AuthorDate: Fri Feb 23 15:54:04 2024 +0800

    [Relay][ONNX] Fix the Resize operator in ONNX frontend (#16626)
    
    * Update onnx.py
    
    * Update test_forward.py
---
 python/tvm/relay/frontend/onnx.py          | 4 ++--
 tests/python/frontend/onnx/test_forward.py | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/python/tvm/relay/frontend/onnx.py 
b/python/tvm/relay/frontend/onnx.py
index ddd0d34c5c..3023cd039c 100644
--- a/python/tvm/relay/frontend/onnx.py
+++ b/python/tvm/relay/frontend/onnx.py
@@ -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":
@@ -4007,7 +4007,7 @@ class Resize(OnnxOpConverter):
         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":
diff --git a/tests/python/frontend/onnx/test_forward.py 
b/tests/python/frontend/onnx/test_forward.py
index 51748462d0..cfa30ad346 100644
--- a/tests/python/frontend/onnx/test_forward.py
+++ b/tests/python/frontend/onnx/test_forward.py
@@ -4503,6 +4503,7 @@ def test_resize(target, dev):
             # 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

Reply via email to