xref: /llvm-project/mlir/test/Integration/Dialect/Linalg/CPU/test-tensor-matmul.mlir (revision eb206e9ea84eff0a0596fed2de8316d924f946d1)
1// UNSUPPORTED: asan
2// RUN: mlir-opt %s -test-transform-dialect-erase-schedule \
3// RUN: -one-shot-bufferize="bufferize-function-boundaries" \
4// RUN: -buffer-deallocation-pipeline -convert-bufferization-to-memref -convert-linalg-to-loops -convert-scf-to-cf \
5// RUN: -expand-strided-metadata -lower-affine -convert-arith-to-llvm -convert-scf-to-cf --finalize-memref-to-llvm -convert-func-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts | \
6// RUN: mlir-runner -e main -entry-point-result=void \
7// RUN:   -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils \
8// RUN: | FileCheck %s
9
10// RUN: mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule \
11// RUN: -one-shot-bufferize="bufferize-function-boundaries" \
12// RUN: -convert-linalg-to-loops -convert-scf-to-cf -convert-scf-to-cf \
13// RUN:  -expand-strided-metadata -lower-affine -convert-arith-to-llvm -convert-scf-to-cf --finalize-memref-to-llvm -convert-func-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts | \
14// RUN: mlir-runner -e main -entry-point-result=void \
15// RUN:   -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils \
16// RUN: | FileCheck %s
17
18func.func @main() {
19  %A = arith.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32>
20  %B = arith.constant dense<[[1.0, 2.0, 3.0, 4.0],
21                       [5.0, 6.0, 7.0, 8.0],
22                       [9.0, 10.0, 11.0, 12.0]]> : tensor<3x4xf32>
23  %C = arith.constant dense<1000.0> : tensor<2x4xf32>
24
25  %D = linalg.matmul ins(%A, %B: tensor<2x3xf32>, tensor<3x4xf32>)
26                     outs(%C: tensor<2x4xf32>) -> tensor<2x4xf32>
27
28  %unranked = tensor.cast %D : tensor<2x4xf32> to tensor<*xf32>
29  call @printMemrefF32(%unranked) : (tensor<*xf32>) -> ()
30
31  //      CHECK: Unranked Memref base@ = {{0x[-9a-f]*}}
32  // CHECK-SAME: rank = 2 offset = 0 sizes = [2, 4] strides = [4, 1] data =
33  // CHECK-NEXT: [1038,   1044,   1050,   1056]
34  // CHECK-NEXT: [1083,   1098,   1113,   1128]
35
36  return
37}
38
39module attributes {transform.with_named_sequence} {
40  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
41    %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op
42    %1, %loops:3 = transform.structured.tile_using_for %0 tile_sizes [1, 2, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
43    transform.yield
44  }
45}
46
47func.func private @printMemrefF32(%ptr : tensor<*xf32>)
48