Skip to content

Commit d5bb838

Browse files
committed
set ir based on opset
1 parent 4f5bfd7 commit d5bb838

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

tf2onnx/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@
3737

3838
# Environment variables
3939
ENV_TF2ONNX_DEBUG_MODE = "TF2ONNX_DEBUG_MODE"
40+
41+
# Mapping opset to IR version.
42+
# When adding here, make sure that the IR changes don't impact that we do.
43+
OPSET_TO_IR_VERSION = {
44+
1: 3, 2:3, 3: 3, 4: 4, 5: 3, 6:3, 7:3, 8:3, 9:4, 10:5, 11:6, 12:7
45+
}

tf2onnx/graph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,9 @@ def make_model(self, graph_doc, optimize=False, graph_name="tf2onnx", **kwargs):
10391039
kwargs["opset_imports"] = opsets
10401040
model_proto = helper.make_model(graph, **kwargs)
10411041

1042+
# set the IR version based on opset
1043+
model_proto.ir_version = constants.OPSET_TO_IR_VERSION.get(self.opset, model_proto.ir_version)
1044+
10421045
# optimize the model proto.
10431046
# TODO: this is disabled by default because of bugs in fuse_consecutive_transposes
10441047
if optimize:

0 commit comments

Comments
 (0)