@@ -415,6 +415,8 @@ def execute_commands(cmds):
415
415
def extend_model_output (model , intermediate_outputs ):
416
416
# Run shape inference to make sure we have valid tensor value infos for all
417
417
# intermediate tensors available
418
+ import onnx
419
+
418
420
model = onnx .shape_inference .infer_shapes (model )
419
421
value_infos = {vi .name : vi for vi in model .graph .value_info }
420
422
graph_inputs = {vi .name : vi for vi in model .graph .input }
@@ -454,6 +456,7 @@ def read_input_from_refs(num_inputs, load_ref_filename, is_load_ref):
454
456
inputs = []
455
457
456
458
if is_load_ref :
459
+ import onnx
457
460
from onnx import numpy_helper
458
461
459
462
for i in range (num_inputs ):
@@ -488,6 +491,7 @@ def read_output_from_refs(num_outputs, load_ref_filename, is_load_ref):
488
491
reference_output = []
489
492
490
493
if is_load_ref :
494
+ import onnx
491
495
from onnx import numpy_helper
492
496
493
497
for i in range (num_outputs ):
@@ -875,13 +879,14 @@ def __init__(self, session_wrapper, model_file=None, **kwargs):
875
879
else :
876
880
# Compile the ONNX model.
877
881
# Prepare input and output paths.
878
- import onnx
879
882
880
883
if args .model .endswith (".onnx" ):
881
884
if args .verify and args .verify == "onnxruntime" and args .verify_all_ops :
882
885
input_model_path = os .path .join (
883
886
self .model_dir , f"{ self .default_model_name } .onnx"
884
887
)
888
+ import onnx
889
+
885
890
onnx .save (model , input_model_path )
886
891
else :
887
892
input_model_path = args .model
0 commit comments