From 679ccdd702b25057cc1a05b847257bf238774ed2 Mon Sep 17 00:00:00 2001 From: AndrewZhaoLuo Date: Mon, 17 Oct 2022 12:57:25 -0700 Subject: [PATCH] [ONNX] Handle multiple imports (#13065) * onnx get right import * fixins --- python/tvm/relay/frontend/onnx.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/python/tvm/relay/frontend/onnx.py b/python/tvm/relay/frontend/onnx.py index 84a5fc3b8237..8c4c056221f6 100644 --- a/python/tvm/relay/frontend/onnx.py +++ b/python/tvm/relay/frontend/onnx.py @@ -5906,7 +5906,16 @@ def from_onnx( graph = model.graph try: - opset_in_model = model.opset_import[0].version if model.opset_import else 1 + opset_in_model = 1 + if model.opset_import: + # TODO: for now we only really support ai.onnx op set + # TODO: handle other namespaces well see https://github.com/apache/tvm/issues/10950 + for opset_identifier in model.opset_import: + # As per https://github.com/onnx/onnx/blob/main/docs/IR.md + # All operator sets except the default one must specify the operator version + if str(opset_identifier.domain) in ["ai.onnx", ""]: + opset_in_model = opset_identifier.version + break except AttributeError: opset_in_model = 1