Skip to content

Commit 79aef14

Browse files
justinchubypytorchmergebot
authored andcommitted
[ONNX] Set the name of the producing node using the value name (pytorch#155413)
When comparing two graphs exported using different opset versions, even though the value names are the same in both graphs, the node names did not match, causing model-explorer to not be able to sync the two graphs. This change updates the names of the nodes that directly produce the output values, for better correspondence across exported graphs. ![image](https://github.com/user-attachments/assets/3c00ca18-221f-4add-8429-4bcf12069036) Pull Request resolved: pytorch#155413 Approved by: https://github.com/cyyever, https://github.com/xadupre
1 parent e158486 commit 79aef14

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

torch/onnx/_internal/exporter/_core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,17 @@ def _handle_call_function_node_with_lowering(
619619
node_name_to_values[node.name] = outputs
620620
for i, output in enumerate(outputs):
621621
output.name = f"{node.name}__{i}"
622+
# Set the name of the producing node using the value name for correspondence
623+
producer = output.producer()
624+
if producer is not None:
625+
producer.name = f"node_{output.name}"
622626
else:
623627
_set_shape_type(outputs, node.meta["val"], complex_to_float=True)
624628
node_name_to_values[node.name] = outputs
625629
outputs.name = node.name
630+
producer = outputs.producer()
631+
if producer is not None:
632+
producer.name = f"node_{outputs.name}"
626633

627634
for ir_node in onnx_nodes:
628635
ir_node.meta["node"] = node

0 commit comments

Comments
 (0)