pytorch/torch
Zhengxu Chen e62189ad69 [jit] Better checking for overload function declarations. (#59956)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59956

Issue #50175. Basically two things need to be checked and are lacking currently:
1. Overload declarations should always have a single `pass` statement as the body.
2. There should be always an implementation provided for decls which doesn't
   have the torch.jit._overload decorator. So in this case we need to check
   whether we are actually compiling a function body with decorator ahead.

Test Plan:
python test/test_jit.py TestScript.test_function_overloads

Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D29106555

fbshipit-source-id: 2d9d7df2fb51ab6db0e1b726f9644e4cfbf733d6
2021-08-05 14:21:48 -07:00
..
_C [DDP Communication Hook] Update get_tensor and set_tensor to be cleaner naming conventions (buffer() and set_buffer()) (#62662) 2021-08-04 09:27:31 -07:00
ao [pruner] generalize bias hook for conv2d (#62430) 2021-08-05 09:27:17 -07:00
autograd [profiler][refactor] Refactor the usage of legacy profiler implementation (#61931) 2021-08-03 18:51:29 -07:00
backends [8/N] Nnapi backend delegation preprocess: New refactored design (#62225) 2021-07-27 18:52:48 -07:00
contrib
cpu
csrc Add batched model to torchdeploy examples (#62836) 2021-08-05 14:01:40 -07:00
cuda [fix] manual_seed{_all}: mem leak (#62534) 2021-08-04 13:03:12 -07:00
distributed [DDP Communication Hook] Update get_tensor and set_tensor to be cleaner naming conventions (buffer() and set_buffer()) (#62662) 2021-08-04 09:27:31 -07:00
distributions [docs] Update sphinx to 3.5.4 (#61601) 2021-07-30 06:23:10 -07:00
fft
for_onnx
futures
fx [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
jit [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
legacy
lib Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
linalg Svd docfix (#62028) 2021-07-22 14:11:52 -07:00
multiprocessing
nn Fixes #62636 (#62670) 2021-08-04 13:58:21 -07:00
onnx Simplify hardswish ONNX export graph. (#60080) 2021-08-05 11:15:14 -07:00
optim
package
profiler [profiler][refactor] Refactor the usage of legacy profiler implementation (#61931) 2021-08-03 18:51:29 -07:00
quantization ns for fx: add ref_node_target_type (#62685) 2021-08-05 09:26:10 -07:00
sparse
special [special] alias for mvlgamma (#61633) 2021-07-23 11:24:27 -07:00
testing add OpInfo for torch.nn.functional.grid_sample (#62311) 2021-08-05 10:43:54 -07:00
utils [profiler][refactor] Refactor the usage of legacy profiler implementation (#61931) 2021-08-03 18:51:29 -07:00
__config__.py
__future__.py
__init__.py remove deprecated is_deterministic and set_deterministic (#62158) 2021-08-04 16:45:23 -07:00
_appdirs.py
_autograd_functions.py
_classes.py
_deploy.py
_jit_internal.py [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
_linalg_utils.py
_lobpcg.py
_lowrank.py
_namedtensor_internals.py
_ops.py
_python_dispatcher.py Add device and key for lazy tensors (#61621) 2021-07-26 23:00:22 -07:00
_six.py
_sources.py [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
_storage_docs.py
_tensor.py Add serialization support for slots and subclass getstate/setstate (#62745) 2021-08-05 06:49:44 -07:00
_tensor_docs.py Exposes _aminmax as aminmax and makes it structured (#62401) 2021-08-03 16:10:43 -07:00
_tensor_str.py
_torch_docs.py Exposes _aminmax as aminmax and makes it structured (#62401) 2021-08-03 16:10:43 -07:00
_utils.py Hacky support for meta tensor serialization. (#62192) 2021-07-26 14:33:45 -07:00
_utils_internal.py [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
_VF.py
_vmap_internals.py
abi-check.cpp
CMakeLists.txt CMake: Add optional precompiled header support (#61940) 2021-08-03 09:13:47 -07:00
custom_class.h
custom_class_detail.h
deploy.h
extension.h
functional.py
hub.py Add option to skip GH validation for torch.hub (#62139) 2021-07-26 22:44:12 -07:00
library.h Add support for boxed functors (#62658) 2021-08-05 07:26:09 -07:00
overrides.py remove deprecated is_deterministic and set_deterministic (#62158) 2021-08-04 16:45:23 -07:00
py.typed
quasirandom.py Update SobolEngine docstring w/ correct behavior (#62548) 2021-08-02 09:04:38 -07:00
random.py
README.txt
script.h
serialization.py [jit] Better checking for overload function declarations. (#59956) 2021-08-05 14:21:48 -07:00
storage.py
torch_version.py
types.py

Note [TH abstraction violation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TH/THC provide some hpp headers, which are proper C++ headers rather than
C headers.  These headers serve double duty as *internal implementation
detail* headers, whose contents should largely not be used by external
clients.

Ideally, we would not install these headers at all; instead, you should
use public functions (in headers like `THTensor.h`, NOT `THTensor.hpp`)
to manipulate these structs.  However, there are a few places
in torch/csrc where we violate this abstraction.  They are marked with
a pointer to this note.  Each of those sites will have to be refactored
when we refactor the guts of THTensor and related structures.