Commit dc35060
authored
### Summary
Sub node of XNNPack backend doesn't consider alpha value, this fixes the
bug by falling back to portable ops and avoid partitioning the node.
(fixes: #11684)
### Test plan
```
$ python -m unittest backends/xnnpack/test/ops/test_sub.py
Ran 3 tests in 7.262s
OK
```
### Model run
```
import torch
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
class Model(torch.nn.Module):
def forward(self, x, y):
return torch.sub(x, y, alpha=10)
inputs = (
torch.randn(10),
torch.randn(10),
)
model = Model()
ep = torch.export.export(model, inputs)
lowered = to_edge_transform_and_lower(
ep,
partitioner=[XnnpackPartitioner()],
).to_executorch()
et_model = _load_for_executorch_from_buffer(lowered.buffer)
eager_output = model(*inputs)
et_output = et_model([*inputs])[0]
tolerance=1e-5
if torch.allclose(eager_output, et_output, atol=tolerance):
print("Outputs are within the tolerance level.")
else:
print("Outputs differ beyond the tolerance level.")
```
### output
```
Outputs are within the tolerance level.
```
1 parent 8e49e01 commit dc35060
File tree
2 files changed
+36
-0
lines changed- backends/xnnpack
- partition/config
- test/ops
2 files changed
+36
-0
lines changedLines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
523 | 524 | | |
524 | 525 | | |
525 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
526 | 538 | | |
527 | 539 | | |
528 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
0 commit comments