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

Fix bug that renamed subgraph i/o twice #1478

Merged
merged 3 commits into from
Apr 27, 2021
Merged
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
15 changes: 7 additions & 8 deletions tf2onnx/tfonnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,6 @@ def rename_tensors_in_nodes(onnx_nodes):
for func in ordered_func:
f_inputs_names = [t.name for t in func.inputs]
f_output_names = [t.name for t in func.outputs]
f_inputs_names = rename_tensors_in_list(f_inputs_names)
f_output_names = rename_tensors_in_list(f_output_names)
fg = process_tf_graph(func, continue_on_error, False, target, opset,
custom_op_handlers, custom_rewriter,
extra_opset, shape_override, inputs_as_nchw,
Expand All @@ -524,12 +522,13 @@ def rename_tensors_in_nodes(onnx_nodes):

check_io(input_names, output_names, output_shapes)

rename_tensors_in_nodes(onnx_nodes)
input_names = rename_tensors_in_list(input_names)
output_names = rename_tensors_in_list(output_names)
output_shapes = rename_tensors_in_dict(output_shapes)
dtypes = rename_tensors_in_dict(dtypes)
inputs_as_nchw = rename_tensors_in_list(inputs_as_nchw)
if not is_subgraph:
rename_tensors_in_nodes(onnx_nodes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually don't need to rename tensors in subgraphs at all.

input_names = rename_tensors_in_list(input_names)
output_names = rename_tensors_in_list(output_names)
output_shapes = rename_tensors_in_dict(output_shapes)
dtypes = rename_tensors_in_dict(dtypes)
inputs_as_nchw = rename_tensors_in_list(inputs_as_nchw)
g = Graph(onnx_nodes, output_shapes, dtypes, target, opset, extra_opset, input_names, output_names, is_subgraph)
g = process_parsed_graph(g, custom_op_handlers, inputs_as_nchw, continue_on_error, custom_rewriter, target,
output_names, initialized_tables, outputs_to_values, outputs_to_dtypes, op_cnt, attr_cnt)
Expand Down