3636import qonnx .analysis .topology as ta
3737import qonnx .core .execute_custom_node as ex_cu_node
3838from qonnx .custom_op .registry import is_custom_op
39- from qonnx .util .basic import (
40- get_preferred_onnx_opset ,
41- get_sanitize_quant_tensors ,
42- qonnx_make_model ,
43- sanitize_quant_values ,
44- )
39+ from qonnx .util .basic import get_preferred_qonnx_opset , get_sanitize_quant_tensors , qonnx_make_model , sanitize_quant_values
4540
4641
47- def execute_node (node , context , graph , return_full_exec_context = False , opset_version = get_preferred_onnx_opset () ):
42+ def execute_node (node , context , graph , opset_version , return_full_exec_context = False ):
4843 """Executes a single node by using onnxruntime or with a custom function.
4944
5045 Input/output provided via context."""
@@ -158,7 +153,7 @@ def execute_onnx(model, input_dict, return_full_exec_context=False, start_node=N
158153 model_exec_mode = model .get_metadata_prop ("exec_mode" )
159154 if (model_exec_mode is None ) or (model_exec_mode == "" ):
160155 # extract opset version for node-by-node execution
161- opset_version = model .model . opset_import [ 0 ]. version
156+ opset_imports = model .get_opset_imports ()
162157 # execute the model node by node
163158 # we can simply walk down the list since the ONNX spec guarantees that it is
164159 # topologically sorted
@@ -176,7 +171,11 @@ def execute_onnx(model, input_dict, return_full_exec_context=False, start_node=N
176171 if get_sanitize_quant_tensors () != 0 :
177172 # round input values to match quantization annotation
178173 execution_context = sanitize_quant_values (model , node .input , execution_context )
179- execute_node (node , execution_context , graph , return_full_exec_context , opset_version )
174+ if node .domain in opset_imports :
175+ opset_version = opset_imports [node .domain ]
176+ else :
177+ opset_version = get_preferred_qonnx_opset ()
178+ execute_node (node , execution_context , graph , opset_version , return_full_exec_context )
180179 if get_sanitize_quant_tensors () != 0 :
181180 # round output values to quantization annotation
182181 execution_context = sanitize_quant_values (model , node .output , execution_context )
0 commit comments