Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add used opset into opset_imports argument to create an onnx model. #1855

Merged
merged 2 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tf2onnx/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# Default opset for custom ops
TENSORFLOW_OPSET = helper.make_opsetid("ai.onnx.converters.tensorflow", 1)

# Built-in supported opset
AI_ONNX_ML_OPSET = helper.make_opsetid(AI_ONNX_ML_DOMAIN, 2)

# Target for the generated onnx graph. It possible targets:
# onnx-1.1 = onnx at v1.1 (winml in rs4 is based on this)
# caffe2 = include some workarounds for caffe2 and winml
Expand Down
6 changes: 2 additions & 4 deletions tf2onnx/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,10 +1193,8 @@ def make_model(self, graph_doc, optimize=False, graph_name="tf2onnx", external_t
"producer_version": __version__}

if "opset_imports" not in kwargs:
opsets = []
imp = OperatorSetIdProto()
imp.version = self._opset
opsets.append(imp)
opsets = [helper.make_opsetid(constants.ONNX_DOMAIN, self._opset)]
opsets.append(constants.AI_ONNX_ML_OPSET)
fatcat-z marked this conversation as resolved.
Show resolved Hide resolved
if self.extra_opset is not None:
opsets.extend(self.extra_opset)
kwargs["opset_imports"] = opsets
Expand Down