@@ -230,11 +230,15 @@ def has_duplicates(seq):
230
230
## 1. ONNX load
231
231
tmp_onnx_graphs = []
232
232
custom_domain_check_onnx_nodes = []
233
+ max_ir_version : int = 0
233
234
if len (onnx_graphs ) > 0 :
234
235
for onnx_graph in onnx_graphs :
236
+ domain : str = onnx_graph .domain
237
+ ir_version : int = onnx_graph .ir_version
238
+ max_ir_version = ir_version if max_ir_version < ir_version else max_ir_version
235
239
gs_graph = gs .import_onnx (onnx_graph )
236
240
gs_graph .cleanup ().toposort ()
237
- tmp_onnx_graphs .append (gs .export_onnx (gs_graph ))
241
+ tmp_onnx_graphs .append (gs .export_onnx (gs_graph , do_type_check = False , ** { 'domain' : domain , 'ir_version' : ir_version } ))
238
242
custom_domain_check_onnx_nodes = \
239
243
custom_domain_check_onnx_nodes + \
240
244
[
@@ -243,9 +247,13 @@ def has_duplicates(seq):
243
247
]
244
248
else :
245
249
for onnx_path in input_onnx_file_paths :
246
- gs_graph = gs .import_onnx (onnx .load (onnx_path ))
250
+ onnx_graph = onnx .load (onnx_path )
251
+ domain : str = onnx_graph .domain
252
+ ir_version : int = onnx_graph .ir_version
253
+ max_ir_version = ir_version if max_ir_version < ir_version else max_ir_version
254
+ gs_graph = gs .import_onnx (onnx_graph )
247
255
gs_graph .cleanup ().toposort ()
248
- tmp_onnx_graphs .append (gs .export_onnx (gs_graph ))
256
+ tmp_onnx_graphs .append (gs .export_onnx (gs_graph , do_type_check = False , ** { 'domain' : domain , 'ir_version' : ir_version } ))
249
257
custom_domain_check_onnx_graph = onnx .load (onnx_path )
250
258
custom_domain_check_onnx_nodes = \
251
259
custom_domain_check_onnx_nodes + \
@@ -436,7 +444,7 @@ def has_duplicates(seq):
436
444
437
445
# Cleaning
438
446
src_gs_model .cleanup ().toposort ()
439
- combined_model = gs .export_onnx (src_gs_model )
447
+ combined_model = gs .export_onnx (src_gs_model , do_type_check = False , ** { 'ir_version' : max_ir_version } )
440
448
441
449
## Output of onnx files in the process of fusion
442
450
if output_of_onnx_file_in_the_process_of_fusion and output_onnx_file_path :
@@ -484,7 +492,7 @@ def has_duplicates(seq):
484
492
replaced_output_names .append (tmp_replaced_output_name )
485
493
486
494
gs_combined_model .cleanup ().toposort ()
487
- combined_model = gs .export_onnx (gs_combined_model )
495
+ combined_model = gs .export_onnx (gs_combined_model , do_type_check = False , ** { 'ir_version' : max_ir_version } )
488
496
489
497
## 4. Optimize
490
498
try :
0 commit comments