mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Summary: We add states in the constant folding process for AOTInductor. Basically, there's 3 states, which is (1) None: The state when no constants are loaded and uninitialized. (2) Initialized: The state when constants are loaded, but not yet folded. (3) Folded: The state where the model is fully ready with folded constants. Note that even if constant folding is not enabled, we still only run when state is FOLDED, this is okay because without constant folding, the transition from INITIALIZED to FOLDED is just a pass-throught. Test Plan: python test/inductor/test_aot_inductor.py -k test_constant_folding_with_update Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D73002538](https://our.internmc.facebook.com/intern/diff/D73002538) Pull Request resolved: https://github.com/pytorch/pytorch/pull/151273 Approved by: https://github.com/jingsh, https://github.com/desertfire