Nanmur opened a new issue, #20398:
URL: https://github.com/apache/tvm/issues/20398

   ### Summary
   
   A PP-OCRv6-derived ONNX graph contains a 2-D `MaxPool` whose spatial width 
is symbolic and whose attributes are:
   
   ```text
   kernel_shape = [2, 2]
   strides      = [1, 1]
   auto_pad     = SAME_UPPER
   ```
   
   `relax.frontend.onnx.from_onnx` fails before producing a Relax module 
because the MaxPool importer converts every input shape dimension to a Python 
`int`. This is invalid when a dimension is a symbolic TIR `Var`.
   
   The failure is reproducible with the minimal public graph below; no model 
file is required.
   
   ### Expected behavior
   
   The Relax ONNX frontend should import this valid ONNX MaxPool with symbolic 
spatial dimensions, without materializing symbolic dimensions as Python 
integers.
   
   ### Actual behavior
   
   ```text
   Error converting operator MaxPool, with inputs: [x]
   ...
   File "python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3996, in 
_get_input_spatial_shape
       return _np.array([int(d) for d in tensor.ty.shape], dtype="int64")[2:]
   TypeError: int() argument must be a string, a bytes-like object or a real 
number, not 'Var'
   ```
   
   ### Minimal reproduction
   
   ```python
   import onnx
   from onnx import TensorProto, helper
   from tvm.relax.frontend.onnx import from_onnx
   
   x = helper.make_tensor_value_info("x", TensorProto.FLOAT, ["N", 3, 48, "W"])
   y = helper.make_tensor_value_info("y", TensorProto.FLOAT, ["N", 3, 48, "W"])
   node = helper.make_node(
       "MaxPool",
       ["x"],
       ["y"],
       kernel_shape=[2, 2],
       strides=[1, 1],
       auto_pad="SAME_UPPER",
   )
   graph = helper.make_graph([node], "dynamic_same_maxpool", [x], [y])
   model = helper.make_model(graph, 
opset_imports=[helper.make_operatorsetid("", 11)])
   
   from_onnx(model)
   ```
   
   ### Environment
   
   ```text
   TVM: v0.26.0 (c7b458e946bc4266915da582457476bdcd9705ae)
   ONNX: 1.22.0
   OS: Windows
   Frontend: tvm.relax.frontend.onnx.from_onnx
   ```
   
   ### Related issues
   
   - This is distinct from #15895, which was an earlier MaxPool default-strides 
issue.
   - #19965 also covers PP-OCRv6 import limitations, but its reported failures 
are Squeeze/shape-graph/TopK related rather than this symbolic MaxPool padding 
path.
   
   ### Triage
   
   - needs-triage
   - type: bug


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to