coffezhou opened a new issue, #18133: URL: https://github.com/apache/tvm/issues/18133
### Expected behavior TVM should run the model correctly. ### Actual behavior For the following model, <img width="190" height="409" alt="Image" src="https://github.com/user-attachments/assets/0f9c1bf0-2104-4b0a-9534-222e7d628c0d" /> it can be executed by onnxruntime, the results are as follows: ```c ONNXRuntime: [array([[[[0.6251511 , 0.6180997 , 0.6039968 , 0.4824833 , 0.25355908, 0.17335546, 0.2418724 , 0.27613088], [0.47064707, 0.46871254, 0.46484345, 0.37809238, 0.20845926, 0.15066189, 0.20470022, 0.23171937], [0.16163902, 0.16993824, 0.18653667, 0.16931047, 0.11825964, 0.10527475, 0.13035582, 0.14289635], [0.34176996, 0.3465182 , 0.3560147 , 0.42180583, 0.5438916 , 0.47625098, 0.21888396, 0.09020043], [1.0110399 , 0.9984524 , 0.9732775 , 1.1355784 , 1.4853553 , 1.2635906 , 0.4702846 , 0.0736316 ], [1.4519522 , 1.4102529 , 1.3268545 , 1.4443552 , 1.7627555 , 1.5264107 , 0.7353209 , 0.3397761 ], [1.6645073 , 1.5819199 , 1.4167454 , 1.3481362 , 1.3760922 , 1.2647111 , 1.013993 , 0.88863397], [1.7707846 , 1.6677535 , 1.4616909 , 1.3000267 , 1.1827606 , 1.1338614 , 1.153329 , 1.1630629 ]], [[1.2571493 , 0.9908935 , 0.4583817 , 0.2656508 , 0.41270074, 0.7101021 , 1.1578549 , 1.3817313 ], [0.99612385, 0.79088306, 0.3804013 , 0.23428433, 0.35253203, 0.6584027 , 1.1518965 , 1.3986433 ], [0.47407275, 0.390862 , 0.22444047, 0.17155136, 0.23219463, 0.555004 , 1.1399796 , 1.4324675 ], [0.25609106, 0.2502444 , 0.23855111, 0.2727924 , 0.35296828, 0.5743203 , 0.9368483 , 1.1181124 ], [0.34217882, 0.36903027, 0.4227332 , 0.53800744, 0.714853 , 0.7163514 , 0.5425026 , 0.4555782 ], [0.76455665, 0.7480468 , 0.7150272 , 0.7738706 , 0.9245769 , 0.8096743 , 0.4291628 , 0.23890704], [1.5232246 , 1.387294 , 1.1154332 , 0.98038185, 0.98213995, 0.85428894, 0.5968289 , 0.46809882], [1.9025584 , 1.7069178 , 1.3156362 , 1.0836375 , 1.0109215 , 0.8765963 , 0.6806619 , 0.5826947 ]]]], dtype=float32)] ``` However, the onnx frontend of TVM cannot import it: ```c File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3925, in from_onnx return g.from_onnx(graph, opset) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3556, in from_onnx self._construct_nodes(graph) File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3736, in _construct_nodes raise err File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3731, in _construct_nodes op = self._convert_operator(op_name, inputs, attr, self.opset) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 3831, in _convert_operator sym = op_function(self.bb, inputs, attrs, [self._nodes, self._params]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/carla/Documents/tvm/python/tvm/relax/frontend/onnx/onnx_frontend.py", line 2147, in _impl_v18 return relax.op.image.resize2d( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/carla/Documents/tvm/python/tvm/relax/op/image/image.py", line 116, in resize2d return _ffi_api.resize2d( # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "tvm/ffi/cython/./function.pxi", line 228, in tvm.ffi.core.Function.__call__ TypeError: Mismatched type on argument #2 when calling: `relax.op.image.resize2d(0: ir.RelaxExpr, 1: ir.RelaxExpr, 2: Array<ir.FloatImm>, 3: ffi.String, 4: ffi.String, 5: ffi.String, 6: ffi.String, 7: float, 8: int, 9: float, 10: Optional<DataType>) -> ir.RelaxExpr`. Expected `Array<ir.FloatImm>` but got `relax.expr.Call` ``` ### Environment OS: Ubuntu 20.04 TVM: 0.22.dev0 (c6969d723) onnxruntime: 1.21.0 ### Steps to reproduce This bug can be reproduced by the following code with the model in the attachment. As shown in the code, the model can be executed by onnxruntime. However, TVM cannot import this model. ```python import sys import numpy as np import onnx import onnxruntime import tvm from tvm import relax from tvm.relax.frontend.onnx import from_onnx import pickle def main(): onnx_model = onnx.load("111.onnx") with open("inputs.pkl", "rb") as fp: inputs = pickle.load(fp) try: ort_session = onnxruntime.InferenceSession( onnx_model.SerializeToString(), providers=["CPUExecutionProvider"] ) ort_output = ort_session.run([], inputs) except Exception as e: print(e) sys.exit(1) print("ONNXRuntime:\n", ort_output) # Convert the onnx model into relax through the onnx importer. tvm_model = from_onnx(onnx_model, keep_params_in_input=True) if __name__ == "__main__": main() ``` ### Triage Please refer to the list of label tags [here](https://github.com/apache/tvm/wiki/Issue-Triage-Labels) to find the relevant tags and add them below in a bullet format (example below). * needs-triage -- 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]
