1 // RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-std -convert-linalg-to-llvm -lower-affine -convert-scf-to-std --convert-memref-to-llvm -convert-std-to-llvm -reconcile-unrealized-casts | \
2 // RUN: mlir-cpu-runner -e main -entry-point-result=void \
3 // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
6 // RUN: mlir-opt %s -linalg-tile="tile-sizes=4" -convert-linalg-to-loops -convert-scf-to-std \
7 // RUN: -convert-linalg-to-llvm -lower-affine -convert-scf-to-std --convert-memref-to-llvm -convert-std-to-llvm -reconcile-unrealized-casts | \
8 // RUN: mlir-cpu-runner -e main -entry-point-result=void \
9 // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \
10 // RUN: | FileCheck %s
12 func private @print_memref_f32(memref<*xf32>)
14 // Creates and returns a 1-D buffer of size %s1 filled with the value %f
15 func @alloc_1d_filled_f32(%s1 : index, %f : f32) -> memref<?xf32> {
16 %buf = memref.alloc(%s1) : memref<?xf32>
17 linalg.fill(%f, %buf) : f32, memref<?xf32>
18 return %buf : memref<?xf32>
21 func @conv_1d(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: memref<?xf32>) {
22 linalg.conv_1d ins (%arg0, %arg1: memref<?xf32>, memref<?xf32>)
23 outs (%arg2: memref<?xf32>)
28 %c3 = arith.constant 3 : index
29 %c6 = arith.constant 6 : index
30 %c8 = arith.constant 8 : index
31 %f10 = arith.constant 10.00000e+00 : f32
32 %val = arith.constant 2.00000e+00 : f32
33 %zero = arith.constant 0.00000e+00 : f32
35 %filter1D = call @alloc_1d_filled_f32(%c3, %val) : (index, f32) -> (memref<?xf32>)
36 %in1D = call @alloc_1d_filled_f32(%c8, %val) : (index, f32) -> (memref<?xf32>)
37 %out1D = call @alloc_1d_filled_f32(%c6, %zero) : (index, f32) -> (memref<?xf32>)
39 memref.store %f10, %in1D[%c3] : memref<?xf32>
40 call @conv_1d(%in1D, %filter1D, %out1D) : (memref<?xf32>, memref<?xf32>, memref<?xf32>) -> ()
41 %out1D_ = memref.cast %out1D : memref<?xf32> to memref<*xf32>
42 call @print_memref_f32(%out1D_): (memref<*xf32>) -> ()
44 memref.dealloc %filter1D : memref<?xf32>
45 memref.dealloc %in1D : memref<?xf32>
46 memref.dealloc %out1D : memref<?xf32>
50 // CHECK: Unranked Memref {{.*}}
51 // CHECK-NEXT: [12, 28, 28, 28, 12, 12]