pytorch/test
Janani Sriram f4cbcff8ef [TorchScript] Expand TorchScript __init__ annotation warning (#127045)
Summary:
Expand TorchScript `__init__` annotation warning to `list` and `dict` with reference to GSD task T187638414 and annotation warning reproduction D56834720.

Currently, the TorchScript compiler ignores and throws `UserWarning`s for the following annotation types for empty values within the `__init__` function: `List`, `Dict`, `Optional`. However, the compiler should additionally cover warnings for `list` and `dict`. This diff adds support for `list` and `dict`.

Test Plan:
Added 4 new unit tests:

`test_annotated_empty_list_lowercase` and `test_annotated_empty_dict_lowercase` verify that TorchScript throws UserWarnings for the list and dict type annotations on empty values.
```
(base) [jananisriram@devvm2248.cco0 /data/users/jananisriram/fbsource/fbcode (e4ce427eb)]$ buck2 test @mode/{opt,inplace} //caffe2/test:jit -- --regex test_annotated_empty_list_lowercase
...
Tests finished: Pass 2. Fail 0. Fatal 0. Skip 0. Build failure 0
```
```
(base) [jananisriram@devvm2248.cco0 /data/users/jananisriram/fbsource/fbcode (e4ce427eb)]$ buck2 test @mode/{opt,inplace} //caffe2/test:jit -- --regex test_annotated_empty_dict_lowercase
...
Tests finished: Pass 2. Fail 0. Fatal 0. Skip 0. Build failure 0
```

`test_annotated_with_jit_empty_list_lowercase` and `test_annotated_with_jit_empty_dict_lowercase` verify that TorchScript throws UserWarnings for the list and dict type annotations on empty values with the jit annotation.
```
(base) [jananisriram@devvm2248.cco0 /data/users/jananisriram/fbsource/fbcode (e4ce427eb)]$ buck2 test @mode/{opt,inplace} //caffe2/test:jit -- --regex test_annotated_with_jit_empty_list_lowercase
...
Tests finished: Pass 2. Fail 0. Fatal 0. Skip 0. Build failure 0
```
```
(base) [jananisriram@devvm2248.cco0 /data/users/jananisriram/fbsource/fbcode (e4ce427eb)]$ buck2 test @mode/{opt,inplace} //caffe2/test:jit -- --regex test_annotated_with_jit_empty_dict_lowercase
...
Tests finished: Pass 2. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Differential Revision: D57752002

Pull Request resolved: https://github.com/pytorch/pytorch/pull/127045
Approved by: https://github.com/davidberard98
2024-05-28 23:49:10 +00:00
..
ao/sparsity
autograd
backends/xeon
benchmark_utils
bottleneck_test
cpp [codemod] c10::optional -> std::optional in caffe2/aten/src/ATen/DeviceGuard.h +117 (#126901) 2024-05-24 00:26:15 +00:00
cpp_api_parity
cpp_extensions [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
custom_backend [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
custom_operator [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
distributed [FSDP2] Added test for N-way TP and 1-way FSDP with CPU offloading (#127024) 2024-05-28 22:51:36 +00:00
distributions [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
dynamo [dynamo][fsdp] Skip Dynamo tracing of __getattr__ if its top-level frame (#127263) 2024-05-28 08:16:53 +00:00
dynamo_expected_failures Revert "reset dynamo cache before each test (#126586)" 2024-05-25 17:17:19 +00:00
dynamo_skips [dynamo] Graph break on set_num_threads (#126623) 2024-05-20 17:44:32 +00:00
edge
error_messages
expect Revert "Lift jagged -> padded dense forward / backward kernels from fbgemm_gpu (#125946)" 2024-05-24 20:26:07 +00:00
export [export] handle new roots & root swapping in derived dims suggested fixes (#125543) 2024-05-28 20:41:43 +00:00
forward_backward_compatibility Switched from parameter in can_cast to from_. (#126030) 2024-05-16 20:58:24 +00:00
functorch [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
fx [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
higher_order_ops [torchbind] Add inductor support (#123709) 2024-05-13 18:18:17 +00:00
inductor cudagraphs: fix backward hooks & fsdp interaction (#126914) 2024-05-28 22:07:41 +00:00
jit [TorchScript] Expand TorchScript __init__ annotation warning (#127045) 2024-05-28 23:49:10 +00:00
jit_hooks
lazy [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
mobile [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
nn Dont mutate tensor stride in place in cudnn conv (#126786) 2024-05-22 01:53:44 +00:00
onnx [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
onnx_caffe2 [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
optim
package [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
profiler [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
quantization Revert "[Quant][PT2E] enable qlinear post op fusion for dynamic quant & qat (#122667)" 2024-05-21 13:45:07 +00:00
scripts [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_img
torch_np [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
typing [1/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort stdlib (#127122) 2024-05-25 08:25:50 +00:00
xpu [Aten] Fix XPU convolution_overrideable input memory format. (#124841) 2024-04-26 15:55:01 +00:00
_test_bazel.py
allowlist_for_publicAPI.json Traceable wrapper subclass support for deferred runtime asserts (#126198) 2024-05-21 01:21:46 +00:00
conftest.py
create_dummy_torchscript_model.py
delete.py
hi.py
HowToWriteTestsUsingFileCheck.md
linear.py
load_torchscript_model.py
minioptest_failures_dict.json
mkl_verbose.py
mkldnn_verbose.py
pytest_shard_custom.py
run_doctests.sh
run_test.py Change run_test.py arg parsing to handle additional args better (#126709) 2024-05-23 21:08:12 +00:00
simulate_nccl_errors.py
test_ao_sparsity.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_autocast.py [Doc] Add deprecated autocast comments for doc (#126062) 2024-05-16 05:26:43 +00:00
test_autograd.py Remove removed ruff rule TRY200 (#126256) 2024-05-17 16:31:05 +00:00
test_autograd_fallback.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_binary_ufuncs.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_bundled_images.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_bundled_inputs.py
test_ci_sanity_check_fail.py
test_comparison_utils.py
test_compile_benchmark_util.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_complex.py
test_content_store.py
test_cpp_api_parity.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_cpp_extensions_aot.py
test_cpp_extensions_jit.py
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 map_location for wrapper subclass and device tensors that go through numpy (#126728) 2024-05-24 16:39:30 +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 generalize custom_fwd&custom_bwd to be device-agnostic (#126531) 2024-05-25 06:48:16 +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 Deprecate device-specific GradScaler autocast API (#126527) 2024-05-25 06:41:34 +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 [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_dataloader.py Enable UFMT on test/test_dataloader.py (#124710) 2024-04-28 21:21:51 +00:00
test_datapipe.py Enable UFMT on test/test_datapipe.py (#124994) 2024-05-15 21:58:35 +00:00
test_decomp.py [decomp] Fix default values missing from inplace rrelu decomposition (#126978) 2024-05-26 23:49: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 [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_dispatch.py
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 [export] handle new roots & root swapping in derived dims suggested fixes (#125543) 2024-05-28 20:41:43 +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 Make propagate_real_tensor more safe (#126281) 2024-05-15 23:57:02 +00:00
test_flop_counter.py Foward fix lint after #125747 (#126295) 2024-05-15 16:37:48 +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 Enable UFMT on test/test_fake_tensor.py, test/test_flop_counter.py and some files (#125747) 2024-05-15 14:50:14 +00:00
test_functional_autograd_benchmark.py Enable UFMT on test/test_fake_tensor.py, test/test_flop_counter.py and some files (#125747) 2024-05-15 14:50:14 +00:00
test_functional_optim.py Enable UFMT on test/test_fake_tensor.py, test/test_flop_counter.py and some files (#125747) 2024-05-15 14:50:14 +00:00
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 Enable UFMT on test/test_fake_tensor.py, test/test_flop_counter.py and some files (#125747) 2024-05-15 14:50:14 +00:00
test_futures.py
test_fx.py Remove removed ruff rule TRY200 (#126256) 2024-05-17 16:31:05 +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 Enable UFMT on test/test_hub.py (#127155) 2024-05-25 18:23:24 +00:00
test_import_stats.py
test_indexing.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +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
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 [MPS] Add _weight_int8pack_mm tests (#127041) 2024-05-24 16:08:06 +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
test_matmul_cuda.py
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 Fix nested fqn discovery (#125957) 2024-05-13 18:24:56 +00:00
test_modules.py Revert "reset dynamo cache before each test (#126586)" 2024-05-25 17:17:19 +00:00
test_monitor.py
test_mps.py [MPS] Enable toch.mm and friends for complex dtypes (#127241) 2024-05-28 17:56:13 +00:00
test_multiprocessing.py
test_multiprocessing_spawn.py
test_namedtensor.py
test_namedtuple_return_api.py
test_native_functions.py
test_native_mha.py
test_nestedtensor.py Revert "Lift jagged -> padded dense forward / backward kernels from fbgemm_gpu (#125946)" 2024-05-24 20:26:07 +00:00
test_nn.py [CUDA] Parallelize upsampling OPS across the batch/channel dimension. (#127082) 2024-05-24 21:17:12 +00:00
test_nnapi.py Enable ufmt format on test files (#126845) 2024-05-28 01:42:07 +00:00
test_numba_integration.py Enable ufmt format on test files (#126845) 2024-05-28 01:42:07 +00:00
test_numpy_interop.py Fix lint after #126845 (#127286) 2024-05-28 12:38:27 +00:00
test_openmp.py Enable ufmt format on test files (#126845) 2024-05-28 01:42:07 +00:00
test_ops.py
test_ops_fwd_gradients.py
test_ops_gradients.py
test_ops_jit.py
test_optim.py Fix lint after #126845 (#127286) 2024-05-28 12:38:27 +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 Address issue #125307 (#126351) 2024-05-28 02:03:24 +00:00
test_pruning_op.py
test_public_bindings.py Fix public binding to actually traverse modules (#126103) 2024-05-15 19:36:03 +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
test_quantization.py
test_reductions.py Remove calls of deprecated _aminmax (#127182) 2024-05-28 03:51:45 +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 Fix map_location for wrapper subclass and device tensors that go through numpy (#126728) 2024-05-24 16:39:30 +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 [traced-graph][sparse] propagate sparsity metadata into traced graph (#117907) 2024-05-23 22:46:46 +00:00
test_sparse_csr.py
test_sparse_semi_structured.py
test_spectral_ops.py
test_stateless.py
test_static_runtime.py
test_subclass.py
test_sympy_utils.py
test_tensor_creation_ops.py
test_tensorboard.py
test_tensorexpr.py
test_tensorexpr_pybind.py
test_testing.py
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 Deprecate device-specific GradScaler autocast API (#126527) 2024-05-25 06:41:34 +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 Enable UFMT format on test/test_utils.py (#125996) 2024-05-15 18:22:57 +00:00
test_view_ops.py [5/N][Easy] fix typo for usort config in pyproject.toml (kown -> known): sort torch (#127126) 2024-05-27 14:49:57 +00:00
test_vulkan.py
test_weak.py
test_xnnpack_integration.py
test_xpu.py xpu: implement xpu serialization (#125530) 2024-05-16 20:22:17 +00:00