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

Deepcopy output node metadata #95426

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions torch/fx/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,9 @@ def __deepcopy__(self, memo=None) -> 'Graph':
output_vals = g.graph_copy(self, val_map=memo, return_output_node=True)
g._codegen = copy.deepcopy(self._codegen)
assert isinstance(output_vals, tuple)
output_val, old_output_val = output_vals
g.output(output_val, type_expr=getattr(old_output_val, 'type', None))
output_val, old_output_node = output_vals
new_output_node = g.output(output_val, type_expr=getattr(old_output_node, 'type', None))
new_output_node.meta = copy.copy(old_output_node.meta)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be done inside graph_copy.
see line 780

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that might break BC because the way graph_copy is implemented, it isn't meant to copy over the output node.

return g

@compatibility(is_backward_compatible=True)
Expand Down