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

Refactored _remove_auto_functionalization_from_graph_helper #125180

Closed
wants to merge 3 commits 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
8 changes: 3 additions & 5 deletions torch/export/_remove_auto_functionalized_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ def _remove_auto_functionalization_from_graph_helper(ep, auto_functionalize_node
)

# If the result of getitem was used in an output node, update the output spec with the correct name
adusted_index = user.args[1] - len(func._schema.returns)
original_arg = original_kwargs[mutable_args_names[adusted_index]]
adjusted_index = user.args[1] - len(func._schema.returns)
original_arg = original_kwargs[mutable_args_names[adjusted_index]]

# This is a little fragile/implementation dependent, but the order of the mutable args is the same as the order
# of the getitem calls following the HOP.
user.replace_all_uses_with(
original_kwargs[mutable_args_names[adusted_index]]
)
user.replace_all_uses_with(original_arg)

if len(func._schema.returns) == 1:
# If the function has 1 return then it will just directly return the
Expand Down