Skip to content

Fix output node in rewrite random normal #2023

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
16 changes: 11 additions & 5 deletions tf2onnx/rewriter/random_normal_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@ def rewrite_random_normal(g, ops):
match_results = list(matcher.match_ops(ops))
for match in match_results:
output = match.get_op('output')
if output.type == 'Add':
input2 = match.get_op('input2')
is_output = False
for output_name in g.outputs:
# input2 and output can not be output node.
if input2.name in output_name or output.name in output_name:
is_output = True
break
if is_output:
continue
if output.type == 'Add' and input2.type == 'Mul':
# pattern 1
mean = output.inputs[1].get_tensor_value()
scale = input2.inputs[1].get_tensor_value()
else:
# pattern 2
mean = 0.0
input2 = match.get_op('input2')
if input2.type == 'Mul':
scale = input2.inputs[1].get_tensor_value()
else:
scale = 1.0
dtype = g.get_dtype(output.output[0])
op_name = utils.make_name("RandomNormal")
Expand Down