Skip to content

Commit 56670ab

Browse files
committed
revert change to custom_op_via_python.py, fix custom_op_handler issue
1 parent 4bc7752 commit 56670ab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/custom_op_via_python.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import tensorflow as tf
55
import tf2onnx
66
from onnx import helper
7-
from tf2onnx import constants
7+
8+
_TENSORFLOW_DOMAIN = "ai.onnx.converters.tensorflow"
89

910

1011
def print_handler(ctx, node, name, args):
@@ -13,7 +14,7 @@ def print_handler(ctx, node, name, args):
1314
# becomes:
1415
# T output = Identity(T Input)
1516
node.type = "Identity"
16-
node.domain = constants.DEFAULT_CUSTOM_OP_OPSET.domain
17+
node.domain = _TENSORFLOW_DOMAIN
1718
del node.input[1:]
1819
return node
1920

@@ -24,8 +25,8 @@ def print_handler(ctx, node, name, args):
2425
x_ = tf.Print(x, [x], "hello")
2526
_ = tf.identity(x_, name="output")
2627
onnx_graph = tf2onnx.tfonnx.process_tf_graph(sess.graph,
27-
custom_op_handlers={"Print": print_handler},
28-
extra_opset=[constants.DEFAULT_CUSTOM_OP_OPSET],
28+
custom_op_handlers={"Print": (print_handler, [])},
29+
extra_opset=[helper.make_opsetid(_TENSORFLOW_DOMAIN, 1)],
2930
input_names=["input:0"],
3031
output_names=["output:0"])
3132
model_proto = onnx_graph.make_model("test")

0 commit comments

Comments
 (0)