Commit 315065a
Automerge: [mlir][affine] Modify assertion into a user visible diagnostic (#136474)
Fixes #122227
The loop’s induction variable (%i) is used to compute two different
indices via affine.apply.
And the Vectorization Assumption is Violated i.e, Each vectorized loop
should contribute at most one non-invariant index.
**Minimal example crashing :**
```
#map = affine_map<(d0)[s0] -> (d0 mod s0)>
#map1 = affine_map<(d0)[s0] -> (d0 floordiv s0)>
func.func @single_loop_unrolling_2D_access_pattern(%arg0: index) -> memref<2x2xf32> {
%c2 = arith.constant 2 : index
%cst = arith.constant 1.0 : f32
%alloc = memref.alloc() : memref<2x2xf32>
affine.for %i = 0 to 4 {
%row = affine.apply #map1(%i)[%c2]
%col = affine.apply #map(%i)[%c2]
affine.store %cst, %alloc[%row, %col] : memref<2x2xf32>
}
return %alloc : memref<2x2xf32>
}
```
The single loop %i contributes two indices (%row and %col) to the 2D
memref access.
The permutation map expects one index per vectorized loop dimension, but
here one loop (%i) maps to two indices (dim=0 and dim=1).
The code detects this when trying to assign the second index (dim=1) to
the same vector dimension (perm[0]).File tree
2 files changed
+63
-0
lines changed- mlir
- lib/Dialect/Affine/Transforms
- test/Dialect/Affine/SuperVectorize
2 files changed
+63
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1185 | 1185 | | |
1186 | 1186 | | |
1187 | 1187 | | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1188 | 1214 | | |
1189 | 1215 | | |
1190 | 1216 | | |
| |||
1217 | 1243 | | |
1218 | 1244 | | |
1219 | 1245 | | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1220 | 1249 | | |
1221 | 1250 | | |
1222 | 1251 | | |
| |||
1262 | 1291 | | |
1263 | 1292 | | |
1264 | 1293 | | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1265 | 1297 | | |
1266 | 1298 | | |
1267 | 1299 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 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 | + | |
0 commit comments