Skip to content

Commit 22db2a9

Browse files
authored
Merge pull request #1855 from fatcat-z/fix_onnx_rc_issue
Add used opset into opset_imports argument to create an onnx model.
2 parents 872a96b + 9f8899c commit 22db2a9

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tf2onnx/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
# Default opset for custom ops
2222
TENSORFLOW_OPSET = helper.make_opsetid("ai.onnx.converters.tensorflow", 1)
2323

24+
# Built-in supported opset
25+
AI_ONNX_ML_OPSET = helper.make_opsetid(AI_ONNX_ML_DOMAIN, 2)
26+
2427
# Target for the generated onnx graph. It possible targets:
2528
# onnx-1.1 = onnx at v1.1 (winml in rs4 is based on this)
2629
# caffe2 = include some workarounds for caffe2 and winml

tf2onnx/graph.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import six
1212
import numpy as np
1313

14-
from onnx import helper, numpy_helper, shape_inference, OperatorSetIdProto, AttributeProto, TensorProto
14+
from onnx import helper, numpy_helper, shape_inference, AttributeProto, TensorProto
1515
from tf2onnx import utils, __version__
1616
from tf2onnx.utils import make_name, port_name, find_opset
1717
from tf2onnx import optimizer
@@ -1193,10 +1193,8 @@ def make_model(self, graph_doc, optimize=False, graph_name="tf2onnx", external_t
11931193
"producer_version": __version__}
11941194

11951195
if "opset_imports" not in kwargs:
1196-
opsets = []
1197-
imp = OperatorSetIdProto()
1198-
imp.version = self._opset
1199-
opsets.append(imp)
1196+
opsets = [helper.make_opsetid(constants.ONNX_DOMAIN, self._opset)]
1197+
opsets.append(constants.AI_ONNX_ML_OPSET)
12001198
if self.extra_opset is not None:
12011199
opsets.extend(self.extra_opset)
12021200
kwargs["opset_imports"] = opsets

0 commit comments

Comments
 (0)