xref: /llvm-project/mlir/test/Integration/Dialect/Linalg/CPU/test-elementwise.mlir (revision eb206e9ea84eff0a0596fed2de8316d924f946d1)
1// RUN: mlir-opt %s -convert-elementwise-to-linalg \
2// RUN: -one-shot-bufferize="bufferize-function-boundaries" \
3// RUN: -canonicalize -buffer-deallocation-pipeline -convert-bufferization-to-memref -convert-linalg-to-loops \
4// RUN: -convert-scf-to-cf -convert-arith-to-llvm -convert-cf-to-llvm --finalize-memref-to-llvm \
5// RUN: -convert-func-to-llvm -reconcile-unrealized-casts | \
6// RUN: mlir-runner -e main -entry-point-result=void \
7// RUN:   -shared-libs=%mlir_runner_utils \
8// RUN: | FileCheck %s
9
10func.func @main() {
11  %a = arith.constant dense<[1.0, 2.0, 3.0]> : tensor<3xf32>
12  %b = arith.constant dense<[10.0, 20.0, 30.0]> : tensor<3xf32>
13
14  %addf = arith.addf %a, %b : tensor<3xf32>
15  %addf_unranked = tensor.cast %addf : tensor<3xf32> to tensor<*xf32>
16  call @printMemrefF32(%addf_unranked) : (tensor<*xf32>) -> ()
17  // CHECK: Unranked Memref base@ = {{.*}} rank = 1 offset = 0 sizes = [3] strides = [1] data =
18  // CHECK-NEXT: [11,  22,  33]
19
20  return
21}
22
23func.func private @printMemrefF32(%ptr : tensor<*xf32>)
24