pytorch/torch/jit
Elias Ellison 451fc51d8d add support for overloading functions (#23886)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/23886

This is a series of PRs that will allow us to support adding [padding to conv](https://github.com/pytorch/pytorch/pull/22484) and also reduce the friction of adding method overloads that was brought up in  https://github.com/pytorch/pytorch/pull/23266.

Support for overloaded functions following the specification in [PEP 484](https://www.python.org/dev/peps/pep-0484/#function-method-overloading).

The usage is:
```
torch.jit.overload
def add(x: int, y: int) -> int: ...
torch.jit.overload
def add(x: float, y: float) -> float: ...

def add:
    return x + y
```

Follow up PRs:

- Add same API for methods
- A couple of cleanups for functions:
     - don't require default params specified on the overload as well
     - potentially error if invocation could be matched to multiple overloads. now it just chooses the first one, mypy does the same thing currently

Test Plan: Imported from OSS

Differential Revision: D16694863

Pulled By: eellison

fbshipit-source-id: f94f2933bc1c97fa58f31846acfe962b0630068c
2019-08-07 19:18:19 -07:00
..
__init__.py add support for overloading functions (#23886) 2019-08-07 19:18:19 -07:00
_logging.py Experimental logging/counters API (#18235) 2019-03-29 17:14:03 -07:00
_pickle.py Add all list specializations to pickler (#20191) 2019-05-10 17:14:42 -07:00
annotations.py Include recursive class compilations in error call stack (#23454) 2019-07-30 17:29:54 -07:00
frontend.py add NotIn support in script 2019-08-07 16:07:21 -07:00
quantized.py Remove K and N function arguments for fbgemm_pack_quantized_matrix (#22956) 2019-08-07 08:50:13 -07:00
supported_ops.py Make it possible for self.forward to return a ScriptMethod (#19217) 2019-04-24 11:14:34 -07:00