Commit 55cea61
authored
[LAYOUTS] Fix memdesc_subviews when we don't slice along the swizzling pattern (#7480)
The previous way of handling `memdesc_subviews` in the context of
LinearLayouts was wrong.
Consider a shmem layout of 1D of a shmem with `64` elements of the form
```
A = {offset = [1, 2, 5, 10, 32, 16], {dim0=64}}
```
If we take a `subview` of `A` that yields a `tesnor<32xtype>` , we
should get the layout
```
A_sub = {offset = [1, 2, 5, 10, 0, 16], {dim0=32}}
```
which maps the full shared memory onto a tensor with `32` elements. When
we take A_sub^{-1}B for `B` a distributed layout on a tensor of `32`
elements to load this layout it will give us the correct mapping on the
offsets, as expected.
This PR fixes this at large by passing the initial shape of the shared
memory, and then resizing in the creation of the `LinearLayout` the
layout. This shows what we already realised at an IR level, that
subviews effectively depend not only on the shape of the layout, but
also the initial shape of the shared_memory.
This PR also removes a number of hacks that worked around the issue
above
To do this, we generalise `lstsq` to compute a left inverse of A in when
`A` is injective but its image is not a subset of that of `B`.
The case where we split along a dimension that's within the swizzling
pattern will be fixed in a follow-up PR.1 parent 322cd5b commit 55cea61
File tree
17 files changed
+183
-114
lines changed- include/triton
- Dialect/TritonGPU/IR
- Tools
- lib
- Conversion/TritonGPUToLLVM
- Dialect/TritonGPU
- IR
- Transforms
- Pipeliner
- Tools
- python/test/unit/language
- test/Conversion
- third_party/amd/lib/TritonAMDGPUTransforms
- unittest/Dialect/TritonGPU
17 files changed
+183
-114
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
| 429 | + | |
429 | 430 | | |
430 | 431 | | |
431 | | - | |
| 432 | + | |
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
378 | 380 | | |
379 | 381 | | |
380 | 382 | | |
381 | | - | |
| 383 | + | |
382 | 384 | | |
383 | 385 | | |
384 | 386 | | |
| |||
503 | 505 | | |
504 | 506 | | |
505 | 507 | | |
506 | | - | |
| 508 | + | |
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
| |||
659 | 661 | | |
660 | 662 | | |
661 | 663 | | |
662 | | - | |
663 | | - | |
664 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
665 | 667 | | |
666 | 668 | | |
667 | 669 | | |
| |||
677 | 679 | | |
678 | 680 | | |
679 | 681 | | |
680 | | - | |
| 682 | + | |
681 | 683 | | |
682 | 684 | | |
683 | 685 | | |
| |||
859 | 861 | | |
860 | 862 | | |
861 | 863 | | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
867 | 871 | | |
868 | 872 | | |
869 | 873 | | |
| |||
1473 | 1477 | | |
1474 | 1478 | | |
1475 | 1479 | | |
1476 | | - | |
| 1480 | + | |
1477 | 1481 | | |
1478 | 1482 | | |
1479 | 1483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
475 | 474 | | |
476 | 475 | | |
477 | | - | |
478 | | - | |
479 | 476 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
| 477 | + | |
486 | 478 | | |
487 | 479 | | |
488 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
489 | 484 | | |
490 | 485 | | |
491 | 486 | | |
492 | 487 | | |
493 | 488 | | |
494 | 489 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
| 490 | + | |
| 491 | + | |
503 | 492 | | |
504 | 493 | | |
505 | 494 | | |
| |||
517 | 506 | | |
518 | 507 | | |
519 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
520 | 514 | | |
521 | 515 | | |
522 | 516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | | - | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
2369 | 2372 | | |
2370 | 2373 | | |
2371 | 2374 | | |
2372 | | - | |
| 2375 | + | |
2373 | 2376 | | |
2374 | 2377 | | |
2375 | 2378 | | |
| |||
2491 | 2494 | | |
2492 | 2495 | | |
2493 | 2496 | | |
2494 | | - | |
2495 | | - | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
2496 | 2500 | | |
2497 | 2501 | | |
2498 | 2502 | | |
| |||
2774 | 2778 | | |
2775 | 2779 | | |
2776 | 2780 | | |
2777 | | - | |
| 2781 | + | |
2778 | 2782 | | |
2779 | 2783 | | |
2780 | 2784 | | |
| |||
2810 | 2814 | | |
2811 | 2815 | | |
2812 | 2816 | | |
2813 | | - | |
| 2817 | + | |
2814 | 2818 | | |
2815 | 2819 | | |
2816 | 2820 | | |
| |||
2866 | 2870 | | |
2867 | 2871 | | |
2868 | 2872 | | |
2869 | | - | |
| 2873 | + | |
2870 | 2874 | | |
2871 | 2875 | | |
2872 | 2876 | | |
| |||
2935 | 2939 | | |
2936 | 2940 | | |
2937 | 2941 | | |
2938 | | - | |
| 2942 | + | |
2939 | 2943 | | |
2940 | 2944 | | |
2941 | 2945 | | |
| |||
3042 | 3046 | | |
3043 | 3047 | | |
3044 | 3048 | | |
3045 | | - | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
3046 | 3052 | | |
3047 | 3053 | | |
3048 | 3054 | | |
3049 | 3055 | | |
3050 | 3056 | | |
3051 | 3057 | | |
3052 | 3058 | | |
3053 | | - | |
3054 | 3059 | | |
3055 | 3060 | | |
3056 | 3061 | | |
| |||
3463 | 3468 | | |
3464 | 3469 | | |
3465 | 3470 | | |
3466 | | - | |
3467 | | - | |
| 3471 | + | |
| 3472 | + | |
3468 | 3473 | | |
3469 | 3474 | | |
3470 | 3475 | | |
| |||
0 commit comments