pytorch/test
Edward Z. Yang f7365eca90 Add unbacked symints support; item works now (#90624)
The big idea is to add `create_unbacked_symfloat` and `create_unbacked_symint` to ShapeEnv, allowing you to allocate symbolic floats/ints corresponding to data you don't know about at compile time. Then, instead of immediately erroring out when you try to call local_scalar_dense on a FakeTensor, we instead create a fresh symint/symfloat and return that.

There a bunch of odds and ends that need to be handled:

* A number of `numel` calls converted to `sym_numel`
* When we finally return from item(), we need to ensure we actually produce a SymInt/SymFloat when appropriate. The previous binding code assumed that you would have to get a normal Python item. I add a pybind11 binding for Scalar (to PyObject only) and refactor the code to use that. There is some trickiness where you are NOT allowed to go through c10::SymInt if there isn't actually any SymInt involved. See comment.
* One of our unit tests tripped an implicit data dependent access which occurs when you pass a Tensor as an argument to a sizes parameter. This is also converted to support symbolic shapes
* We now support tracking bare SymInt/SymFloat returns in proxy tensor mode (this was already in symbolic-shapes branch)
* Whenever we allocate an unbacked symint, we record the stack trace it was allocated at. These get printed when you attempt data dependent access on the symint (e.g., you try to guard on it)
* Subtlety: unbacked symints are not necessarily > 1. I added a test for this.

These unbacked symints are not very useful right now as you will almost always immediately raise an error later when you try to guard on them. The next logical step is adding an assertion refinement system that lets ShapeEnv learn facts about unbacked symints so it can do a better job eliding guards that are unnecessary.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/90624
Approved by: https://github.com/Skylion007, https://github.com/voznesenskym
2022-12-12 13:33:07 +00:00
..
ao/sparsity [pruning][core][feature] Implement prune for structured pruning (#89777) 2022-12-08 07:13:24 +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 Clean up dependancy for flatbuffer_loader (#86041) 2022-12-08 03:48:04 +00:00
cpp_api_parity
cpp_extensions Add tests for custom pybind type_casters (#89897) 2022-12-02 07:02:09 +00:00
custom_backend Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
custom_operator Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
distributed [FSDP] Allow MixedPrecision to skip inputs (#90620) 2022-12-11 06:39:38 +00:00
distributions Add a transform for positive-definite matrices. (#76777) 2022-12-08 09:18:44 +00:00
dynamo [Dynamo] Support access nn.Module keys (#90502) 2022-12-12 09:15:42 +00:00
error_messages
expect Avoid overflow in tensorboard image summary (#90423) 2022-12-08 08:31:52 +00:00
forward_backward_compatibility Update sdp dispatch logic to enable fused backward (#89154) 2022-11-21 20:02:09 +00:00
functorch Revert guaranteed symint allocation (#90381) 2022-12-10 13:17:34 +00:00
fx [fx] Have replace_pattern return replaced nodes (#90244) 2022-12-09 23:43:16 +00:00
inductor inductor(CPU): add Conv+binary+unary fusion filter (#90259) 2022-12-12 06:04:55 +00:00
jit Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
jit_hooks Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
lazy Fix exception causes all over the codebase (#90271) 2022-12-07 04:29:00 +00:00
mobile Migrate PyTorch to C++17 (#85969) 2022-12-08 02:27:48 +00:00
nn add shape check for random_samples in fractional_max_pool{2d|3d} (#89992) 2022-12-06 14:14:41 +00:00
onnx [ONNX] Introduce ONNX reference evaluator for verification (#89808) 2022-12-10 01:29:12 +00:00
onnx_caffe2 Disable BUILD_CAFFE2 from ONNX builds (#90475) 2022-12-09 18:02:48 +00:00
package [rfc][pkg] check spec for module source before falling back to file in package exporter (#90258) 2022-12-08 20:24:45 +00:00
profiler [Profiler] Memory profiler part 13: Add sizes to timeline. (#89356) 2022-12-02 03:55:22 +00:00
quantization Reland "Add heirachical module names to torchFX graph.node" (#90205) 2022-12-09 06:20:31 +00:00
scripts Fix typos in messages under test (#89121) 2022-11-17 01:55:03 +00:00
test_img
typing
allowlist_for_publicAPI.json Revert "[ao] making _is_activation_post_process private (#87520)" 2022-11-21 16:48:26 +00:00
conftest.py [ci] print rerun stacktraces for pytest (#86831) 2022-10-14 17:31:31 +00:00
create_dummy_torchscript_model.py
delete.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py
mkl_verbose.py [RFC] enable oneMKL&oneDNN on-demands verbose functinality (#63212) 2022-07-27 23:29:35 +00:00
mkldnn_verbose.py [RFC] enable oneMKL&oneDNN on-demands verbose functinality (#63212) 2022-07-27 23:29:35 +00:00
run_doctests.sh Integrate xdoctest - Rebased (#82797) 2022-08-12 02:08:01 +00:00
run_test.py Use pytest-flakefinder to rerun tests multiple times (#89106) 2022-11-18 00:11:44 +00:00
simulate_nccl_errors.py
test_ao_sparsity.py [pruning][core][feature] Align BaseStructuredPruner with existing pruning flow (#88436) 2022-12-03 00:53:53 +00:00
test_autocast.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_autograd.py Add setup_context staticmethod to autograd.Function (#89859) 2022-12-08 19:31:04 +00:00
test_binary_ufuncs.py Fix type promotion for 2 wrapped scalar args (#87845) 2022-10-27 15:53:11 +00:00
test_bundled_images.py
test_bundled_inputs.py
test_comparison_utils.py Add aten _assert_tensor_metadata op (#84617) 2022-09-19 20:48:09 +00:00
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 Add tests for custom pybind type_casters (#89897) 2022-12-02 07:02:09 +00:00
test_cpp_extensions_jit.py Split out forward AD tests from test_ops_gradients and reenable slow gradcheck CI (#88216) 2022-11-03 00:20:45 +00:00
test_cpp_extensions_open_device_registration.py Make M1 tests green (#82213) 2022-08-05 16:12:08 +00:00
test_cuda_nvml_based_avail.py Extend torch.cuda.is_available() to attempt an NVML-based CUDA availability assessment when explicitly requested by the user (#85951) 2022-10-12 18:37:50 +00:00
test_cuda_primary_ctx.py
test_cuda_sanitizer.py Rework printing tensor aliases in CSAN error message (#85008) 2022-09-21 13:41:52 +00:00
test_cuda_trace.py Add synchronize hooks (#84427) 2022-09-09 13:56:59 +00:00
test_cuda.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_dataloader.py Fix issue 38095 TODO in test_dataloader.py (#90084) 2022-12-03 03:01:52 +00:00
test_datapipe.py [dynamo] VariableTracker.call_method requires a name (#88311) 2022-11-10 18:17:23 +00:00
test_decomp.py Fix uniform ref implementation (#90094) 2022-12-06 21:28:17 +00:00
test_deploy.py
test_determination.py
test_dispatch.py Remove unnecessary skips in test_dispatch.py (#85557) 2022-09-26 15:35:47 +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 Revert guaranteed symint allocation (#90381) 2022-12-10 13:17:34 +00:00
test_expanded_weights.py Tweak test tolerances to be compatible with A10G (#86538) 2022-10-11 23:31:48 +00:00
test_fake_tensor.py Make fake tensors preserve dense strides in type conversion (#89803) 2022-11-30 01:28:51 +00:00
test_foreach.py Add _foreach_addc(div/mul)(_).Tensor (#88157) 2022-11-02 23:24:35 +00:00
test_function_schema.py [frontend] Print real type for Argument (#85103) 2022-09-15 22:16:32 +00:00
test_functional_autograd_benchmark.py
test_functional_optim.py [CI] Build MacOS M1 binaries without distributed support (#86451) 2022-10-10 17:42:13 +00:00
test_functionalization.py [Reland] Move functorch/_src to torch/_functorch (#88756) (#90091) 2022-12-03 14:17:15 +00:00
test_futures.py [torch.futures] Fix nullptr deref (#85304) 2022-09-20 01:49:04 +00:00
test_fx_experimental.py [fx][passes] Implement annotate getitem node FX passes (#90237) 2022-12-06 23:18:55 +00:00
test_fx_passes.py nvprims bookend non compute (#88457) 2022-11-08 12:06:35 +00:00
test_fx_reinplace_pass.py Make aten.copy preserve strides (hf_Longformer) (#89464) 2022-11-22 13:06:43 +00:00
test_fx.py Reland "Add heirachical module names to torchFX graph.node" (#90205) 2022-12-09 06:20:31 +00:00
test_hub.py
test_import_stats.py
test_indexing.py Add a mode to rerun all disabled tests (without running anything else) (#88646) 2022-11-15 05:08:26 +00:00
test_itt.py Fix ITT unit-tests if PyTorch is compiled with USE_ITT=OFF (#86199) 2022-10-04 21:57:05 +00:00
test_jit_autocast.py prepare removal of deprecated functionality in torch.testing (#87969) 2022-11-02 14:04:48 +00:00
test_jit_cuda_fuser.py Rectify native_batch_norm schema by splitting it into two legit schemas (#88697) 2022-11-23 23:23:17 +00:00
test_jit_disabled.py
test_jit_fuser_legacy.py
test_jit_fuser_te.py Fix issue 38095 TODO in test_jit_fuser_te.py (#90246) 2022-12-08 01:39:26 +00:00
test_jit_fuser.py
test_jit_legacy.py
test_jit_llga_fuser.py Set correct size of attr::output_layouts when the graph has multiple outputs in JIT oneDNN fuser (#88496) 2022-11-15 07:29:55 +00:00
test_jit_profiling.py
test_jit_simple.py
test_jit_string.py
test_jit.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_jiterator.py [ROCm] enable jiterator (#77982) 2022-08-15 16:04:09 +00:00
test_kernel_launch_checks.py
test_legacy_vmap.py [vmap] Prepend "legacy" to files for old vmap implementation (#90324) 2022-12-07 18:46:15 +00:00
test_license.py
test_linalg.py Reland Dispatch torch.norm to linalg.vector_norm and linalg.matrix_norm (#81761) (#84624) 2022-11-22 07:53:24 +00:00
test_logging.py
test_masked.py [maskedtensor] port torch/_masked into torch/masked (#85515) 2022-09-26 23:41:13 +00:00
test_maskedtensor.py [maskedtensor] use masked_softmax for forward/backward instead of regular softmax (#85845) 2022-10-04 00:29:19 +00:00
test_matmul_cuda.py Add test case for matrix multiply-add with large inputs (#85550) 2022-10-11 17:52:21 +00:00
test_meta.py correctly set strides for expanded/unsqueezed dimensions (#90341) 2022-12-07 23:38:33 +00:00
test_metal.py
test_mkl_verbose.py [RFC] enable oneMKL&oneDNN on-demands verbose functinality (#63212) 2022-07-27 23:29:35 +00:00
test_mkldnn_fusion.py torchdynamo: add convolution add(relu) inplace fusion kernel (#88048) 2022-11-10 13:54:37 +00:00
test_mkldnn_verbose.py [RFC] enable oneMKL&oneDNN on-demands verbose functinality (#63212) 2022-07-27 23:29:35 +00:00
test_mkldnn.py add parameters check for mkldnn_transpose (#85318) 2022-11-03 17:28:33 +00:00
test_mobile_optimizer.py
test_model_dump.py Fix failing test_model_dump due to empty file (#84744) 2022-09-12 20:59:19 +00:00
test_module_init.py prepare removal of deprecated functionality in torch.testing (#87969) 2022-11-02 14:04:48 +00:00
test_modules.py Enable some PyTorch core tests with inductor (#87490) 2022-10-26 18:58:33 +00:00
test_monitor.py
test_mps.py Add additional tests for view slice tensors (#86282) 2022-12-08 17:59:55 +00:00
test_multiprocessing_spawn.py
test_multiprocessing.py Revert "Fix issue 38095 TODO in test_multiprocessing.py (#90335)" 2022-12-08 17:12:10 +00:00
test_namedtensor.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_namedtuple_return_api.py Remove deprecated torch.lstsq (#70980) 2022-09-23 00:16:55 +00:00
test_native_functions.py Improve argument printing (#87601) 2022-10-24 23:55:10 +00:00
test_native_mha.py Use scaled_dot_product_attention within attention.cpp (#87312) 2022-10-31 04:06:31 +00:00
test_nestedtensor.py Removed unecessary check in select_nested (#89150) 2022-11-16 22:11:37 +00:00
test_nn.py [Resubmit] state_dict_pre_hook (#90435) 2022-12-08 07:54:14 +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_nvfuser_dynamo.py Add min cut partitioner for AOT+nvFuser (#88204) 2022-11-09 12:56:55 +00:00
test_nvfuser_frontend.py Add ops.broadcast for nvFuser (#88080) 2022-11-02 10:05:12 +00:00
test_openmp.py
test_ops_fwd_gradients.py Mitigate flaky test_ops_fwd_gradients on macOS (#89410) 2022-11-22 00:13:38 +00:00
test_ops_gradients.py Split out forward AD tests from test_ops_gradients and reenable slow gradcheck CI (#88216) 2022-11-03 00:20:45 +00:00
test_ops_jit.py Split out forward AD tests from test_ops_gradients and reenable slow gradcheck CI (#88216) 2022-11-03 00:20:45 +00:00
test_ops.py Add Pointwise Tag from pointwise set in DTensor, use in aot_autograd partitioner (#90029) 2022-12-08 20:21:17 +00:00
test_optim.py Implement post and pre hooks for optimizer (#89176) 2022-12-02 07:03:45 +00:00
test_overrides.py Fix gradcheck for CSR and CSC inputs. (#89786) 2022-12-02 12:35:20 +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 [ROCm] Enable few test_prim UTs for ROCm (#88983) 2022-12-07 06:21:31 +00:00
test_proxy_tensor.py Add unbacked symints support; item works now (#90624) 2022-12-12 13:33:07 +00:00
test_pruning_op.py
test_public_bindings.py Revert "rename DisableTorchFunction to DisableTorchFunctionSubclass (#88218)" 2022-11-11 19:13:05 +00:00
test_python_dispatch.py Fix bug in OptionalTensorList (#88887) 2022-11-12 02:19:46 +00:00
test_pytree.py Make nested TreeSpec printing nicer (#46538) (#86546) 2022-10-18 16:50:39 +00:00
test_quantization.py [Reland][ONNX] Move all torch.onnx.export related tests to test/onnx (#87292) 2022-11-01 14:22:46 +00:00
test_reductions.py Reland Dispatch torch.norm to linalg.vector_norm and linalg.matrix_norm (#81761) (#84624) 2022-11-22 07:53:24 +00:00
test_scatter_gather_ops.py Add deterministic impl of scatter_add CUDA for all input sizes (#79466) 2022-09-07 03:12:49 +00:00
test_schema_check.py Skip some unittests (#90609) 2022-12-11 23:53:05 +00:00
test_segment_reductions.py
test_serialization.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_set_default_mobile_cpu_allocator.py
test_shape_ops.py Enable sparse_dim() and dense_dim() methods for Strided tensors (#86203) 2022-10-06 18:39:22 +00:00
test_show_pickle.py
test_sort_and_select.py Re-enable fixed dynamo tests (#84969) 2022-09-16 15:36:52 +00:00
test_sparse_csr.py Add layout and blocksize arguments to Tensor.to_sparse method (#89502) 2022-11-30 20:21:10 +00:00
test_sparse.py Add layout and blocksize arguments to Tensor.to_sparse method (#89502) 2022-11-30 20:21:10 +00:00
test_spectral_ops.py istft: require complex input (#86628) 2022-10-18 12:03:55 +00:00
test_stateless.py add deprecation warning to nn stateless functional_call (#87367) 2022-10-20 20:16:49 +00:00
test_static_runtime.py [Static Runtime] test case for staticRuntime::runAsync() API (#80407) 2022-07-05 23:40:53 +00:00
test_subclass.py [torchdynamo hash update] update the pinned torchdynamo hash (#85225) 2022-09-26 20:07:13 +00:00
test_tensor_creation_ops.py [reland] [numpy] add torch.concatenate, alias of torch.cat (#85073) 2022-09-15 19:34:44 +00:00
test_tensorboard.py use proper temp directories in test_tensorboard.py (#89826) 2022-12-09 19:33:03 +00:00
test_tensorexpr_pybind.py
test_tensorexpr.py Revert "remove torch.equal usages (#89527)" 2022-12-02 21:36:13 +00:00
test_testing.py Refactor how AOTAutograd backends are defined (#89736) 2022-11-28 18:39:12 +00:00
test_throughput_benchmark.py
test_torch.py Some memory saving in large unittests (#90148) 2022-12-11 21:04:38 +00:00
test_transformers.py [SDP] Fix alignment check for efficient_attention (#90413) 2022-12-09 21:09:25 +00:00
test_type_hints.py
test_type_info.py
test_type_promotion.py Fix typos in messages under test (#89121) 2022-11-17 01:55:03 +00:00
test_typing.py
test_unary_ufuncs.py Log1p complex for CUDA (#90422) 2022-12-09 19:53:22 +00:00
test_utils.py skip environment collection test in fbcode (#88744) 2022-11-09 18:20:04 +00:00
test_view_ops.py disable test that fails in fbcode (#88786) 2022-11-15 19:08:31 +00:00
test_vulkan.py
test_xnnpack_integration.py disable test that times out in fbcode (#88758) 2022-11-10 00:28:02 +00:00