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

   For the below onnx model with LpPool, we can see that `strides = 3,3` in 
LpPool. However, tvm frontend cannot parse this attribute, and throw an error: 
`KeyError: 'strides'`. By analysis, the crash is caused by the [node.attribute] 
https://github.com/apache/tvm/blob/main/python/tvm/relay/frontend/onnx.py#:~:text=attr%20%3D%20self._parse_attr(node.attribute)
 cannot get the `strides` attribute and lead to a crash when execute 
`attr["strides"]` in this 
[line](https://github.com/apache/tvm/blob/main/python/tvm/relay/frontend/onnx.py#:~:text=data%2C-,attr%5B%22strides%22%5D%2C,-attr%5B%22kernel_shape).
   
   ### model structure
   
![image](https://user-images.githubusercontent.com/29506758/232844355-1d425875-59a7-4570-849f-584b8110a955.png)
   
   ### Crash message
   ```
   Traceback (most recent call last):
     File "test.py", line 7, in <module>
       irmod, params = relay.frontend.from_onnx(model, {'x': (1, 3, 32, 32)}, 
freeze_params=True)
     File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/onnx.py", line 
7347, in from_onnx
       mod, params = g.from_onnx(graph, opset)
     File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/onnx.py", line 
6964, in from_onnx
       self._construct_nodes(graph)
     File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/onnx.py", line 
7079, in _construct_nodes
       op = self._convert_operator(op_name, inputs, attr, self.opset)
     File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/onnx.py", line 
7205, in _convert_operator
       sym = convert_map[op_name](inputs, attrs, self._params)
     File "/workplace/software/tvm/tvm/python/tvm/relay/frontend/onnx.py", line 
1999, in _impl_v1
       attr["strides"],
   KeyError: 'strides'
   ```
   
   ### Steps to reproduce
   1. download the 
[lppool_model.onnx](https://github.com/jikechao/onnx_models/blob/main/lppool_model.onnx)
   2. execute the script.
   ```
   import onnx
   from tvm import relay
   
   onnx_model_path = "lppool_model.onnx"
   model = onnx.load(onnx_model_path)
   irmod, params = relay.frontend.from_onnx(model, {'x': (1, 3, 32, 32)}, 
freeze_params=True)
   ```
   
   ### Triage
   * frontend:onnx
   
   Although I can understand and locate the bug, I cannot fix it. Wish someone 
can fix it.


-- 
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]

Reply via email to