Commit 98df96d
root
Update on "[JIT] add support for overloading functions"
This is a series of PRs that will allow us to support adding [padding to conv](#22484) and also reduce the friction of adding method overloads that was brought up in #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: int, y: int) -> int: ...
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 currently1 parent 397328b commit 98df96d
File tree
3 files changed
+50
-29
lines changed- test
- torch
- csrc/jit/script
- jit
3 files changed
+50
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12914 | 12914 | | |
12915 | 12915 | | |
12916 | 12916 | | |
12917 | | - | |
12918 | | - | |
| 12917 | + | |
| 12918 | + | |
| 12919 | + | |
| 12920 | + | |
| 12921 | + | |
| 12922 | + | |
| 12923 | + | |
| 12924 | + | |
| 12925 | + | |
| 12926 | + | |
| 12927 | + | |
| 12928 | + | |
| 12929 | + | |
| 12930 | + | |
| 12931 | + | |
| 12932 | + | |
| 12933 | + | |
| 12934 | + | |
| 12935 | + | |
| 12936 | + | |
| 12937 | + | |
| 12938 | + | |
| 12939 | + | |
| 12940 | + | |
12919 | 12941 | | |
12920 | 12942 | | |
12921 | 12943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | | - | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
| 1160 | + | |
1171 | 1161 | | |
1172 | 1162 | | |
1173 | 1163 | | |
1174 | 1164 | | |
1175 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
1176 | 1182 | | |
1177 | 1183 | | |
1178 | 1184 | | |
| |||
2088 | 2094 | | |
2089 | 2095 | | |
2090 | 2096 | | |
2091 | | - | |
2092 | | - | |
2093 | | - | |
2094 | | - | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
2095 | 2101 | | |
2096 | 2102 | | |
2097 | 2103 | | |
2098 | | - | |
| 2104 | + | |
2099 | 2105 | | |
2100 | 2106 | | |
2101 | 2107 | | |
| |||
2105 | 2111 | | |
2106 | 2112 | | |
2107 | 2113 | | |
2108 | | - | |
2109 | | - | |
2110 | | - | |
2111 | | - | |
2112 | | - | |
2113 | | - | |
2114 | | - | |
2115 | | - | |
2116 | | - | |
| 2114 | + | |
| 2115 | + | |
2117 | 2116 | | |
2118 | 2117 | | |
2119 | 2118 | | |
| |||
0 commit comments