pytorch/torchgen
Brian Hirsh f22b303f65 Add TorchDispatch version of functionalization (#106404)
This PR adds a new `FunctionalTensor` subclass, and `FunctionalTensorMode` torch dispatch mode. Together, this class/mode are a lightweight wrapper around our existing C++ functionalization logic.

This idea came from Ed - later in the stack, I want to be able to run functionalization **underneath** torch_dispatch, when performing tracing in AOTAutograd. I can't do this easily with vanilla C++ functionalization, because it has a dedicated dispatch key that always runs before TorchDispatch. However, by adding a torch_dispatch mode shim around functionalization, we can use functionalization as a torch_dispatch mode, which will make it easier to run underneath other modes later.

This PR provides the basic new classes, and some light testing.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/106404
Approved by: https://github.com/ezyang
2023-09-15 20:19:25 +00:00
..
api [BE] use DeviceIndex instead of int64_t for related device interfaces (#103068) 2023-08-25 20:16:14 +00:00
decompositions
dest Remove ExclusivelyOwned from register_dispatch_key (#106791) 2023-08-11 21:04:33 +00:00
executorch [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
operator_versions [BE]: Update Ruff to 0.0.280 (#105724) 2023-07-22 23:03:34 +00:00
selective_build [BE] f-stringify torch/ and scripts (#105538) 2023-07-21 19:35:24 +00:00
shape_functions
static_runtime
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
context.py
gen.py [BE]: Enable ruff rules PIE807 and PIE810 (#106218) 2023-07-28 22:35:56 +00:00
gen_backend_stubs.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
gen_executorch.py [executorch] Let custom ops registration code only import ATen headers (#107064) 2023-08-13 00:34:34 +00:00
gen_functionalization_type.py
gen_lazy_tensor.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
gen_vmap_plumbing.py
local.py
model.py Add TorchDispatch version of functionalization (#106404) 2023-09-15 20:19:25 +00:00
native_function_generation.py [export] Refactor constrain_as_value and constrain_as_size (#106591) 2023-08-15 05:41:43 +00:00
utils.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
yaml_utils.py