Commit 35cbab6
committed
Apply alpha scale factor in torch add/sub converters
`aten::add(self, other, alpha)` and `aten::sub(self, other, alpha)`
compute `self ± alpha * other`, but the converters previously raised
on positional `alpha != 1` and silently ignored kwarg `alpha` from the
`torch.export` path. As a result, `torch.sub(x, y, alpha=5)` produced
`x - y` instead of `x - 5*y` (issue #2573).
Look up `alpha` from positional inputs (TorchScript) and kwinputs
(torch.export), and apply `y = y * alpha` before the add/sub when
`alpha != 1`, mirroring the existing `addmm` handler. The alpha=1 fast
path is unchanged.
Fixes #2573.1 parent e95804f commit 35cbab6
2 files changed
Lines changed: 45 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | 1066 | | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
1072 | 1076 | | |
1073 | 1077 | | |
1074 | 1078 | | |
| |||
2074 | 2078 | | |
2075 | 2079 | | |
2076 | 2080 | | |
2077 | | - | |
2078 | | - | |
2079 | | - | |
2080 | | - | |
2081 | | - | |
2082 | | - | |
2083 | | - | |
2084 | | - | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
2085 | 2090 | | |
2086 | 2091 | | |
2087 | 2092 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4289 | 4289 | | |
4290 | 4290 | | |
4291 | 4291 | | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
4292 | 4319 | | |
4293 | 4320 | | |
4294 | 4321 | | |
| |||
0 commit comments