mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Remove code for Python < 3.9 (#147097)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/147097 Approved by: https://github.com/albanD
This commit is contained in:
@ -233,24 +233,11 @@ def stacksize_analysis(instructions) -> Union[int, float]:
|
||||
|
||||
for inst, next_inst in zip(instructions, instructions[1:] + [None]):
|
||||
stack_size = stack_sizes[inst]
|
||||
# CALL_FINALLY in Python 3.8 is handled differently when determining stack depth.
|
||||
# See https://github.com/python/cpython/blob/3.8/Python/compile.c#L5450.
|
||||
# Essentially, the stack effect of CALL_FINALLY is computed with jump=True,
|
||||
# but the resulting stack depth is propagated to the next instruction, not the
|
||||
# jump target.
|
||||
is_call_finally = (
|
||||
sys.version_info < (3, 9) and inst.opcode == dis.opmap["CALL_FINALLY"]
|
||||
)
|
||||
if inst.opcode not in TERMINAL_OPCODES:
|
||||
assert next_inst is not None, f"missing next inst: {inst}"
|
||||
# total stack effect of CALL_FINALLY and END_FINALLY in 3.8 is 0
|
||||
eff = (
|
||||
0
|
||||
if is_call_finally
|
||||
else stack_effect(inst.opcode, inst.arg, jump=False)
|
||||
)
|
||||
eff = stack_effect(inst.opcode, inst.arg, jump=False)
|
||||
stack_sizes[next_inst].offset_of(stack_size, eff)
|
||||
if inst.opcode in JUMP_OPCODES and not is_call_finally:
|
||||
if inst.opcode in JUMP_OPCODES:
|
||||
stack_sizes[inst.target].offset_of(
|
||||
stack_size, stack_effect(inst.opcode, inst.arg, jump=True)
|
||||
)
|
||||
|
Reference in New Issue
Block a user