Expected behavior
The Relax ONNX frontend should import a valid ONNX Reshape whose shape input is a runtime INT64 tensor, or report that feature as unsupported.
Actual behavior
The script constructs a valid ONNX model. onnx.checker.check_model and ONNX Runtime session construction succeed. from_onnx fails while converting Reshape:
Error converting operator Reshape, with inputs: [data, shape]
Traceback (most recent call last):
...
File ".../src/relax/op/tensor/manipulate.cc", line 1014, in InferTypeReshape
TVM_FFI_VISIT_THROW(TypeError, call)
TypeError: Reshape requires the input new shape to be Shape. However, the given one is relax.TensorType
Environment
- OS: macOS 15.6 (Darwin 24.6.0, arm64)
- Python: 3.12.2
- TVM: c7b458e (tag v0.26.0; package reports 0.26.dev0)
- ONNX: 1.17.0
- ONNX Runtime: 1.21.1
- Frontend:
tvm.relax.frontend.onnx.from_onnx
Steps to reproduce
The following self-contained script constructs the model:
#!/usr/bin/env python3
"""Reproduce the Relax ONNX runtime-shape Reshape import failure."""
import onnx
import onnxruntime as ort
from onnx import TensorProto, helper
from tvm.relax.frontend.onnx import from_onnx
def main() -> None:
data = helper.make_tensor_value_info("data", TensorProto.FLOAT, [2, 3])
shape = helper.make_tensor_value_info("shape", TensorProto.INT64, [2])
out = helper.make_tensor_value_info("out", TensorProto.FLOAT, [3, 2])
graph = helper.make_graph(
[helper.make_node("Reshape", ["data", "shape"], ["out"])],
"reshape_runtime_shape",
[data, shape],
[out],
)
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 18)])
onnx.checker.check_model(model)
ort.InferenceSession(model.SerializeToString(), providers=["CPUExecutionProvider"])
from_onnx(model, opset=18, keep_params_in_input=True)
if __name__ == "__main__":
main()
Analysis
The runtime Reshape shape input is represented as relax.TensorType, while Relax reshape expects a Shape argument. The failure occurs during ONNX import.
Triage
Expected behavior
The Relax ONNX frontend should import a valid ONNX Reshape whose shape input is a runtime INT64 tensor, or report that feature as unsupported.
Actual behavior
The script constructs a valid ONNX model.
onnx.checker.check_modeland ONNX Runtime session construction succeed.from_onnxfails while convertingReshape:Environment
tvm.relax.frontend.onnx.from_onnxSteps to reproduce
The following self-contained script constructs the model:
Analysis
The runtime
Reshapeshape input is represented asrelax.TensorType, while Relaxreshapeexpects aShapeargument. The failure occurs during ONNX import.Triage