pytorch/torch/csrc/utils
Edward Z. Yang fca03eeec1 Make proxy tensor support item() calls on torch.tensor constants (#81192)
This PR is doing a few interrelated things, all of which are necessary to get correctness. Read the comment in torch/fx/experimental/proxy_tensor.py for the high level overview.

Let's break down the parts of this PR:

* Bug fix where `enable_torch_dispatch_mode` with `None` doesn't work. This make `enable_torch_dispatch_mode(current_mode.inner)` work which is the basis for how we temporarily disable fake tensor mode.
* Bug fix for when fake tensor mode is combined with a non-mode tensor subclass. This actually could be ablated from this PR but it affects where the logic for allowing non fake tensor inputs with lift goes, so it's all in here in one go. There are some relevant tests for the fix in fake tensor, but it turns out I didn't need this because I'm always using proxy tensors as a mode (which ensures the ordering is right.)
* New `lift_fresh` view operator.  Note that like lift, we have to manually write the functionalize kernel for these functions.
* The actual change, which is to save constants when we see them in the proxy tensor mode, and then propagate them as we go (because otherwise you'll handle mutations on constants incorrectly--see test.)

This is mildly BC-breaking if anyone was previously interposing on
at::lift, but this operator was relatively new and I checked
functorch which has no explicit reference to lift.  So I think it
should not be too disruptive.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81192
Approved by: https://github.com/samdow, https://github.com/bdhirsh
2022-07-15 03:53:40 +00:00
..
auto_gil.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
byte_order.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
byte_order.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
cpp_stacktraces.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
cpp_stacktraces.h [JIT] pass more exception info through the JIT interpreter 2022-04-21 18:26:49 +00:00
cuda_enabled.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
cuda_lazy_init.cpp Fix set_requires_cuda_init (#81183) 2022-07-11 15:36:42 +00:00
cuda_lazy_init.h Improve readability of cuda_lazy_init (#80788) 2022-07-04 16:47:11 +00:00
disable_torch_function.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
disable_torch_function.h Disable functorch modes in testing's freeze_rng_state() (#81006) 2022-07-08 03:28:49 +00:00
disallow_copy.h
init.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
init.h Remove breakpad dependency 2022-05-03 20:21:55 +00:00
invalid_arguments.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
invalid_arguments.h
memory.h
numpy_stub.h
object_ptr.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
object_ptr.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
out_types.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
out_types.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
pybind.h [Profiler] Expose extra fields to Python 2022-06-19 15:41:27 +00:00
pycfunction_helpers.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_arg_parser.cpp Only allow numbers as tensors if operator was explicitly allowlisted so (#80587) 2022-06-30 18:59:38 +00:00
python_arg_parser.h add layout to slow path (#80429) 2022-07-06 18:01:31 +00:00
python_compat.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_dispatch.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_dispatch.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_numbers.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_scalars.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_strings.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_stub.h
python_torch_function_mode.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
python_tuples.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
schema_info.cpp [JIT] Add side effects checks for ops in SchemaInfo subclass (#81002) 2022-07-13 00:39:30 +00:00
schema_info.h [JIT] Add side effects checks for ops in SchemaInfo subclass (#81002) 2022-07-13 00:39:30 +00:00
six.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
structseq.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
structseq.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_apply.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_apply.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_dtypes.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_dtypes.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_flatten.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_flatten.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_layouts.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_layouts.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_list.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_list.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_memoryformats.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_memoryformats.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_new.cpp Make proxy tensor support item() calls on torch.tensor constants (#81192) 2022-07-15 03:53:40 +00:00
tensor_new.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_numpy.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_numpy.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_qschemes.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_qschemes.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_types.cpp simple c10 implementation for std::call_once (#78051) 2022-06-28 15:47:03 +00:00
tensor_types.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
throughput_benchmark-inl.h canonicalize includes of form <aten/src/ATen/...> 2022-06-16 17:46:45 +00:00
throughput_benchmark.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
throughput_benchmark.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
torch_dispatch_mode.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
variadic.cpp
variadic.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00