You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ec...@apache.org on 2023/09/04 07:26:06 UTC

[tvm] branch main updated: [Relay] Fix an adaptive_max_pool1d operator conversion bug (#15386)

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 d75083cd97 [Relay] Fix an adaptive_max_pool1d operator conversion bug (#15386)
d75083cd97 is described below

commit d75083cd97ede706338ab413dbc964009456d01b
Author: Haoyang <ha...@gmail.com>
AuthorDate: Mon Sep 4 15:26:00 2023 +0800

    [Relay] Fix an adaptive_max_pool1d operator conversion bug (#15386)
    
    * Fix an adaptive_max_pool1d operator conversion bug
    
    * Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * add tests for Fix an adaptive_max_pool1d operator conversion bug
    
    * Fix an adaptive_max_pool1d operator conversion bug
    
    * Fix an adaptive_max_pool1d operator conversion bug
    
    * Add a TODO
    
    * Add a TODO
    
    * Add a TODO
---
 python/tvm/relay/frontend/pytorch.py          | 10 +++++++++-
 tests/python/frontend/pytorch/test_forward.py | 10 ++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/python/tvm/relay/frontend/pytorch.py b/python/tvm/relay/frontend/pytorch.py
index 42765d2fb0..683b94dd92 100644
--- a/python/tvm/relay/frontend/pytorch.py
+++ b/python/tvm/relay/frontend/pytorch.py
@@ -4291,7 +4291,15 @@ class PyTorchOpConverter:
 
             self.current_op.pop()
 
-        return [_wrap_const(outputs[ret_name]) for ret_name in ret_names]
+        # TODO(@haoyang9804): outputs[ret_name] could be None and cause some issue
+        # revealed by https://github.com/apache/tvm/issues/15004
+        # Now only adaptive_max_pool1d is considered. Maybe other ops could also
+        # trigger this problem.
+        return [
+            _wrap_const(outputs[ret_name])
+            for ret_name in ret_names
+            if ret_name != "aten::adaptive_max_pool1d_0_1"
+        ]
 
     def _set_parameter_source_name(self, op_node, outputs):
         """A helper function to rewrite source_name of parameter."""
diff --git a/tests/python/frontend/pytorch/test_forward.py b/tests/python/frontend/pytorch/test_forward.py
index cb49e837fe..8c1cdbb0cf 100644
--- a/tests/python/frontend/pytorch/test_forward.py
+++ b/tests/python/frontend/pytorch/test_forward.py
@@ -3439,6 +3439,16 @@ def test_forward_full():
     verify_model(Full2().float().eval(), input_data=[])
 
 
+@tvm.testing.uses_gpu
+def test_forward_adaptive_max_pool1d():
+    """test_forward_adaptive_max_pool1d"""
+    torch.set_grad_enabled(False)
+    input_data = [torch.randn([2, 2, 4], dtype=torch.float32)]
+    m = torch.nn.AdaptiveMaxPool1d(3)
+
+    verify_model(m.float().eval(), input_data=input_data)
+
+
 @tvm.testing.uses_gpu
 def test_forward_full_like():
     """test_forward_full_like"""