brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · dce4a41 Raw
158 lines · plain
1// RUN: mlir-opt %s -transform-interpreter -split-input-file -verify-diagnostics2 3func.func @set_desc_layout(%arg0: memref<4096x4096xf16>) {4  %c32 = arith.constant 32 : index // expected-note {{target op}}5  return6}7 8module attributes {transform.with_named_sequence} {9  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {10    %0 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!transform.any_op) -> !transform.any_op11    // expected-error@below {{Expected a xegpu.create_nd_desc op, but got: arith.constant}}12    %1 = transform.xegpu.set_desc_layout %0 sg_layout = [8, 4] sg_data = [32, 32] : (!transform.any_op) -> !transform.any_op13    transform.yield14  }15}16 17// -----18 19// CHECK-LABEL: @set_op_layout_attr_bad_result_index20func.func @set_op_layout_attr_bad_result_index(%arg0: memref<4096x4096xf16>) {21  %0 = xegpu.create_nd_tdesc %arg0 : memref<4096x4096xf16> -> !xegpu.tensor_desc<256x32xf16>22  %1 = xegpu.load_nd %0[0, 0]  : !xegpu.tensor_desc<256x32xf16> -> vector<256x32xf16>23  %2 = arith.extf %1 : vector<256x32xf16> to vector<256x32xf32>24  return25}26 27module attributes {transform.with_named_sequence} {28  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {29    %0 = transform.structured.match ops{["arith.extf"]} in %arg1 : (!transform.any_op) -> !transform.any_op30    // expected-error@below {{Index exceeds the number of op results}}31    transform.xegpu.set_op_layout_attr %0 result index = 1 sg_layout = [8, 4] sg_data = [32, 64] : !transform.any_op32    transform.yield33  }34}35 36// -----37 38// CHECK-LABEL: @set_op_layout_attr_bad_operand_index39func.func @set_op_layout_attr_bad_operand_index(%arg0: memref<4096x4096xf16>) {40  %0 = xegpu.create_nd_tdesc %arg0 : memref<4096x4096xf16> -> !xegpu.tensor_desc<256x32xf16>41  %1 = xegpu.load_nd %0[0, 0]  : !xegpu.tensor_desc<256x32xf16> -> vector<256x32xf16>42  %2 = arith.extf %1 : vector<256x32xf16> to vector<256x32xf32>43  return44}45 46module attributes {transform.with_named_sequence} {47  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {48    %0 = transform.structured.match ops{["arith.extf"]} in %arg1 : (!transform.any_op) -> !transform.any_op49    // expected-error@below {{Index exceeds the number of op operands}}50    transform.xegpu.set_op_layout_attr %0 index = 1 sg_layout = [8, 4] sg_data = [32, 64] : !transform.any_op51    transform.yield52  }53}54 55// -----56 57// CHECK-LABEL: @set_op_layout_attr_multiple58func.func @set_op_layout_attr_multiple(%arg0: memref<4096x4096xf16>) {59  %0 = xegpu.create_nd_tdesc %arg0 : memref<4096x4096xf16> -> !xegpu.tensor_desc<256x32xf16>60  %1 = xegpu.load_nd %0[0, 0]  : !xegpu.tensor_desc<256x32xf16> -> vector<256x32xf16>61  %2 = arith.extf %1 : vector<256x32xf16> to vector<256x32xf32>62  %3 = arith.extf %2 : vector<256x32xf32> to vector<256x32xf64>63  return64}65 66module attributes {transform.with_named_sequence} {67  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {68    %0 = transform.structured.match ops{["arith.extf"]} in %arg1 : (!transform.any_op) -> !transform.any_op69    // expected-error@below {{Requires exactly one targetOp handle (got 2)}}70    transform.xegpu.set_op_layout_attr %0 sg_layout = [8, 4] sg_data = [32, 64] : !transform.any_op71    transform.yield72  }73}74 75// -----76 77func.func @set_gpu_launch_threads_bad_handle(%arg0: memref<4096x4096xf16>) {78  %c32 = arith.constant 32 : index // expected-note {{target op}}79  return80}81 82module attributes {transform.with_named_sequence} {83  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {84    %0 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!transform.any_op) -> !transform.any_op85    // expected-error@below {{Expected a gpu.launch op, but got: arith.constant}}86    transform.xegpu.set_gpu_launch_threads %0 threads = [8, 4, 1] : !transform.any_op87    transform.yield88  }89}90 91// -----92 93func.func @set_gpu_launch_threads_many_handles(%arg0: memref<4096x4096xf16>) {94  %c32 = arith.constant 32 : index95  %c64 = arith.constant 64 : index96  return97}98 99module attributes {transform.with_named_sequence} {100  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {101    %0 = transform.structured.match ops{["arith.constant"]} in %arg1 : (!transform.any_op) -> !transform.any_op102    // expected-error@below {{Requires exactly one targetOp handle (got 2)}}103    transform.xegpu.set_gpu_launch_threads %0 threads = [8, 4, 1] : !transform.any_op104    transform.yield105  }106}107 108// -----109 110func.func @set_gpu_launch_threads_bad_threads(%arg0: memref<4096x4096xf16>) {111  %c1 = arith.constant 1 : index112  %c16 = arith.constant 16 : index113  gpu.launch blocks(%arg3, %arg4, %arg5) in (%arg9 = %c16, %arg10 = %c16, %arg11 = %c1) threads(%arg6, %arg7, %arg8) in (%arg12 = %c1, %arg13 = %c1, %arg14 = %c1) {114    gpu.terminator115  }116  return117}118 119module attributes {transform.with_named_sequence} {120  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {121    %0 = transform.structured.match ops{["gpu.launch"]} in %arg1 : (!transform.any_op) -> !transform.any_op122    // expected-error@below {{Expected threads argument to consist of three values (got 2)}}123    transform.xegpu.set_gpu_launch_threads %0 threads = [8, 4] : !transform.any_op124    transform.yield125  }126}127 128// -----129 130// CHECK-LABEL: @insert_prefetch_dpas_c131func.func @insert_prefetch_dpas_c(%arg0: memref<4096x4096xf16>, %arg1: memref<4096x4096xf16>, %arg2: memref<4096x4096xf16>) {132  %c32 = arith.constant 32 : index133  %c4096 = arith.constant 4096 : index134  %c0 = arith.constant 0 : index135  %0 = xegpu.create_nd_tdesc %arg2 : memref<4096x4096xf16> -> !xegpu.tensor_desc<256x256xf16>136  // expected-note@below {{load op}}137  %1 = xegpu.load_nd %0[%c0, %c0]  : !xegpu.tensor_desc<256x256xf16> -> vector<256x256xf16>138  %3 = xegpu.create_nd_tdesc %arg0 : memref<4096x4096xf16> -> !xegpu.tensor_desc<256x32xf16>139  %4 = xegpu.create_nd_tdesc %arg1 : memref<4096x4096xf16> -> !xegpu.tensor_desc<32x256xf16>140  %2 = scf.for %arg3 = %c0 to %c4096 step %c32 iter_args(%arg4 = %1) -> (vector<256x256xf16>) {141    %5 = xegpu.load_nd %3[%c0, %arg3] : !xegpu.tensor_desc<256x32xf16> -> vector<256x32xf16>142    %6 = xegpu.load_nd %4[%arg3, %c0] : !xegpu.tensor_desc<32x256xf16> -> vector<32x256xf16>143    %7 = xegpu.dpas %5, %6, %arg4 : vector<256x32xf16>, vector<32x256xf16>, vector<256x256xf16> -> vector<256x256xf16>144    scf.yield %7 : vector<256x256xf16>145  }146  return147}148 149module attributes {transform.with_named_sequence} {150  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {151    %0 = transform.structured.match ops{["xegpu.dpas"]} in %arg0 : (!transform.any_op) -> !transform.any_op152    %1 = transform.get_operand %0[2] : (!transform.any_op) -> !transform.any_value153    // expected-error@below {{Load op is not contained in a scf.for loop.}}154    %2 = transform.xegpu.insert_prefetch %1 nb_prefetch = 1 : (!transform.any_value) -> !transform.any_op155    transform.yield156  }157}158