Commit 221ae39
Fix DMA offset for transposed memrefs and simplify test 55 (#1530)
* Fix DMA offset for transposed memrefs and simplify test 55 to 3 herds
Fix a bug in extractOperandsFromReinterpretCast where a single flat
offset from a reinterpret_cast was placed in the wrong DMA dimension.
For transposed memrefs (e.g. strides [1, 504]), the old code padded
zeros at the front, assigning the flat offset to the highest-stride
dimension. This caused the offset to be multiplied by the wrong stride,
producing out-of-bounds reads and NaN results for multi-launch-tile
kernels.
The fix finds the stride-1 dimension and places the flat offset there,
so the offset is multiplied by 1 (correct) rather than by the column
stride.
Also simplify test 55 from a 4-herd pattern to a 3-herd pattern by
merging the truncf herd into the compute herd. Testing on NPU1 hardware
confirms the combined truncf+matmul pattern works correctly on aie2,
making the separate truncf herd unnecessary.
Add FileCheck unit tests for standalone reinterpret_cast with transposed
and normal layouts, including a constant-offset variant.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix stride-1 search direction to avoid NPU2 regression
Search backward for the stride-1 dimension so that ambiguous cases
(e.g., strides=[1,1] in test_40 triton_vec_add) default to the last
dimension, matching the original prepend-zeros behavior. Forward
search picked dim 0 for strides=[1,1], which changed the intermediate
DMA dimension structure and caused all-zeros output on NPU2.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent f876db8 commit 221ae39
4 files changed
Lines changed: 116 additions & 57 deletions
File tree
- mlir
- lib/Conversion
- test/Conversion/ConvertToAIR
- test/xrt/55_matmul_padding_bf16_npu1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 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 | + | |
105 | 132 | | |
106 | 133 | | |
107 | 134 | | |
| |||
Lines changed: 60 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
| 10 | + | |
12 | 11 | | |
13 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
45 | | - | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
83 | | - | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | | - | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
274 | 276 | | |
275 | 277 | | |
276 | 278 | | |
277 | | - | |
| 279 | + | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
| |||
288 | 290 | | |
289 | 291 | | |
290 | 292 | | |
291 | | - | |
| 293 | + | |
292 | 294 | | |
293 | 295 | | |
294 | 296 | | |
| |||
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
348 | | - | |
| 350 | + | |
349 | 351 | | |
350 | 352 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | 353 | | |
380 | 354 | | |
381 | 355 | | |
| |||
389 | 363 | | |
390 | 364 | | |
391 | 365 | | |
392 | | - | |
| 366 | + | |
393 | 367 | | |
394 | 368 | | |
395 | 369 | | |
396 | | - | |
| 370 | + | |
397 | 371 | | |
398 | 372 | | |
399 | 373 | | |
| |||
541 | 515 | | |
542 | 516 | | |
543 | 517 | | |
544 | | - | |
545 | | - | |
546 | | - | |
| 518 | + | |
| 519 | + | |
547 | 520 | | |
548 | 521 | | |
549 | 522 | | |
| |||
584 | 557 | | |
585 | 558 | | |
586 | 559 | | |
587 | | - | |
| 560 | + | |
588 | 561 | | |
589 | 562 | | |
590 | | - | |
| 563 | + | |
591 | 564 | | |
592 | 565 | | |
593 | 566 | | |
| |||
605 | 578 | | |
606 | 579 | | |
607 | 580 | | |
608 | | - | |
| 581 | + | |
609 | 582 | | |
610 | 583 | | |
611 | | - | |
612 | | - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
613 | 587 | | |
614 | 588 | | |
615 | 589 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments