mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
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 |
||
|---|---|---|
| .. | ||
| _imported_class_test | ||
| fixtures | ||
| fixtures_srcs | ||
| xnnpack | ||
| __init__.py | ||
| mydecorator.py | ||
| myexception.py | ||
| myfunction_a.py | ||
| myfunction_b.py | ||
| test_alias_analysis.py | ||
| test_async.py | ||
| test_aten_pow.py | ||
| test_attr.py | ||
| test_autodiff.py | ||
| test_autodiff_subgraph_slicing.py | ||
| test_await.py | ||
| test_backend_nnapi.py | ||
| test_backends.py | ||
| test_batch_mm.py | ||
| test_builtins.py | ||
| test_class_type.py | ||
| test_complex.py | ||
| test_complexity.py | ||
| test_convert_activation.py | ||
| test_cuda.py | ||
| test_custom_operators.py | ||
| test_data_parallel.py | ||
| test_dataclasses.py | ||
| test_dce.py | ||
| test_decorator.py | ||
| test_device_analysis.py | ||
| test_dtype_analysis.py | ||
| test_enum.py | ||
| test_exception.py | ||
| test_freezing.py | ||
| test_functional_blocks.py | ||
| test_fuser_common.py | ||
| test_generator.py | ||
| test_graph_rewrite_passes.py | ||
| test_hash.py | ||
| test_hooks.py | ||
| test_hooks_modules.py | ||
| test_ignorable_args.py | ||
| test_ignore_context_manager.py | ||
| test_isinstance.py | ||
| test_jit_utils.py | ||
| test_list_dict.py | ||
| test_logging.py | ||
| test_misc.py | ||
| test_models.py | ||
| test_module_apis.py | ||
| test_module_containers.py | ||
| test_module_interface.py | ||
| test_modules.py | ||
| test_op_decompositions.py | ||
| test_optimize_for_mobile_preserve_debug_info.py | ||
| test_parametrization.py | ||
| test_pdt.py | ||
| test_peephole.py | ||
| test_profiler.py | ||
| test_python_bindings.py | ||
| test_python_builtins.py | ||
| test_python_ir.py | ||
| test_recursive_script.py | ||
| test_remove_mutation.py | ||
| test_save_load.py | ||
| test_save_load_for_op_version.py | ||
| test_script_profile.py | ||
| test_scriptmod_ann.py | ||
| test_slice.py | ||
| test_sparse.py | ||
| test_string_formatting.py | ||
| test_symbolic_shape_analysis.py | ||
| test_tensor_creation_ops.py | ||
| test_tensor_methods.py | ||
| test_torchbind.py | ||
| test_tracer.py | ||
| test_type_sharing.py | ||
| test_types.py | ||
| test_typing.py | ||
| test_union.py | ||
| test_union_pep604.py | ||
| test_unsupported_ops.py | ||
| test_upgraders.py | ||
| test_warn.py | ||
| test_with.py | ||