|
| 1 | +// RUN: triton-opt -split-input-file %s --convert-triton-amdgpu-to-llvm='arch=gfx942' -verify-diagnostics |
| 2 | + |
| 3 | + |
| 4 | +// Invalid ranks |
| 5 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 6 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 7 | + tt.func @invalid_concat( |
| 8 | + %arg0: tensor<32x64xf32, #blocked>, |
| 9 | + %arg1: tensor<32x64xf32, #blocked>, |
| 10 | + %arg2: tensor<32x64xf32, #blocked>, |
| 11 | + %arg3: tensor<32x64xf32, #blocked>, |
| 12 | + %arg4: tensor<32x64xf32, #blocked>, |
| 13 | + %arg5: tensor<32x64xf32, #blocked>, |
| 14 | + %arg6: tensor<32x64xf32, #blocked>, |
| 15 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 16 | + |
| 17 | + // expected-error @+1 {{Source and destination tensors must have the same rank.}} |
| 18 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 19 | + tensor<32x64xf32, #blocked>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<256xf32, #blocked> |
| 20 | + tt.return |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +// ----- |
| 25 | + |
| 26 | +// Invalid shapes 1 |
| 27 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 28 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 29 | + tt.func @invalid_concat( |
| 30 | + %arg0: tensor<32x64xf32, #blocked>, |
| 31 | + %arg1: tensor<32x64xf32, #blocked>, |
| 32 | + %arg2: tensor<32x64xf32, #blocked>, |
| 33 | + %arg3: tensor<32x64xf32, #blocked>, |
| 34 | + %arg4: tensor<32x64xf32, #blocked>, |
| 35 | + %arg5: tensor<32x64xf32, #blocked>, |
| 36 | + %arg6: tensor<32x64xf32, #blocked>, |
| 37 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 38 | + |
| 39 | + // expected-error @+1 {{Source and destination tensor shapes don't match.}} |
| 40 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 41 | + tensor<32x64xf32, #blocked>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<257x128xf32, #blocked> |
| 42 | + tt.return |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +// ----- |
| 47 | + |
| 48 | +// Invalid shapes 2 |
| 49 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 50 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 51 | + tt.func @invalid_concat( |
| 52 | + %arg0: tensor<32x64xf32, #blocked>, |
| 53 | + %arg1: tensor<32x64xf32, #blocked>, |
| 54 | + %arg2: tensor<32x64xf32, #blocked>, |
| 55 | + %arg3: tensor<32x64xf32, #blocked>, |
| 56 | + %arg4: tensor<32x64xf32, #blocked>, |
| 57 | + %arg5: tensor<32x64xf32, #blocked>, |
| 58 | + %arg6: tensor<32x64xf32, #blocked>, |
| 59 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 60 | + |
| 61 | + // expected-error @+1 {{Number of source tiles (8) doesn't match required count (16).}} |
| 62 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 63 | + tensor<32x64xf32, #blocked>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<256x128xf32, #blocked> |
| 64 | + tt.return |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | + |
| 69 | +// ----- |
| 70 | + |
| 71 | +// Invalid shapes 3 |
| 72 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 73 | +#blocked1 = #ttg.blocked<{sizePerThread = [1, 4], threadsPerWarp = [4, 16], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 74 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 75 | + tt.func @invalid_concat( |
| 76 | + %arg0: tensor<32x64xf32, #blocked>, |
| 77 | + %arg1: tensor<32x64xf32, #blocked>, |
| 78 | + %arg2: tensor<32x64xf32, #blocked>, |
| 79 | + %arg3: tensor<32x64xf32, #blocked>, |
| 80 | + %arg4: tensor<32x64xf32, #blocked>, |
| 81 | + %arg5: tensor<32x64xf32, #blocked>, |
| 82 | + %arg6: tensor<32x64xf32, #blocked>, |
| 83 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 84 | + |
| 85 | + // expected-error @+1 {{CTA tile shapes must match between source and destination tensors.}} |
| 86 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 87 | + tensor<32x64xf32, #blocked>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<128x128xf32, #blocked1> |
| 88 | + tt.return |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +// ----- |
| 93 | + |
| 94 | +// Different types |
| 95 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 96 | +#blocked1 = #ttg.blocked<{sizePerThread = [1, 4], threadsPerWarp = [4, 16], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 97 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 98 | + tt.func @invalid_concat( |
| 99 | + %arg0: tensor<32x64xf32, #blocked1>, |
| 100 | + %arg1: tensor<32x64xf32, #blocked>, |
| 101 | + %arg2: tensor<32x64xf32, #blocked>, |
| 102 | + %arg3: tensor<32x64xf32, #blocked>, |
| 103 | + %arg4: tensor<32x64xf32, #blocked>, |
| 104 | + %arg5: tensor<32x64xf32, #blocked>, |
| 105 | + %arg6: tensor<32x64xf32, #blocked>, |
| 106 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 107 | + |
| 108 | + // expected-error @+1 {{All sources must have identical tensor types.}} |
| 109 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 110 | + tensor<32x64xf32, #blocked1>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<128x128xf32, #blocked> |
| 111 | + tt.return |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +// ----- |
| 116 | + |
| 117 | +// Invalid element types |
| 118 | +#blocked = #ttg.blocked<{sizePerThread = [1, 8], threadsPerWarp = [8, 8], warpsPerCTA = [4, 1], order = [1, 0]}> |
| 119 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 120 | + tt.func @invalid_concat( |
| 121 | + %arg0: tensor<32x64xf32, #blocked>, |
| 122 | + %arg1: tensor<32x64xf32, #blocked>, |
| 123 | + %arg2: tensor<32x64xf32, #blocked>, |
| 124 | + %arg3: tensor<32x64xf32, #blocked>, |
| 125 | + %arg4: tensor<32x64xf32, #blocked>, |
| 126 | + %arg5: tensor<32x64xf32, #blocked>, |
| 127 | + %arg6: tensor<32x64xf32, #blocked>, |
| 128 | + %arg7: tensor<32x64xf32, #blocked>) { |
| 129 | + |
| 130 | + // expected-error @+1 {{Element types of sources and destination must match.}} |
| 131 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7: |
| 132 | + tensor<32x64xf32, #blocked>,tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked>, tensor<32x64xf32, #blocked> -> tensor<256x64xf16, #blocked> |
| 133 | + tt.return |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | + |
| 138 | +// ----- |
| 139 | + |
| 140 | +// Different layouts 1 |
| 141 | +#src_layout = #ttg.linear<{register=[[0, 1], [0, 2], [0, 8], [0, 16], [0, 64], [64, 0]], lane=[[1, 0], [2, 0], [4, 0], [8, 0], [16, 0], [0, 4]], warp=[[0, 32], [32, 0]], block=[]}> |
| 142 | +#dst_layout = #ttg.linear<{register=[[0, 1], [0, 2], [0, 8], [0, 16], [0, 64], [0, 128], [64, 0], [128, 0]], lane=[[1, 0], [2, 0], [4, 0], [8, 0], [16, 0], [0, 4], [0, 0]], warp=[[0, 32], [32, 0]], block=[]}> |
| 143 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 144 | + tt.func @invalid_concat( |
| 145 | + %arg0: tensor<128x128xf32, #src_layout>, |
| 146 | + %arg1: tensor<128x128xf32, #src_layout>, |
| 147 | + %arg2: tensor<128x128xf32, #src_layout>, |
| 148 | + %arg3: tensor<128x128xf32, #src_layout>) { |
| 149 | + |
| 150 | + // expected-error @+1 {{Lane and warp dim basis must match between source and destination layout.}} |
| 151 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3: |
| 152 | + tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout> -> tensor<256x256xf32, #dst_layout> |
| 153 | + tt.return |
| 154 | + } |
| 155 | +} |
| 156 | + |
| 157 | +// ----- |
| 158 | + |
| 159 | +// Different layouts 2 |
| 160 | +#src_layout = #ttg.linear<{register=[[0, 1], [0, 2], [0, 8], [0, 16], [0, 64], [64, 0]], lane=[[1, 0], [2, 0], [4, 0], [8, 0], [16, 0], [0, 4]], warp=[[0, 32], [32, 0]], block=[]}> |
| 161 | +#dst_layout = #ttg.linear<{register=[[0, 0], [0, 1], [0, 2], [0, 8], [0, 16], [0, 64], [0, 128], [64, 0], [128, 0]], lane=[[1, 0], [2, 0], [4, 0], [8, 0], [16, 0], [0, 4]], warp=[[0, 32], [32, 0]], block=[]}> |
| 162 | +module attributes {"ttg.compute-capability" = 0 : i32, "ttg.num-ctas" = 1 : i32, "ttg.num-warps" = 4 : i32, "ttg.threads-per-warp" = 64 : i32} { |
| 163 | + tt.func @invalid_concat( |
| 164 | + %arg0: tensor<128x128xf32, #src_layout>, |
| 165 | + %arg1: tensor<128x128xf32, #src_layout>, |
| 166 | + %arg2: tensor<128x128xf32, #src_layout>, |
| 167 | + %arg3: tensor<128x128xf32, #src_layout>) { |
| 168 | + |
| 169 | + // expected-error @+1 {{Register basis must match on a CTA tile between source and destination.}} |
| 170 | + %1 = amdgpu.concat %arg0, %arg1, %arg2, %arg3: |
| 171 | + tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout>, tensor<128x128xf32, #src_layout> -> tensor<256x256xf32, #dst_layout> |
| 172 | + tt.return |
| 173 | + } |
| 174 | +} |
0 commit comments