pytorch/c10
David Berard 82edc8b5d5 [NT] Make NestedTensor register as having symbolic sizes/strides (#124687)
Fixes #123698

This PR makes TensorImpl::has_symbolic_sizes_strides return false for NestedTensors.

1. It passes in the actual sizes when we call `_make_wrapper_subclass` - this is the change that makes the subclass register as `has_symbolic_sizes_strides() == True`
2. It adds a field to `_make_wrapper_subclass` where an explicit `numel` can be provided. This allows us to skip the numel computation for the storage, which previously fails due to arithmetic on NestedInts.
3. Implements `aten::numel` for NJT - this is separate from the overridden numel in `make_wrapper_subclass` for now. Note also that this means that we leave `dispatch_sizes_strides_policy="sizes"`, so that we call into the custom `numel` implementation (as well as `sizes` and `strides`), because `numel` cannot currently be computed from `sizes` for NJT.

Note also that this depends on #121361, because calling TensorImpl::set_sizes_and_strides() tries to clone the sizes into the tensor, which means that we need `clone` to be implemented on NestedInt.

Differential Revision: [D57225736](https://our.internmc.facebook.com/intern/diff/D57225736)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/124687
Approved by: https://github.com/albanD
2024-05-13 16:50:25 +00:00
..
benchmark increase clang-tidy coverage to more c10 source files (#102902) 2023-06-04 06:33:01 +00:00
core [NT] Make NestedTensor register as having symbolic sizes/strides (#124687) 2024-05-13 16:50:25 +00:00
cuda [ROCm] enforce ROCM_VERSION >= 6.0 (#125646) 2024-05-12 18:01:28 +00:00
hip [ROCm] remove HCC references (#111975) 2023-10-26 02:39:10 +00:00
macros [ROCm] enforce ROCM_VERSION >= 6.0 (#125646) 2024-05-12 18:01:28 +00:00
mobile Fix broken lint after #116876 (#122253) 2024-03-20 04:09:00 +00:00
test [ROCm] enforce ROCM_VERSION >= 6.0 (#125646) 2024-05-12 18:01:28 +00:00
util STRONG_CONSTEXPR -> constexpr (#125872) 2024-05-13 14:07:26 +00:00
xpu Support generic stream/event on CUDA/HIP backend (#125757) 2024-05-10 13:34:09 +00:00
BUCK.oss [1/4] Intel GPU Runtime Upstreaming for Device (#116019) 2024-01-12 07:36:25 +00:00
BUILD.bazel remove //c10:headers (#98420) 2023-04-05 19:33:10 +00:00
build.bzl Revert "Move at::{Refcounted,}MapAllocator to c10 (#109881)" 2023-10-13 17:57:53 +00:00
CMakeLists.txt Remove redundant CMake NUMA code (#119650) 2024-02-12 21:53:44 +00:00
ovrsource_defs.bzl [caffe2] Add build configuration for linux-arm64 (#124618) 2024-04-25 21:55:26 +00:00