|
| 1 | +// RUN: triton-opt -split-input-file %s --convert-triton-amdgpu-to-llvm='arch=gfx942' -verify-diagnostics |
| 2 | + |
| 3 | +// Invalid size |
| 4 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 5 | +tt.func @invalid_size_input(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 6 | + // expected-error @+1 {{sizes [256, 2] must be a multiple of shapePerCTATile [256, 16]}} |
| 7 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x2xi32, #blocked1> |
| 8 | + tt.return |
| 9 | +} |
| 10 | + |
| 11 | +// ----- |
| 12 | + |
| 13 | +// Invalid zero source dimension |
| 14 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 15 | +tt.func @invalid_size_input(%arg0: tensor<256x0xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 16 | + // expected-error @+1 {{source tensor dimension size zero at dimension 1}} |
| 17 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x0xi32, #blocked1> to tensor<256x16xi32, #blocked1> |
| 18 | + tt.return |
| 19 | +} |
| 20 | + |
| 21 | +// ----- |
| 22 | + |
| 23 | +// Invalid zero result dimension |
| 24 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 25 | +tt.func @invalid_size_input(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 26 | + // expected-error @+1 {{result tensor dimension size zero at dimension 1}} |
| 27 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x0xi32, #blocked1> |
| 28 | + tt.return |
| 29 | +} |
| 30 | + |
| 31 | +// ----- |
| 32 | + |
| 33 | +// Invalid offset, not multiple of shapePerTile |
| 34 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 35 | +tt.func @invalid_offset_input(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 36 | + // expected-error @+1 {{offset [0, 5] must be a multiple of shapePerCTATile [256, 16]}} |
| 37 | + %1 = amdgpu.extract_slice %arg0 [0,5] : tensor<256x128xi32, #blocked1> to tensor<256x16xi32, #blocked1> |
| 38 | + tt.return |
| 39 | +} |
| 40 | + |
| 41 | +// ----- |
| 42 | + |
| 43 | +// Invalid offset, out of bounds for dimension |
| 44 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 45 | +tt.func @invalid_offset_input(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 46 | + // expected-error @+1 {{invalid offset 128 at dimension 1}} |
| 47 | + %1 = amdgpu.extract_slice %arg0 [0,128] : tensor<256x128xi32, #blocked1> to tensor<256x16xi32, #blocked1> |
| 48 | + tt.return |
| 49 | +} |
| 50 | + |
| 51 | +// ----- |
| 52 | + |
| 53 | +// Invalid result layout |
| 54 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 55 | +#blocked2 = #triton_gpu.blocked<{sizePerThread = [4, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 56 | +tt.func @invalid_result_layout(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 57 | + // expected-error @+1 {{result layout must match source layout}} |
| 58 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x16xi32, #blocked2> |
| 59 | + tt.return |
| 60 | +} |
| 61 | + |
| 62 | +// ----- |
| 63 | + |
| 64 | +// Invalid result element type |
| 65 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 66 | +tt.func @invalid_result_element_type(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 67 | + // expected-error @+1 {{result element type must match source element type}} |
| 68 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x16xi64, #blocked1> |
| 69 | + tt.return |
| 70 | +} |
| 71 | + |
| 72 | +// ----- |
| 73 | + |
| 74 | +// Invalid result rank |
| 75 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 76 | +tt.func @invalid_result_rank(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 77 | + // expected-error @+1 {{result rank must be equal to source rank}} |
| 78 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x16x2xi32, #blocked1> |
| 79 | + tt.return |
| 80 | +} |
| 81 | + |
| 82 | +// ----- |
| 83 | + |
| 84 | +// Invalid result shape |
| 85 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 86 | +tt.func @invalid_result_rank(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 87 | + // expected-error @+1 {{result shape cannot be larger than input shape at dimension 1}} |
| 88 | + %1 = amdgpu.extract_slice %arg0 [0,0] : tensor<256x128xi32, #blocked1> to tensor<256x256xi32, #blocked1> |
| 89 | + tt.return |
| 90 | +} |
| 91 | + |
| 92 | +// ----- |
| 93 | + |
| 94 | +// Invalid rank |
| 95 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 96 | +tt.func @invalid_rank(%arg0: tensor<256x128x2xi32, #blocked1> {tt.divisibility = 16 : i32}) { |
| 97 | + // expected-error @+1 {{currently only 2D tensors are supported}} |
| 98 | + %1 = amdgpu.extract_slice %arg0 [0,0,0] : tensor<256x128x2xi32, #blocked1> to tensor<256x16x2xi32, #blocked1> |
| 99 | + tt.return |
| 100 | +} |
| 101 | + |
| 102 | +// ----- |
| 103 | + |
| 104 | +// Invalid non static offset |
| 105 | +#blocked1 = #triton_gpu.blocked<{sizePerThread = [8, 1], threadsPerWarp = [4, 16], warpsPerCTA = [8, 1], order = [1, 0], CTAsPerCGA = [1, 1], CTASplitNum = [1, 1], CTAOrder = [0, 1]}> |
| 106 | +tt.func @invalid_non_static_offset(%arg0: tensor<256x128xi32, #blocked1> {tt.divisibility = 16 : i32}, %arg1: i32) { |
| 107 | + // expected-error @+2 {{expected ']'}} |
| 108 | + // expected-error @+1 {{expected integer value}} |
| 109 | + %2 = amdgpu.extract_slice %arg0 [%arg1, 0] : tensor<256x128xi32, #blocked1> to tensor<256x16xi32, #blocked1> |
| 110 | + tt.return |
| 111 | +} |
0 commit comments