|
1 |
| -// RUN: mlir-opt %s -test-transform-dialect-interpreter -test-transform-dialect-erase-schedule \ |
2 |
| -// RUN: -one-shot-bufferize -func-bufferize -cse -canonicalize -convert-vector-to-scf -arm-sve-legalize-vector-storage \ |
3 |
| -// RUN: -convert-vector-to-llvm="enable-arm-sve" -test-lower-to-llvm | \ |
4 |
| -// RUN: %mcr_aarch64_cmd -e=matmul_f32 -entry-point-result=void --march=aarch64 --mattr="+sve" -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils | \ |
5 |
| -// RUN: FileCheck %s |
| 1 | +// DEFINE: %{compile} = mlir-opt %s \ |
| 2 | +// DEFINE: -transform-interpreter -test-transform-dialect-erase-schedule \ |
| 3 | +// DEFINE: -one-shot-bufferize -func-bufferize -cse -canonicalize -convert-vector-to-scf -arm-sve-legalize-vector-storage \ |
| 4 | +// DEFINE: -convert-vector-to-llvm="enable-arm-sve" -test-lower-to-llvm -o %t |
| 5 | +// DEFINE: %{entry_point} = matmul_f32 |
| 6 | +// DEFINE: %{run} = %mcr_aarch64_cmd %t -e %{entry_point} -entry-point-result=void --march=aarch64 --mattr="+sve"\ |
| 7 | +// DEFINE: -shared-libs=%mlir_runner_utils,%mlir_c_runner_utils |
| 8 | + |
| 9 | +// RUN: %{compile} |
| 10 | + |
| 11 | +// RUN: %{run} | FileCheck %s |
6 | 12 |
|
7 | 13 | func.func @matmul_f32() {
|
8 | 14 | // Matrix dimensions
|
@@ -40,29 +46,37 @@ func.func @matmul_f32() {
|
40 | 46 | return
|
41 | 47 | }
|
42 | 48 |
|
43 |
| -transform.sequence failures(propagate) { |
44 |
| -^bb1(%module_op: !transform.any_op): |
45 |
| - // Step 1: Tile |
46 |
| - %matmul = transform.structured.match ops{["linalg.matmul"]} in %module_op : (!transform.any_op) -> !transform.any_op |
47 |
| - %func_op = get_parent_op %matmul : (!transform.any_op) -> !transform.op<"func.func"> |
48 |
| - %module_with_tiled_loops, %loops:3 = transform.structured.tile_using_for %matmul [2, [4], 1] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) |
49 |
| - |
50 |
| - // Step 2: Vectorize |
51 |
| - %tiled_matmul = transform.structured.match ops{["linalg.matmul"]} in %module_with_tiled_loops : (!transform.any_op) -> !transform.any_op |
52 |
| - transform.structured.vectorize %tiled_matmul vector_sizes [2, [4], 1] : !transform.any_op |
53 |
| - |
54 |
| - // Step 3: Lower vector.multi_reduction to vector.contract (+ some helpful patterns) |
55 |
| - transform.apply_patterns to %func_op { |
56 |
| - transform.apply_patterns.vector.reduction_to_contract |
57 |
| - transform.apply_patterns.vector.transfer_permutation_patterns |
58 |
| - transform.apply_patterns.vector.lower_masked_transfers |
59 |
| - } : !transform.op<"func.func"> |
60 |
| - |
61 |
| - // Step 4: Lower vector.contract to vector.fma |
62 |
| - transform.apply_patterns to %func_op { |
63 |
| - transform.apply_patterns.vector.lower_contraction lowering_strategy = "outerproduct" |
64 |
| - transform.apply_patterns.vector.lower_outerproduct |
65 |
| - } : !transform.op<"func.func"> |
| 49 | +module attributes {transform.with_named_sequence} { |
| 50 | +transform.named_sequence @__transform_main(%module: !transform.any_op {transform.readonly}) { |
| 51 | + %matmul = transform.structured.match ops{["linalg.matmul"]} in %module |
| 52 | + : (!transform.any_op) -> !transform.any_op |
| 53 | + |
| 54 | + // Step 1: Tile |
| 55 | + %module_with_tiled_loops, %loops:3 = transform.structured.tile_using_for %matmul [2, [4], 1] |
| 56 | + : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) |
| 57 | + |
| 58 | + // Step 2: Vectorize |
| 59 | + %tiled_matmul = transform.structured.match ops{["linalg.matmul"]} in %module_with_tiled_loops |
| 60 | + : (!transform.any_op) -> !transform.any_op |
| 61 | + transform.structured.vectorize %tiled_matmul vector_sizes [2, [4], 1] : !transform.any_op |
| 62 | + |
| 63 | + // Step 3: Lower vector.multi_reduction to vector.contract (+ some helpful patterns) |
| 64 | + %func = transform.structured.match ops{["func.func"]} in %module |
| 65 | + : (!transform.any_op) -> !transform.op<"func.func"> |
| 66 | + transform.apply_patterns to %func { |
| 67 | + transform.apply_patterns.vector.reduction_to_contract |
| 68 | + transform.apply_patterns.vector.transfer_permutation_patterns |
| 69 | + transform.apply_patterns.vector.lower_masked_transfers |
| 70 | + } : !transform.op<"func.func"> |
| 71 | + |
| 72 | + // Step 4: Lower vector.contract to vector.fma |
| 73 | + transform.apply_patterns to %func { |
| 74 | + transform.apply_patterns.vector.lower_contraction lowering_strategy = "outerproduct" |
| 75 | + transform.apply_patterns.vector.lower_outerproduct |
| 76 | + } : !transform.op<"func.func"> |
| 77 | + |
| 78 | + transform.yield |
| 79 | + } |
66 | 80 | }
|
67 | 81 |
|
68 | 82 | func.func private @printMemrefF32(%ptr : tensor<*xf32>)
|
0 commit comments