@@ -42,13 +42,15 @@ class OnnxGraph:
4242
4343 :param opset: main opset version
4444 :param opsets: other opsets as a dictionary
45+ :param ir_version: to specify an ir_version
4546 :param is_function: a :class:`onnx.ModelProto` or a :class:`onnx.FunctionProto`
4647 """
4748
4849 def __init__ (
4950 self ,
5051 opset : Optional [int ] = None ,
5152 opsets : Optional [Dict [str , int ]] = None ,
53+ ir_version : Optional [int ] = None ,
5254 proto_type : ProtoType = ProtoType .MODEL ,
5355 ):
5456 if opsets is not None and "" in opsets :
@@ -65,6 +67,7 @@ def __init__(
6567 self .proto_type = proto_type
6668 self .opsets = opsets
6769 self .opset = opset
70+ self .ir_version = ir_version
6871 self .nodes : List [Union [NodeProto , TensorProto ]] = []
6972 self .inputs : List [ValueInfoProto ] = []
7073 self .outputs : List [ValueInfoProto ] = []
@@ -402,6 +405,8 @@ def to_onnx(self) -> GRAPH_PROTO:
402405 # If no opsets, it a subgraph, not a model.
403406 return graph
404407 model = make_model (graph , opset_imports = opsets )
408+ if self .ir_version :
409+ model .ir_version = ir_version
405410 if not is_windows () or not is_azure ():
406411 # check_model fails sometimes on Windows
407412 check_model (model )
0 commit comments