1// RUN: mlir-opt %s -convert-linalg-to-loops -convert-linalg-to-llvm -convert-std-to-llvm | \ 2// RUN: mlir-cpu-runner -e main -entry-point-result=void \ 3// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \ 4// RUN: | FileCheck %s 5 6// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,3,3,2" -convert-linalg-to-loops \ 7// RUN: -convert-linalg-to-llvm -convert-std-to-llvm | \ 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 11 12// RUN: mlir-opt %s -test-conv-vectorization="tile-sizes=1,1,1,1,3,3,3" -convert-linalg-to-llvm | \ 13// RUN: mlir-cpu-runner -e main -entry-point-result=void \ 14// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \ 15// RUN: | FileCheck %s 16 17// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,3,3,2" \ 18// RUN: -test-conv-vectorization="tile-sizes=1,1,1,1,3,3,3" -convert-linalg-to-llvm | \ 19// RUN: mlir-cpu-runner -e main -entry-point-result=void \ 20// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_runner_utils%shlibext \ 21// RUN: | FileCheck %s 22 23func private @print_memref_f32(memref<*xf32>) 24 25// Creates and returns 4-D buffer of size (%s1, %s2, %s3, %s4) filled with the value %f 26func @alloc_4d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %s4 : index, %f : f32) -> memref<?x?x?x?xf32> { 27 %buf = alloc(%s1, %s2, %s3, %s4) : memref<?x?x?x?xf32> 28 linalg.fill(%buf, %f) : memref<?x?x?x?xf32>, f32 29 return %buf : memref<?x?x?x?xf32> 30} 31 32func @conv_2d_nhwc(%arg0: memref<?x?x?x?xf32>, %arg1: memref<?x?x?x?xf32>, %arg2: memref<?x?x?x?xf32>) { 33 linalg.conv_2d_nhwc ins (%arg0, %arg1: memref<?x?x?x?xf32>, memref<?x?x?x?xf32>) 34 outs (%arg2: memref<?x?x?x?xf32>) 35 return 36} 37 38func @main() { 39 %c0 = constant 0 : index 40 %c1 = constant 1 : index 41 %c3 = constant 3 : index 42 %c6 = constant 6 : index 43 %c8 = constant 8 : index 44 %f10 = constant 10.00000e+00 : f32 45 %val = constant 2.00000e+00 : f32 46 %zero = constant 0.00000e+00 : f32 47 48 %filter2D_nhwc = call @alloc_4d_filled_f32(%c1, %c3, %c3, %c3, %val) :(index, index, index, index, f32) -> (memref<?x?x?x?xf32>) 49 %in2D_nhwc = call @alloc_4d_filled_f32(%c3, %c8, %c8, %c3, %val) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>) 50 %out2D_nhwc = call @alloc_4d_filled_f32(%c3, %c6, %c6, %c1, %zero) : (index, index, index, index, f32) -> (memref<?x?x?x?xf32>) 51 52 store %f10, %in2D_nhwc[%c0, %c0, %c3, %c0] : memref<?x?x?x?xf32> 53 call @conv_2d_nhwc(%in2D_nhwc, %filter2D_nhwc, %out2D_nhwc) : (memref<?x?x?x?xf32>, memref<?x?x?x?xf32>, memref<?x?x?x?xf32>) -> () 54 %out2D_nhwc_ = memref_cast %out2D_nhwc : memref<?x?x?x?xf32> to memref<*xf32> 55 call @print_memref_f32(%out2D_nhwc_): (memref<*xf32>) -> () 56 57 dealloc %filter2D_nhwc : memref<?x?x?x?xf32> 58 dealloc %in2D_nhwc : memref<?x?x?x?xf32> 59 dealloc %out2D_nhwc : memref<?x?x?x?xf32> 60 return 61} 62 63// CHECK: Unranked Memref {{.*}} 64// CHECK-NEXT: [ 65// CHECK-SAME: [ 66// CHECK-SAME: [ 67// CHECK-SAME: [108], 68// CHECK-COUNT-3: [124], 69// CHECK-COUNT-2: [108] 70// CHECK-SAME: ], 71// CHECK-NEXT: [ 72// CHECK-COUNT-6: [108] 73// CHECK-SAME: ], 74// CHECK-NEXT: [ 75// CHECK-COUNT-6: [108] 76// CHECK-SAME: ], 77// CHECK-NEXT: [ 78// CHECK-COUNT-6: [108] 79// CHECK-SAME: ], 80// CHECK-NEXT: [ 81// CHECK-COUNT-6: [108] 82// CHECK-SAME: ], 83// CHECK-NEXT: [ 84// CHECK-COUNT-6: [108] 85// CHECK-SAME: ] 86// CHECK-SAME: ], 87// CHECK-NEXT: [ 88// CHECK-SAME: [ 89// CHECK-COUNT-6: [108] 90// CHECK-SAME: ], 91// CHECK-NEXT: [ 92// CHECK-COUNT-6: [108] 93// CHECK-SAME: ], 94// CHECK-NEXT: [ 95// CHECK-COUNT-6: [108] 96// CHECK-SAME: ], 97// CHECK-NEXT: [ 98// CHECK-COUNT-6: [108] 99// CHECK-SAME: ], 100// CHECK-NEXT: [ 101// CHECK-COUNT-6: [108] 102// CHECK-SAME: ], 103// CHECK-NEXT: [ 104// CHECK-COUNT-6: [108] 105// CHECK-SAME: ] 106// CHECK-SAME: ], 107// CHECK-NEXT: [ 108// CHECK-SAME: [ 109// CHECK-COUNT-6: [108] 110// CHECK-SAME: ], 111// CHECK-NEXT: [ 112// CHECK-COUNT-6: [108] 113// CHECK-SAME: ], 114// CHECK-NEXT: [ 115// CHECK-COUNT-6: [108] 116// CHECK-SAME: ], 117// CHECK-NEXT: [ 118// CHECK-COUNT-6: [108] 119// CHECK-SAME: ], 120// CHECK-NEXT: [ 121// CHECK-COUNT-6: [108] 122// CHECK-SAME: ], 123// CHECK-NEXT: [ 124// CHECK-COUNT-6: [108] 125// CHECK-SAME: ] 126// CHECK-SAME: ] 127// CHECK-SAME: ] 128