Commit 225b5eb
authored
Add Python runtime end-to-end tests for XNNPACK on Linux (#18703)
## Summary
Add Python runtime end-to-end tests for the XNNPACK backend on Linux —
the first batch for the testing gap described in #11225.
This update keeps the Linux-only coverage under
`runtime/test/test_runtime_xnnpack.py` so the standard unittest jobs
collect it cleanly. Each test exports a small model with XNNPACK
delegation, saves it as `.pte`, loads it via
`executorch.runtime.Runtime`, and compares the output against PyTorch
eager mode.
**Models tested:**
- `test_add` — element-wise addition
- `test_linear` — single `Linear` layer (fp32)
- `test_conv2d_relu` — `Conv2d + ReLU`
- `test_mlp` — multi-layer perceptron (`Linear -> ReLU -> Linear`)
- `test_depthwise_separable_conv` — depthwise + pointwise conv
(MobileNet building block)
- `test_classifier_head` — `AdaptiveAvgPool2d + Flatten + Linear`
- `test_conv_bn` — `Conv2d + BatchNorm2d + ReLU` (**skipped**:
`FuseBatchNormPass` crashes; TODO to re-enable)
Part of #11225 (Linux XNNPACK)
<details>
<summary>Before</summary>
```text
$ pull / unittest-editable / linux / linux-job
==================================== ERRORS ====================================
_________ ERROR collecting test/end2end/test_python_runtime_xnnpack.py _________
ImportError while importing test module '/pytorch/executorch/test/end2end/test_python_runtime_xnnpack.py'.
Traceback:
E ModuleNotFoundError: No module named 'test.end2end'
$ lintrunner --skip MYPY test/end2end/test_python_runtime_xnnpack.py
Warning (UFMT) format
- from executorch.backends.xnnpack.partition.xnnpack_partitioner import (
- XnnpackPartitioner,
- )
+ from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
```
</details>
<details>
<summary>After</summary>
```text
$ lintrunner --skip MYPY runtime/test/test_runtime_xnnpack.py
ok No lint issues.
$ python -m py_compile runtime/test/test_runtime_xnnpack.py
```
</details>
## Test plan
- [x] Moved the Linux-only XNNPACK runtime tests to
`runtime/test/test_runtime_xnnpack.py`
- [x] Added `runtime/test/TARGETS` coverage for the new Python runtime
test
- [x] `lintrunner --skip MYPY runtime/test/test_runtime_xnnpack.py`
- [x] `python -m py_compile runtime/test/test_runtime_xnnpack.py`
- [x] `test_conv_bn` remains skipped with TODO — `FuseBatchNormPass`
still has a known bug on `Sequential(Conv2d, BN)` export
- [ ] Full `python -m pytest runtime/test/test_runtime_xnnpack.py -v`
Local blocker: this workstation does not currently have a fully
provisioned ExecuTorch runtime test environment; upstream CI remains the
source of truth for this suite.
cc @GregoryComer @digantdesai @cbilgin @jathu @larryliu0820
> This PR was authored with the help of Claude.
---------
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>1 parent 2eff4f4 commit 225b5eb
2 files changed
Lines changed: 192 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 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 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
0 commit comments