Commit 06f10b9
[cortex_m] Fix linear weight layout: transpose in AOT pass, align meta/ref impl (pytorch#16782)
### Summary:
The linear path in ConvertToCortexMPass was not transposing weights
unlike
conv2d, causing inconsistency with the C++ runtime which expects weights
in
[in_features, out_features] format per CMSIS-NN.
Changes:
- convert_to_cortex_m_pass.py: Transpose linear weights [out, in] ->
[in, out]
- operators.py: Update meta to use weights.shape[1] for output dimension
- operators.py: Remove .T from ref impl (weights pre-transposed by pass)
Fixes MV2 output shape mismatch: [1, 1280] -> [1, 1000]
MV2 on Corstone-300/E8 with CMSIS-NN kernels
This fix ensures the AOT-compiled .pte file has correctly shaped output
tensors for any model using quantized_linear (MV2, ResNet, MV3, etc.).
### Test plan
Run MV2 lowered to CMSIS-NN ops on E8 alif board
Co-authored-by: Github Executorch <github_executorch@arm.com>1 parent 3ddb86c commit 06f10b9
2 files changed
Lines changed: 24 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
| 389 | + | |
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
399 | | - | |
| 399 | + | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
110 | 115 | | |
111 | 116 | | |
112 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
113 | 122 | | |
114 | | - | |
| 123 | + | |
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
| |||
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
125 | 142 | | |
126 | 143 | | |
127 | | - | |
| 144 | + | |
128 | 145 | | |
129 | 146 | | |
130 | 147 | | |
| |||
0 commit comments