Skip to content

[dynamo, nested graph breaks] use CALL_FUNCTION_EX when calling resume function #159281

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

Open
wants to merge 13 commits into
base: gh/williamwen42/266/base
Choose a base branch
from
Open
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
22 changes: 14 additions & 8 deletions torch/_dynamo/symbolic_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
create_dup_top,
create_instruction,
create_jump_absolute,
create_reverse,
create_swap,
get_code_keys,
Instruction,
Expand Down Expand Up @@ -2518,7 +2517,6 @@ def create_call_resume_at(self, inst, push, all_stack_locals_metadata):
stack_len = len(self.stack) - len(
all_stack_locals_metadata[-1].stack_null_idxes
)
nargs = stack_len + len(argnames)

new_code: types.CodeType = ContinueExecutionCache.lookup(
self.f_code,
Expand Down Expand Up @@ -2608,16 +2606,24 @@ def create_call_resume_at(self, inst, push, all_stack_locals_metadata):
[
create_instruction("POP_TOP"),
create_instruction("BUILD_LIST", arg=len(argnames)),
*create_swap(3),
# live_locals, frames[-1][0], frames
create_instruction("BUILD_LIST", arg=1),
*create_swap(2),
# live_locals, [frames], frames[-1][0]
create_instruction("LIST_EXTEND", arg=1),
*create_swap(2),
create_instruction("LIST_EXTEND", arg=1),
# UNPACK_SEQUENCE reverses elements
create_instruction("UNPACK_SEQUENCE", arg=nargs),
*create_reverse(nargs),
]
)
# frames, *(stack + live locals)
# [frames, *(stack + live locals)]

cg.extend_output(create_call_function(nargs + 1, False))
cg.append_output(create_instruction("RETURN_VALUE"))
cg.extend_output(
[
create_instruction("CALL_FUNCTION_EX", arg=0),
create_instruction("RETURN_VALUE"),
]
)
return cg.get_instructions()

def should_compile_partial_graph(self):
Expand Down
Loading