[3.12, 3.13, dynamo] simplified construction for frame f_locals/localsplus (#129185)

Construct frame localsplus in 3.12+ using our own simplified way rather than copypasting from CPython.

This is necessary for 3.13 since we can no longer generate frame `f_locals` before executing the interpreter frame.
We also enable this for 3.12 since the `f_locals` construction between 3.12 and 3.13 is the same, so we can test for correctness with 3.12.

This is also one of the first steps to completing https://github.com/pytorch/pytorch/issues/93753 - we will implement simplified f_locals generation of previous Python versions in the future.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129185
Approved by: https://github.com/jansel
This commit is contained in:
William Wen
2024-07-11 13:44:28 -07:00
committed by PyTorch MergeBot
parent b0a597fcb4
commit c3e77d144e
20 changed files with 189 additions and 245 deletions

View File

@ -828,6 +828,7 @@ libtorch_python_core_sources = [
"torch/csrc/dynamo/cpython_defs.c",
"torch/csrc/dynamo/eval_frame.c",
"torch/csrc/dynamo/extra_state.cpp",
"torch/csrc/dynamo/framelocals_mapping.cpp",
"torch/csrc/dynamo/guards.cpp",
"torch/csrc/dynamo/init.cpp",
"torch/csrc/functorch/init.cpp",