Commit 08fa1e0
[Codegen] linalg.generic with dynamic reduction dim: use
### Motivation and next steps:
We want to deprecate the WarpReduction pipeline. WarpReduction is not
used in e2e numerical tests (complete removal, and CI runs all e2e). I intend to get
all lit tests that use WarpReduction working through VectorDistribution,
and then reconsider total removal
### How dynamic reduction size is supported in this PR:
There are places where `LLVMGPUVectorDistribution` selection fails
because the reduction size is dynamic. This PR instead chooses a large
reduction size to target for configuration.
### Testing:
There is a numerical test in CI exercising this path.
I also performed numerical testing locally using
```mlir
#map = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>
#map1 = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>
func.func @bmm(%arg0: tensor<32x1x?xf16>, %arg1: tensor<32x?x128xf16>) -> tensor<32x1x128xf16> {
%cst = arith.constant 0.000000e+00 : f16
%0 = tensor.empty() : tensor<32x1x128xf16>
%1 = linalg.fill ins(%cst : f16) outs(%0 : tensor<32x1x128xf16>) -> tensor<32x1x128xf16>
%2 = linalg.generic {indexing_maps = [#map, #map1, #map2], iterator_types = ["parallel", "parallel", "parallel", "reduction"]} ins(%arg0, %arg1 : tensor<32x1x?xf16>, tensor<32x?x128xf16>) outs(%1 : tensor<32x1x128xf16>) {
^bb0(%in: f16, %in_0: f16, %out: f16):
%3 = arith.mulf %in, %in_0 : f16
%4 = arith.addf %out, %3 : f16
linalg.yield %4 : f16
} -> tensor<32x1x128xf16>
return %2 : tensor<32x1x128xf16>
}
```
Run with various K values in script
```bash
${IREE_BUILD}/tools/iree-compile --iree-hal-target-device=hip --iree-hip-target=gfx942 -o foo.vmfb
export K_VALUES=(1 17 64 1000 9999 99999)
for K in "${K_VALUES[@]}"; do
echo "Running with K=${K}"
${IREE_BUILD}/tools/iree-run-module \
--device=hip \
--module=foo.vmfb \
--input=32x1x${K}xf16=1 \
--input=32x${K}x128xf16=1 \
--expected_output=32x1x128xf16=${K}
done
```
And verified all correct.
---------
Signed-off-by: James Newling <[email protected]>
Signed-off-by: keshavvinayak01 <[email protected]>LLVMGPUVectorDistribution. (iree-org#21430)1 parent ec53dbe commit 08fa1e0
File tree
2 files changed
+64
-16
lines changed- compiler/src/iree/compiler/Codegen/LLVMGPU
- test
2 files changed
+64
-16
lines changedLines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
143 | 147 | | |
144 | 148 | | |
145 | 149 | | |
| |||
527 | 531 | | |
528 | 532 | | |
529 | 533 | | |
| 534 | + | |
530 | 535 | | |
531 | | - | |
| 536 | + | |
532 | 537 | | |
533 | 538 | | |
534 | 539 | | |
| |||
834 | 839 | | |
835 | 840 | | |
836 | 841 | | |
| 842 | + | |
837 | 843 | | |
838 | | - | |
| 844 | + | |
839 | 845 | | |
840 | 846 | | |
841 | | - | |
| 847 | + | |
842 | 848 | | |
843 | 849 | | |
844 | | - | |
| 850 | + | |
845 | 851 | | |
846 | 852 | | |
847 | 853 | | |
848 | 854 | | |
849 | 855 | | |
850 | | - | |
| 856 | + | |
851 | 857 | | |
852 | 858 | | |
853 | 859 | | |
| |||
870 | 876 | | |
871 | 877 | | |
872 | 878 | | |
873 | | - | |
| 879 | + | |
874 | 880 | | |
875 | 881 | | |
876 | 882 | | |
| |||
2881 | 2887 | | |
2882 | 2888 | | |
2883 | 2889 | | |
2884 | | - | |
2885 | 2890 | | |
2886 | 2891 | | |
2887 | 2892 | | |
| |||
Lines changed: 52 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 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 | + | |
4 | 37 | | |
5 | 38 | | |
6 | 39 | | |
7 | 40 | | |
8 | 41 | | |
9 | | - | |
10 | | - | |
| 42 | + | |
11 | 43 | | |
12 | 44 | | |
13 | 45 | | |
| |||
28 | 60 | | |
29 | 61 | | |
30 | 62 | | |
31 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
32 | 69 | | |
33 | 70 | | |
34 | 71 | | |
35 | 72 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
42 | 85 | | |
43 | 86 | | |
44 | 87 | | |
| |||
0 commit comments