Revert "[dynamo, nested graph breaks] clean up comments and codegen (#160138)"

This reverts commit ac6316caaa74513cbcf3c7f9269bc23cd74749db.

Reverted https://github.com/pytorch/pytorch/pull/160138 on behalf of https://github.com/atalman due to failing internal tests ([comment](https://github.com/pytorch/pytorch/pull/160138#issuecomment-3225546707))
This commit is contained in:
PyTorch MergeBot
2025-08-26 20:01:25 +00:00
parent 46576f5a16
commit caf98fde0d
5 changed files with 222 additions and 247 deletions

View File

@ -508,43 +508,6 @@ def create_binary_slice(
]
def create_copy(i: int) -> list[Instruction]:
if sys.version_info >= (3, 11):
return [create_instruction("COPY", arg=i)]
# COPY 4
# 0 1 2 3
# 3 1 2 0
# 3 1 2 0 0
# 0 1 2 0 3
# 0 1 2 3 0
return [
*create_swap(i),
create_dup_top(),
*create_swap(i + 1),
*create_swap(2),
]
# mainly for debugging generated bytecode
def create_print_on_stack(depth: int) -> list[Instruction]:
return [
*add_push_null(create_instruction("LOAD_CONST", argval=print)),
*create_copy(depth + (2 if sys.version_info >= (3, 11) else 1)),
*create_call_function(1, False),
create_instruction("POP_TOP"),
]
# mainly for debugging generated bytecode
def create_print_value(value: Any) -> list[Instruction]:
return [
*add_push_null(create_instruction("LOAD_CONST", argval=print)),
create_instruction("LOAD_CONST", argval=value),
*create_call_function(1, False),
create_instruction("POP_TOP"),
]
def lnotab_writer(
lineno: int, byteno: int = 0
) -> tuple[list[int], Callable[[int, int], None]]: