pytorch/torch/_dynamo/variables
Edward Z. Yang dc70b00d0b Track and record hint on SymNode and use when possible (#94201)
Historically, we work out `size_hint` by working it out on the fly by doing a substitution on the sympy expression with the `var_to_val` mapping. With this change, we also maintain the hint directly on SymNode (in `expr._hint`) and use it in lieu of Sympy substitution when it is available (mostly guards on SymInt, etc; in particular, in idiomatic Inductor code, we typically manipulate Sympy expressions directly and so do not have a way to conveniently maintain hints.)

While it's possible this will give us modest performance improvements, this is not the point of this PR; the goal is to make it easier to carefully handle unbacked SymInts, where hints are expected not to be available. You can now easily test if a SymInt is backed or not by checking `symint.node.hint is None`.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94201
Approved by: https://github.com/voznesenskym
2023-02-09 00:00:44 +00:00
..
__init__.py Rename DynamicShapeVariable to SymNodeVariable cause thats what it is (#94152) 2023-02-08 10:41:10 +00:00
base.py Tiny unimplemented improvements (#94150) 2023-02-08 02:57:29 +00:00
builder.py Track and record hint on SymNode and use when possible (#94201) 2023-02-09 00:00:44 +00:00
builtin.py Rename DynamicShapeVariable to SymNodeVariable cause thats what it is (#94152) 2023-02-08 10:41:10 +00:00
constant.py Rename DynamicShapeVariable to SymNodeVariable cause thats what it is (#94152) 2023-02-08 10:41:10 +00:00
dicts.py [Dynamo] Support context wrapping(e.g, torch.no_grad) on nested functions w/o closure (#92922) 2023-01-26 04:23:35 +00:00
functions.py Check for none for NNModuleVariable.__module__ (#93326) 2023-02-02 09:41:41 +00:00
lists.py Rename DynamicShapeVariable to SymNodeVariable cause thats what it is (#94152) 2023-02-08 10:41:10 +00:00
misc.py Tiny unimplemented improvements (#94150) 2023-02-08 02:57:29 +00:00
nn_module.py [Dynamo] Fix bug if module calls module with static forward function (#93299) 2023-01-31 06:16:33 +00:00
tensor.py Track and record hint on SymNode and use when possible (#94201) 2023-02-09 00:00:44 +00:00
torch.py Rename DynamicShapeVariable to SymNodeVariable cause thats what it is (#94152) 2023-02-08 10:41:10 +00:00
user_defined.py [Dynamo] UserDefinedClassVariable supports python type (#93310) 2023-01-31 17:41:51 +00:00