|
1 |
| -// Test that both anchor-op name and MatmulOp-based codegen strategy produce the same result. |
2 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=2,4,8 vectorize vectorize-contraction-to=matrixintrinsics unroll-vector-transfers=true" | FileCheck %s |
3 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=2,4,8 tile-interchange=1,2,0 vectorize vectorize-contraction-to=matrixintrinsics unroll-vector-transfers=true" | FileCheck %s |
4 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 promote promote-full-tile-pad register-tile-sizes=2,4,8 vectorize vectorize-contraction-to=outerproduct split-transfers=true unroll-vector-transfers=false" | FileCheck %s --check-prefix=OUTER |
5 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=2,4,8 vectorize vectorize-contraction-to=matrixintrinsics unroll-vector-transfers=true" | FileCheck %s |
6 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 promote promote-full-tile-pad register-tile-sizes=2,4,8 vectorize vectorize-contraction-to=outerproduct split-transfers=true unroll-vector-transfers=false" | FileCheck %s --check-prefix=OUTER |
7 |
| -// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 generalize iterator-interchange=0,2,1" | FileCheck %s --check-prefix=GENER |
8 |
| - |
9 |
| - |
10 |
| -// CHECK-LABEL: func @matmul( |
11 |
| -// OUTER-LABEL: func @matmul( |
12 |
| -// GENER-LABEL: func @matmul( |
13 |
| -func @matmul(%A: memref<1584x1584xf32>, %B: memref<1584x1584xf32>, %C: memref<1584x1584xf32>) { |
14 |
| - linalg.matmul |
15 |
| - ins(%A, %B: memref<1584x1584xf32>, memref<1584x1584xf32>) |
16 |
| - outs(%C: memref<1584x1584xf32>) |
17 |
| - |
18 |
| - // CHECK: vector.matrix_multiply |
19 |
| - // CHECK-SAME: {lhs_columns = 8 : i32, lhs_rows = 2 : i32, rhs_columns = 4 : i32} |
20 |
| - // CHECK-SAME: (vector<16xf32>, vector<32xf32>) -> vector<8xf32> |
21 |
| - |
22 |
| - // OUTER: vector.outerproduct {{.*}} : vector<2xf32>, vector<4xf32> |
23 |
| - |
24 |
| - // GENER: linalg.generic |
25 |
| - // GENER-SAME: iterator_types = ["parallel", "reduction", "parallel"] |
| 1 | +// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=2,4,8 vectorize vectorize-contraction-to=matrixintrinsics unroll-vector-transfers=true" -split-input-file | FileCheck %s --check-prefix=CHECK-INTRINSIC |
| 2 | +// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 promote promote-full-tile-pad register-tile-sizes=2,4,8 vectorize vectorize-contraction-to=outerproduct split-transfers=true unroll-vector-transfers=false" -split-input-file | FileCheck %s --check-prefix=CHECK-OUTER |
| 3 | +// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 tile-interchange=1,2,0 generalize iterator-interchange=0,2,1" -split-input-file | FileCheck %s --check-prefix=CHECK-INTERCHANGE |
| 4 | +// RUN: mlir-opt %s -test-linalg-codegen-strategy="anchor-func=matmul anchor-op=linalg.matmul tile-sizes=16,32,64 pad pack-paddings=1,1,0 hoist-paddings=3,3,0" -split-input-file | FileCheck %s --check-prefix=CHECK-PAD |
| 5 | + |
| 6 | +// CHECK-INTRINSIC: func @matmul( |
| 7 | +// CHECK-OUTER: func @matmul( |
| 8 | +func @matmul(%arg0: memref<72x72xf32>, %arg1: memref<72x72xf32>, %arg2: memref<72x72xf32>) { |
| 9 | + |
| 10 | + // Check the matrix intrinsic lowering is triggered. |
| 11 | + // CHECK-INTRINSIC: vector.matrix_multiply |
| 12 | + // CHECK-INTRINSIC-SAME: {lhs_columns = 8 : i32, lhs_rows = 2 : i32, rhs_columns = 4 : i32} |
| 13 | + // CHECK-INTRINSIC-SAME: (vector<16xf32>, vector<32xf32>) -> vector<8xf32> |
| 14 | + |
| 15 | + // Check the outer product lowering is triggered. |
| 16 | + // CHECK-OUTER: vector.outerproduct {{.*}} : vector<2xf32>, vector<4xf32> |
| 17 | + linalg.matmul ins(%arg0, %arg1: memref<72x72xf32>, memref<72x72xf32>) outs(%arg2: memref<72x72xf32>) |
26 | 18 | return
|
27 | 19 | }
|
28 | 20 |
|
| 21 | +// ----- |
| 22 | + |
| 23 | +// CHECK-INTERCHANGE: func @matmul( |
| 24 | +func @matmul(%arg0: tensor<72x72xf32>, %arg1: tensor<72x72xf32>, %arg2: tensor<72x72xf32>) -> tensor<72x72xf32> { |
| 25 | + // CHECK-INTERCHANGE-DAG: %[[C16:.*]] = arith.constant 16 |
| 26 | + // CHECK-INTERCHANGE-DAG: %[[C32:.*]] = arith.constant 32 |
| 27 | + // CHECK-INTERCHANGE-DAG: %[[C64:.*]] = arith.constant 64 |
| 28 | + |
| 29 | + // Check the tile loops are interchanged. |
| 30 | + // CHECK-INTERCHANGE: scf.for {{.*}} step %[[C32]] |
| 31 | + // CHECK-INTERCHANGE: scf.for {{.*}} step %[[C64]] |
| 32 | + // CHECK-INTERCHANGE: scf.for {{.*}} step %[[C16]] |
| 33 | + |
| 34 | + // Check the operation has been generalized and interchanged. |
| 35 | + // CHECK-INTERCHANGE: linalg.generic |
| 36 | + // CHECK-INTERCHANGE-SAME: iterator_types = ["parallel", "reduction", "parallel"] |
| 37 | + %0 = linalg.matmul ins(%arg0, %arg1: tensor<72x72xf32>, tensor<72x72xf32>) outs(%arg2: tensor<72x72xf32>) -> tensor<72x72xf32> |
| 38 | + return %0 : tensor<72x72xf32> |
| 39 | +} |
| 40 | + |
| 41 | +// ----- |
| 42 | + |
| 43 | +// CHECK-PAD: func @matmul( |
| 44 | +func @matmul(%arg0: tensor<72x72xf32>, %arg1: tensor<72x72xf32>, %arg2: tensor<72x72xf32>) -> tensor<72x72xf32> { |
| 45 | + |
| 46 | + // Check the padding of the input operands has been hoisted out of the tile loop nest. |
| 47 | + // CHECK-PAD-COUNT=2: linalg.pad_tensor %{{.*}} nofold |
| 48 | + // CHECK-PAD-COUNT=3: scf.for |
| 49 | + // CHECK-PAD: linalg.matmul |
| 50 | + %0 = linalg.matmul ins(%arg0, %arg1: tensor<72x72xf32>, tensor<72x72xf32>) outs(%arg2: tensor<72x72xf32>) -> tensor<72x72xf32> |
| 51 | + return %0 : tensor<72x72xf32> |
| 52 | +} |
| 53 | + |
0 commit comments