Skip to content

Commit 4fe7a90

Browse files
committed
use the same mapping from opset to ir as in r1.5 branch
1 parent b39da4b commit 4fe7a90

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tests/test_optimizers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import numpy as np
1111
from onnx import helper, TensorProto, OperatorSetIdProto
12-
from tf2onnx import utils
12+
from tf2onnx import utils, constants
1313
from tf2onnx.graph import GraphUtil
1414
from backend_test_base import Tf2OnnxBackendTestBase
1515
from common import unittest_main, group_nodes_by_type, check_opset_min_version, check_opset_max_version
@@ -69,8 +69,11 @@ def _make_onnx_const(np_val, output_name):
6969
def make_model(self, graph, producer_name="onnx-tests"):
7070
imp = OperatorSetIdProto()
7171
imp.version = self.config.opset
72-
7372
model_proto = helper.make_model(graph, producer_name=producer_name, opset_imports=[imp])
73+
try:
74+
model_proto.ir_version = constants.OPSET_TO_IR_VERSION.get(self.config.opset, model_proto.ir_version)
75+
except: # pylint: disable=bare-except
76+
pass
7477
return model_proto
7578

7679
# Tranpose Optimizer Tests Start

tf2onnx/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
ENV_TF2ONNX_DEBUG_MODE = "TF2ONNX_DEBUG_MODE"
4040

4141
# Mapping opset to IR version.
42-
# When adding here, make sure that the IR changes don't impact that we do.
42+
# Note: opset 7 and opset 8 came out with IR3 but we need IR4 because of PlaceholderWithDefault
4343
OPSET_TO_IR_VERSION = {
44-
1: 3, 2: 3, 3: 3, 4: 4, 5: 3, 6: 3, 7: 3, 8: 4, 9: 4, 10: 5, 11: 6, 12: 7
44+
1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3, 7: 4, 8: 4, 9: 4, 10: 5, 11: 6, 12: 7
4545
}

0 commit comments

Comments
 (0)