pytorch/test
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
..
ao/sparsity UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
autograd UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
backends/xeon UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
benchmark_utils UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
bottleneck_test UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
cpp [dynamo] support torchbind object input (#124978) 2024-05-07 03:02:00 +00:00
cpp_api_parity [BE]: Update ruff to 0.4.1 (#124549) 2024-04-21 14:06:23 +00:00
cpp_extensions Support generic stream/event on CUDA/HIP backend (#125757) 2024-05-10 13:34:09 +00:00
custom_backend Enable UFMT on test/cpp_api_parity, test/cpp_extensions, test/create_dummy_torchscript_model.py, test/custom_backend, test/custom_operator (#123518) 2024-04-08 20:18:42 +00:00
custom_operator Stop requiring a pystub for register_fake by default (#124064) 2024-04-17 23:51:20 +00:00
distributed [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
distributions [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
dynamo functionalize storage resizing, minimal ppFSDP traceable forward (#122434) 2024-05-10 18:09:10 +00:00
dynamo_expected_failures functionalize storage resizing, minimal ppFSDP traceable forward (#122434) 2024-05-10 18:09:10 +00:00
dynamo_skips functionalize storage resizing, minimal ppFSDP traceable forward (#122434) 2024-05-10 18:09:10 +00:00
edge
error_messages UFMT formatting on test/distributions, test/error_messages, test/forward_backward_compatability (#123527) 2024-04-09 16:03:46 +00:00
expect [optim] add fused_adagrad support for CPU device (#124905) 2024-05-13 01:16:20 +00:00
export Memoize local_scalar_dense calls, refactor all memos (#125623) 2024-05-11 21:12:35 +00:00
forward_backward_compatibility Remove deprecated _aminmax operator (#125995) 2024-05-12 17:50:17 +00:00
functorch Keep track of ViewMeta with symbolic inputs. (#125876) 2024-05-12 01:41:06 +00:00
fx [fx] Prioritize runtime assertions ops (#124213) 2024-05-07 21:31:10 +00:00
higher_order_ops [dynamo] support torchbind object input (#124978) 2024-05-07 03:02:00 +00:00
inductor [inductor][cpp] GEMM template (infra and fp32) (#124021) 2024-05-12 07:46:44 +00:00
jit Revert "Refresh OpOverloadPacket if a new OpOverload gets added (#124654)" 2024-04-26 08:56:03 +00:00
jit_hooks Enable UFMT on all of test/jit (#123623) 2024-04-11 23:45:05 +00:00
lazy [BE] enable ruff rule RSE and remove useless parentheses in raise statements (#124261) 2024-04-17 19:29:34 +00:00
mobile Remove deprecated _aminmax operator (#125995) 2024-05-12 17:50:17 +00:00
nn [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
onnx [RELAND] Switch default behavoir of export IR to be predispatch (#125860) 2024-05-10 17:36:53 +00:00
onnx_caffe2 Enable UFMT on test/onnx_caffe2, test/optim, test/package and test/profiler (#123901) 2024-04-15 17:46:59 +00:00
optim Add testing and fix issues for weights_only load for LRScheduler (#123775) 2024-04-16 20:29:27 +00:00
package Fix global flake8 issues (#124771) 2024-04-26 15:35:53 +00:00
profiler Revert "[profiler] enable CUPTI range profiler in build (#125685)" 2024-05-09 17:28:02 +00:00
quantization [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
scripts Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_img
torch_np [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
typing Fix: nn.Parameter return type identified as Tensor instead of nn.Parameter (#125106) 2024-04-29 23:25:23 +00:00
xpu [Aten] Fix XPU convolution_overrideable input memory format. (#124841) 2024-04-26 15:55:01 +00:00
_test_bazel.py UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
allowlist_for_publicAPI.json Remove deprecated _aminmax operator (#125995) 2024-05-12 17:50:17 +00:00
conftest.py UFMT formatting on test/autograd test/ao test/cpp test/backends (#123369) 2024-04-05 18:51:38 +00:00
create_dummy_torchscript_model.py Enable UFMT on test/cpp_api_parity, test/cpp_extensions, test/create_dummy_torchscript_model.py, test/custom_backend, test/custom_operator (#123518) 2024-04-08 20:18:42 +00:00
delete.py
hi.py Dont precompile already seen keys, limit epilogue choices (#122642) 2024-04-19 17:34:22 +00:00
HowToWriteTestsUsingFileCheck.md
linear.py Enable UFMT on test/jit_hooks, test/lazy and some files (#123807) 2024-04-12 03:39:38 +00:00
load_torchscript_model.py Enable UFMT on test/jit_hooks, test/lazy and some files (#123807) 2024-04-12 03:39:38 +00:00
minioptest_failures_dict.json
mkl_verbose.py Enable UFMT on test/jit_hooks, test/lazy and some files (#123807) 2024-04-12 03:39:38 +00:00
mkldnn_verbose.py Enable UFMT on test/jit_hooks, test/lazy and some files (#123807) 2024-04-12 03:39:38 +00:00
pytest_shard_custom.py
run_doctests.sh
run_test.py [ez] functorch/test_vmap and test_dataloader to run in parallel (#125597) 2024-05-08 15:37:29 +00:00
simulate_nccl_errors.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_ao_sparsity.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_autocast.py make torch.amp.autocast more generic (#125103) 2024-05-08 12:13:26 +00:00
test_autograd.py Fix cpp node instance check (#125875) 2024-05-11 21:31:12 +00:00
test_autograd_fallback.py
test_binary_ufuncs.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_bundled_images.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_bundled_inputs.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_ci_sanity_check_fail.py
test_comparison_utils.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_compile_benchmark_util.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_complex.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_content_store.py
test_cpp_api_parity.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_cpp_extensions_aot.py rename ort to maia (#123265) 2024-04-23 00:33:25 +00:00
test_cpp_extensions_jit.py Enable UFMT on test/scripts and some files (#124137) 2024-04-19 22:01:27 +00:00
test_cpp_extensions_mtia_backend.py [Inductor Intel GPU backend Upstream] Reuse inductor test for Intel GPU (PART 1) (#122866) 2024-05-09 00:51:35 +00:00
test_cpp_extensions_open_device_registration.py Fix & optimize open device registration test. (#125572) 2024-05-07 08:30:01 +00:00
test_cpp_extensions_stream_and_event.py Add test_cpp_extensions tests for stream_and_event and mita_backend (#123614) 2024-04-26 16:17:54 +00:00
test_cuda.py [optim] add fused_adagrad support for CPU device (#124905) 2024-05-13 01:16:20 +00:00
test_cuda_expandable_segments.py Enable UFMT on test/test_cuda*.py (#124352) 2024-04-25 18:31:08 +00:00
test_cuda_multigpu.py [CI] Relax per proc memory by a little bit, mark a test as serial (#125960) 2024-05-10 21:11:39 +00:00
test_cuda_nvml_based_avail.py Enable UFMT on test/test_cuda*.py (#124352) 2024-04-25 18:31:08 +00:00
test_cuda_primary_ctx.py Enable UFMT on test/test_cuda*.py (#124352) 2024-04-25 18:31:08 +00:00
test_cuda_sanitizer.py Enable UFMT on test/test_cuda*.py (#124352) 2024-04-25 18:31:08 +00:00
test_cuda_trace.py Enable UFMT on test/test_cuda*.py (#124352) 2024-04-25 18:31:08 +00:00
test_custom_ops.py functionalize storage resizing, minimal ppFSDP traceable forward (#122434) 2024-05-10 18:09:10 +00:00
test_dataloader.py Enable UFMT on test/test_dataloader.py (#124710) 2024-04-28 21:21:51 +00:00
test_datapipe.py
test_decomp.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_deploy.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_determination.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_dispatch.py Enable UFMT on test/test_dispatch (#123644) 2024-04-10 03:09:38 +00:00
test_dlpack.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_dynamic_shapes.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_expanded_weights.py Enable UFMT on test_decomp.py, test_expanded_weights.py and some files (#125117) 2024-05-07 02:36:40 +00:00
test_fake_tensor.py Add propagate_real_tensors mode for unbacked (#125115) 2024-05-02 15:28:26 +00:00
test_flop_counter.py Add "accurate" FlopCounter implementations for NestedTensor SDPA kernels (#125776) 2024-05-10 19:49:37 +00:00
test_foreach.py in test_foreach.py pacth KINETO_LOG_LEVEL to silence profiler log (#126048) 2024-05-13 15:31:56 +00:00
test_function_schema.py
test_functional_autograd_benchmark.py
test_functional_optim.py
test_functionalization.py Enable UFMT on test/test_functionalization.py (#123926) 2024-04-28 17:02:34 +00:00
test_functionalization_of_rng_ops.py
test_futures.py
test_fx.py Fix infinite recursion in API BC test (#125706) 2024-05-08 23:07:16 +00:00
test_fx_experimental.py
test_fx_passes.py remove empty partition (#124920) 2024-05-09 07:39:47 +00:00
test_fx_reinplace_pass.py
test_hub.py
test_import_stats.py
test_indexing.py Enable UFMT on test_indexing&test_view_ops (#125112) 2024-05-01 23:44:53 +00:00
test_itt.py
test_jit.py Fix global flake8 issues (#124771) 2024-04-26 15:35:53 +00:00
test_jit_autocast.py make torch.amp.autocast more generic (#125103) 2024-05-08 12:13:26 +00:00
test_jit_disabled.py
test_jit_fuser.py Fix global flake8 issues (#124771) 2024-04-26 15:35:53 +00:00
test_jit_fuser_legacy.py
test_jit_fuser_te.py
test_jit_legacy.py
test_jit_llga_fuser.py [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
test_jit_profiling.py
test_jit_simple.py
test_jit_string.py
test_jiterator.py
test_kernel_launch_checks.py
test_legacy_vmap.py Enable UFMT on test/test_legacy_vmap.py (#124381) 2024-04-20 03:37:57 +00:00
test_license.py Enable UFMT format on test/license.py test/logging.py (#125737) 2024-05-11 01:52:35 +00:00
test_linalg.py [ez] functorch/test_vmap and test_dataloader to run in parallel (#125597) 2024-05-08 15:37:29 +00:00
test_logging.py Enable UFMT format on test/license.py test/logging.py (#125737) 2024-05-11 01:52:35 +00:00
test_masked.py
test_maskedtensor.py [BE] enable ruff rule RSE and remove useless parentheses in raise statements (#124261) 2024-04-17 19:29:34 +00:00
test_matmul_cuda.py [ROCm] Fix ROCm bug that causes numerical errors in float8_experimental (#123275) 2024-04-10 21:52:02 +00:00
test_meta.py Add meta for _embedding_bag_dense_backward and _embedding_bag_per_sample_weights_backward (#125785) 2024-05-09 04:28:16 +00:00
test_metal.py
test_mkl_verbose.py
test_mkldnn.py
test_mkldnn_fusion.py
test_mkldnn_verbose.py
test_mobile_optimizer.py
test_model_dump.py
test_model_exports_to_core_aten.py
test_module_tracker.py More accurate is_bw and prompt parents cleanup for ModuleTracker utils (#125634) 2024-05-07 20:57:36 +00:00
test_modules.py
test_monitor.py
test_mps.py [EZ][BE] Use untyped_storage in tests (#125838) 2024-05-09 14:04:21 +00:00
test_multiprocessing.py skip various unit tests for Jetson (#122531) 2024-04-16 01:26:26 +00:00
test_multiprocessing_spawn.py
test_namedtensor.py
test_namedtuple_return_api.py
test_native_functions.py [BE]: TRY002 - Ban raising vanilla exceptions (#124570) 2024-04-21 22:26:40 +00:00
test_native_mha.py
test_nestedtensor.py [NT] Make NestedTensor register as having symbolic sizes/strides (#124687) 2024-05-13 16:50:25 +00:00
test_nn.py Fixed issue in affine_grid_backward when grad_grid is non-contiguous (#124370) 2024-04-18 16:30:10 +00:00
test_nnapi.py [BE]: TRY002 - Ban raising vanilla exceptions (#124570) 2024-04-21 22:26:40 +00:00
test_numba_integration.py
test_numpy_interop.py Support numpy array in Tensor.__eq__ (#122249) 2024-03-21 04:55:01 +00:00
test_openmp.py
test_ops.py [BE]: Update ruff to 0.4.1 (#124549) 2024-04-21 14:06:23 +00:00
test_ops_fwd_gradients.py Enable UFMT on test/test_ops* (#123935) 2024-04-13 03:31:56 +00:00
test_ops_gradients.py Enable UFMT on test/test_ops* (#123935) 2024-04-13 03:31:56 +00:00
test_ops_jit.py [BE]: TRY002 - Ban raising vanilla exceptions (#124570) 2024-04-21 22:26:40 +00:00
test_optim.py [optim] add fused_adagrad support for CPU device (#124905) 2024-05-13 01:16:20 +00:00
test_out_dtype_op.py
test_overrides.py Made FlexAttention rewrite getitem calls to use aten.index in score_mod (#124799) 2024-04-26 17:22:13 +00:00
test_package.py Enable UFMT format on test/test_package.py test/test_per_overload_api.py (#125834) 2024-05-09 19:48:22 +00:00
test_per_overload_api.py Enable UFMT format on test/test_package.py test/test_per_overload_api.py (#125834) 2024-05-09 19:48:22 +00:00
test_prims.py
test_proxy_tensor.py Add propagate_real_tensors mode for unbacked (#125115) 2024-05-02 15:28:26 +00:00
test_pruning_op.py
test_public_bindings.py Fix global flake8 issues (#124771) 2024-04-26 15:35:53 +00:00
test_python_dispatch.py [BE]: Update ruff to v0.4.4 (#125031) 2024-05-12 20:02:37 +00:00
test_pytree.py [pytree] Fix namedtuple serialization (#123388) 2024-04-08 20:55:19 +00:00
test_quantization.py
test_reductions.py Remove deprecated _aminmax operator (#125995) 2024-05-12 17:50:17 +00:00
test_scatter_gather_ops.py Revert "Include support for the scatter gather cuda kernels to allow for comp… (#124809)" 2024-05-02 21:36:18 +00:00
test_schema_check.py
test_segment_reductions.py
test_serialization.py Revert "Add write_record_metadata to PyTorchFileWriter (#125184)" 2024-05-05 22:40:00 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py Add a variable for some testcases. (#124708) 2024-05-01 23:19:12 +00:00
test_show_pickle.py
test_sort_and_select.py
test_sparse.py Fix sparse fake tensors detach (#125679) 2024-05-09 15:40:57 +00:00
test_sparse_csr.py [BE]: Update ruff to 0.4.1 (#124549) 2024-04-21 14:06:23 +00:00
test_sparse_semi_structured.py [sparse] Add fast semi-structured spasification kernels (#122350) 2024-04-19 13:31:58 +00:00
test_spectral_ops.py
test_stateless.py Graph break cleanly in Dynamo for module parametrization (#121041) 2024-03-26 23:44:51 +00:00
test_static_runtime.py
test_subclass.py
test_sympy_utils.py Generalise mod value ranges (#123253) 2024-04-06 20:19:24 +00:00
test_tensor_creation_ops.py [BE]: Update ruff to 0.4.1 (#124549) 2024-04-21 14:06:23 +00:00
test_tensorboard.py [CI] Removed tests for torch.utils.tensorboard.summary.hparams (#122556) 2024-03-29 21:44:02 +00:00
test_tensorexpr.py
test_tensorexpr_pybind.py
test_testing.py [BE]: Update ruff to 0.4.1 (#124549) 2024-04-21 14:06:23 +00:00
test_throughput_benchmark.py Enable UFMT format on test/test_throughput_benchmark.py test/test_type_hints.py test/test_type_info.py (#125906) 2024-05-11 04:32:01 +00:00
test_torch.py Forbid subclassing _TensorBase directly (#125558) 2024-05-08 20:29:29 +00:00
test_transformers.py Revert "Refactoring to remove unused variable (#125252)" 2024-05-02 01:49:57 +00:00
test_type_hints.py Enable UFMT format on test/test_throughput_benchmark.py test/test_type_hints.py test/test_type_info.py (#125906) 2024-05-11 04:32:01 +00:00
test_type_info.py Enable UFMT format on test/test_throughput_benchmark.py test/test_type_hints.py test/test_type_info.py (#125906) 2024-05-11 04:32:01 +00:00
test_type_promotion.py
test_typing.py
test_unary_ufuncs.py
test_utils.py [checkpoint] Improve error message when use_reentrant=True is used with .grad() (#125155) 2024-04-29 18:57:35 +00:00
test_view_ops.py Enable UFMT on test_indexing&test_view_ops (#125112) 2024-05-01 23:44:53 +00:00
test_vulkan.py
test_weak.py [BE] enable ruff rule RSE and remove useless parentheses in raise statements (#124261) 2024-04-17 19:29:34 +00:00
test_xnnpack_integration.py
test_xpu.py Support generic stream/event on XPU backend (#125751) 2024-05-10 01:27:30 +00:00