pytorch/test
YifanShenSZ 673b35c847 Better reshape with autograd support (#82754) (#84154)
The original author is @YifanShenSZ  and the original PR is: #82754
# Summary:
Previous reshape [https://github.com/pytorch/pytorch/issues/80981](https://github.com/pytorch/pytorch/pull/80981) is ok for forward, but needs improvement for backward: need to handle "sometimes view sometimes copy" behavior.

This pull request fixes it by:
1. add a new alias dispatch key `CompositeImplicitAutogradNestedTensor`, which ideally would work as nested-tensor version of `CompositeImplicitAutograd`
2. register `reshape_nested` to `reshape` by `CompositeImplicitAutogradNestedTensor`

Side changes:
* add contiguous memory format support to `clone_nested`
* add `view_nested`
* add `reshape_as_nested`

Fix issue [https://github.com/pytorch/pytorch/issues/83041](https://github.com/pytorch/pytorch/issues/83041)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/82754

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: executorch**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39023822/V13/executorch/)|

|**Modified Pages**|

Reviewed By: albanD

Differential Revision: D39023822

Pulled By: drisspg

Pull Request resolved: https://github.com/pytorch/pytorch/pull/84154
Approved by: https://github.com/bdhirsh, https://github.com/albanD
2022-09-01 20:01:39 +00:00
..
ao/sparsity [quant][ao_migration] torch.nn.qattorch.ao.nn.qat (#78716) 2022-08-25 16:50:38 +00:00
autograd
backends/xeon A Launch script with Best Recipe of Deep Learning on Intel Xeon CPU (#63932) 2022-07-29 12:57:22 +00:00
benchmark_utils
bottleneck_test
cpp Back out "Revert D38984222: Don't introduce new overload for SymInt (#83628)" (#84173) 2022-08-29 18:01:07 +00:00
cpp_api_parity
cpp_extensions Back out "Revert D38984222: Don't introduce new overload for SymInt (#83628)" (#84173) 2022-08-29 18:01:07 +00:00
custom_backend
custom_operator
distributed [FSDP] Fix the FQN not found issue for load sharded_state_dict when using activation checkpoint (#84253) 2022-08-31 23:05:46 +00:00
distributions remove assertEqualIgnoreTypes from test/distributions/test_distributions.py (#83709) 2022-08-23 19:19:38 +00:00
error_messages
expect Fix dumb make_fx issue (#84011) 2022-08-25 06:52:01 +00:00
forward_backward_compatibility Better reshape with autograd support (#82754) (#84154) 2022-09-01 20:01:39 +00:00
fx example program for paper intro (#83945) 2022-08-25 21:28:30 +00:00
jit Update Dynamo pin (#83829) 2022-08-26 20:49:43 +00:00
jit_hooks
lazy
mobile [quant][ao_migration] torch.nn.quantized.modulestorch.ao.nn.quantized.modules (#78713) 2022-08-25 16:50:33 +00:00
nn Update start_index and end_index for adaptive pooling (#84010) 2022-08-29 22:53:40 +00:00
onnx [ONNX] Support nn.init.normal (#84149) 2022-09-01 18:29:41 +00:00
package
quantization [Pytorch][Ondevice quantization] Add device side API to convert model (#83807) 2022-08-29 17:57:38 +00:00
scripts
test_img
typing
allowlist_for_publicAPI.json [quant][ao_migration] torch.nn.qattorch.ao.nn.qat (#78716) 2022-08-25 16:50:38 +00:00
conftest.py
create_dummy_torchscript_model.py
defs.bzl
delete.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py
mkl_verbose.py
mkldnn_verbose.py
profiler_utils_mock_events.json
run_doctests.sh Integrate xdoctest - Rebased (#82797) 2022-08-12 02:08:01 +00:00
run_test.py Test distributed backends in parallel (#84034) 2022-09-01 03:48:54 +00:00
simulate_nccl_errors.py
test_ao_sparsity.py [ao][sparsity] Data Sparsity with Post Training Quantization (#82759) 2022-08-10 16:51:35 +00:00
test_autocast.py
test_autograd.py Fix use-dict-literal lint (#83718) 2022-08-24 00:26:46 +00:00
test_binary_ufuncs.py Fix and improve the efficiency of the backward of xlog* functions. (#82713) 2022-08-18 21:55:42 +00:00
test_bundled_images.py
test_bundled_inputs.py
test_complex.py
test_cpp_api_parity.py Make M1 tests green (#82213) 2022-08-05 16:12:08 +00:00
test_cpp_extensions_aot.py
test_cpp_extensions_jit.py Make M1 tests green (#82213) 2022-08-05 16:12:08 +00:00
test_cpp_extensions_open_device_registration.py Make M1 tests green (#82213) 2022-08-05 16:12:08 +00:00
test_cuda.py [ROCm] Fixes the kernel asserts API declaration mismatch error (#81790) 2022-08-16 19:22:31 +00:00
test_cuda_primary_ctx.py
test_cuda_trace.py CUDA trace Python hooks (#82824) 2022-08-11 10:21:40 +00:00
test_dataloader.py [DataPipe] Reset Shuffler's iterator when NotStarted (#83535) 2022-08-25 19:45:41 +00:00
test_datapipe.py [DataPipe] Fixing map function signature validation (#84279) 2022-08-31 19:55:01 +00:00
test_decomp.py Test Dynamo CI w Fake Tensors (#84282) 2022-09-01 00:15:05 +00:00
test_deploy.py
test_determination.py
test_dispatch.py Fix and unskip cpp extension tests for ARM (#83115) 2022-08-11 20:01:53 +00:00
test_dlpack.py Normalize DLPack stride to 1 where shape < 2 (#83158) 2022-08-23 15:03:29 +00:00
test_dynamic_shapes.py Started storing faketensor/symbolic shape metadata on FX nodes in make_fx (#84114) 2022-08-31 04:39:48 +00:00
test_expanded_weights.py [Expanded Weights] add 'same' and 'valid' padding support (#83345) 2022-08-16 22:39:08 +00:00
test_fake_tensor.py Use reentrant mode when invoking prims, delete global prim_fake_mode (#84090) 2022-08-31 01:58:44 +00:00
test_foreach.py Test Dynamo CI w Fake Tensors (#84282) 2022-09-01 00:15:05 +00:00
test_function_schema.py [frontend] Fix tensor list alias annotation (#84005) 2022-08-24 19:50:19 +00:00
test_functional_autograd_benchmark.py
test_functional_optim.py
test_functionalization.py Refactored proxytensor to clean up separate branches (#84325) 2022-08-31 09:37:55 +00:00
test_futures.py
test_fx.py Change the input of mvit_v2_s on the FX test (#83242) 2022-08-11 15:27:38 +00:00
test_fx_backends.py [ROCm] enable nvfuser (#82498) 2022-08-30 21:50:39 +00:00
test_fx_experimental.py
test_fx_passes.py Back out "Support regex-style matching for Any and Oneof (#82853)" (#83922) 2022-08-24 00:17:46 +00:00
test_fx_reinplace_pass.py Refactored proxytensor to clean up separate branches (#84325) 2022-08-31 09:37:55 +00:00
test_hub.py
test_import_stats.py
test_indexing.py Test Dynamo CI w Fake Tensors (#84282) 2022-09-01 00:15:05 +00:00
test_jit.py Update Dynamo pin (#83829) 2022-08-26 20:49:43 +00:00
test_jit_autocast.py [JIT] Retry - Support scripting torch.is_autocast_enabled() (#82394) 2022-08-10 18:26:17 +00:00
test_jit_cuda_fuser.py [ROCm] enable nvfuser (#82498) 2022-08-30 21:50:39 +00:00
test_jit_disabled.py
test_jit_fuser.py
test_jit_fuser_legacy.py
test_jit_fuser_te.py Supports symbolic diff for silu (#81724) 2022-08-09 01:18:10 +00:00
test_jit_legacy.py
test_jit_llga_fuser.py
test_jit_profiling.py
test_jit_simple.py
test_jit_string.py
test_jiterator.py [ROCm] enable jiterator (#77982) 2022-08-15 16:04:09 +00:00
test_kernel_launch_checks.py
test_license.py
test_linalg.py Make linalg.inv composite of linalg.solve (#80074) 2022-08-25 09:28:55 +00:00
test_logging.py
test_masked.py
test_maskedtensor.py [maskedtensor] adding unary and binary operations (#82837) 2022-08-22 21:00:38 +00:00
test_meta.py Add per-op MPS gradient tests and update skips (#84242) 2022-09-01 16:41:52 +00:00
test_metal.py
test_mkl_verbose.py
test_mkldnn.py check params shape for mkldnn_convolution (#76526) 2022-08-02 17:26:36 +00:00
test_mkldnn_fusion.py [NNC] enable fusion of conv with elementwise OP (#77157) 2022-08-10 21:46:51 +00:00
test_mkldnn_verbose.py
test_mobile_optimizer.py
test_model_dump.py
test_module_init.py [quant][ao_migration] torch.nn.qattorch.ao.nn.qat (#78716) 2022-08-25 16:50:38 +00:00
test_modules.py
test_monitor.py
test_mps.py Add per-op MPS gradient tests and update skips (#84242) 2022-09-01 16:41:52 +00:00
test_multiprocessing.py [ROCm] Enable test_multiprocessing tests (#82356) 2022-08-24 20:49:20 +00:00
test_multiprocessing_spawn.py
test_namedtensor.py Update std_mean/var_mean/nanmean/nansum signatures with int[1]? dim (#82912) 2022-08-10 16:58:26 +00:00
test_namedtuple_return_api.py [Refactoring] making the code more Pythonic (#82929) 2022-08-08 06:08:21 +00:00
test_native_functions.py
test_native_mha.py Add mask identifier for multiplexed src_mask/src_key_padding_mask in BT (#81947) 2022-08-09 23:42:16 +00:00
test_nestedtensor.py Better reshape with autograd support (#82754) (#84154) 2022-09-01 20:01:39 +00:00
test_nn.py Test Dynamo CI w Fake Tensors (#84282) 2022-09-01 00:15:05 +00:00
test_nnapi.py [quant][ao_migration] torch.nn.quantized.modulestorch.ao.nn.quantized.modules (#78713) 2022-08-25 16:50:33 +00:00
test_numba_integration.py
test_numpy_interop.py
test_openmp.py
test_ops.py [primTorch] Add ref for poisson_nll_loss (#83805) 2022-08-31 17:39:34 +00:00
test_ops_gradients.py
test_ops_jit.py [JIT Test] Add more debugging information for JIT opinfo tests (#83269) 2022-08-12 00:29:06 +00:00
test_optim.py Enhance add_out_dense_sparse_cpu for hybrid sparse tensor (#23057) 2022-08-24 22:42:53 +00:00
test_overrides.py Revert "Remove split functional wrapper (#74727)" 2022-08-10 19:45:23 +00:00
test_package.py
test_per_overload_api.py Add OpOverload.decompose API (#83075) 2022-08-09 18:53:19 +00:00
test_prims.py Refactored proxytensor to clean up separate branches (#84325) 2022-08-31 09:37:55 +00:00
test_profiler.py [Profiler][Minor] Extend Python bindings (#83622) 2022-08-26 20:03:24 +00:00
test_profiler_tree.py Back out "Revert D38984222: Don't introduce new overload for SymInt (#83628)" (#84173) 2022-08-29 18:01:07 +00:00
test_proxy_tensor.py Use register_meta for everything in meta_registrations (#84297) 2022-08-31 23:58:24 +00:00
test_pruning_op.py
test_public_bindings.py Torch cond operator, python dispatch, pyoperator (#83154) 2022-08-25 20:11:53 +00:00
test_python_dispatch.py Support returning symbolic strides from t.stride() in Python (#83842) 2022-08-24 04:32:51 +00:00
test_pytree.py Add *_only and all/any pytree utilities (#83316) 2022-08-12 17:31:55 +00:00
test_quantization.py Remove DBR quantization from the codebase (#83642) 2022-08-23 15:18:40 +00:00
test_reductions.py Enable dim=None for torch.var (#82765) 2022-08-04 20:47:27 +00:00
test_scatter_gather_ops.py
test_schema_check.py Respect TorchDispatchMode for shallow_copy_and_detach (#83372) 2022-08-16 14:32:27 +00:00
test_segment_reductions.py
test_serialization.py Rename _Typed/_UntypedStorage to Typed/UntypedStorage and update docs (#82438) 2022-07-30 19:37:08 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py
test_show_pickle.py
test_sort_and_select.py Update Dynamo pin (#83829) 2022-08-26 20:49:43 +00:00
test_sparse.py Sparse_coo: Be more agressive in setting coalesced True to avoid suprising behaviors (#82426) 2022-09-01 17:46:51 +00:00
test_sparse_csr.py Dense <-> bsc conversions (#80781) 2022-09-01 16:01:58 +00:00
test_spectral_ops.py Fix use-dict-literal lint (#83718) 2022-08-24 00:26:46 +00:00
test_stateless.py
test_static_runtime.py
test_subclass.py
test_tensor_creation_ops.py [primTorch] Refs for pdist, triu and related ops (#82819) 2022-08-18 21:52:03 +00:00
test_tensorboard.py
test_tensorexpr.py
test_tensorexpr_pybind.py
test_testing.py Move OpInfo class into new opinfo folder (#82540) 2022-08-05 15:10:17 +00:00
test_throughput_benchmark.py
test_torch.py Test Dynamo CI w Fake Tensors (#84282) 2022-09-01 00:15:05 +00:00
test_transformers.py Fix issue in softmax.cu with transformer error when mask seqlen > 1024 (#83639) 2022-08-30 18:06:27 +00:00
test_type_hints.py
test_type_info.py
test_type_promotion.py Test type promotion assertignoretypes (#83867) 2022-08-24 08:00:20 +00:00
test_typing.py
test_unary_ufuncs.py Remove assertEqualIgnoreTypes from test_unary_ufuncs (#83711) 2022-08-19 05:04:56 +00:00
test_utils.py Fix and unskip cpp extension tests for ARM (#83115) 2022-08-11 20:01:53 +00:00
test_view_ops.py
test_vmap.py
test_vulkan.py
test_xnnpack_integration.py