pytorch
451fc51d - add support for overloading functions (#23886)

Commit
5 years ago
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
Author
Elias Ellison
Parents
Loading