1// RUN: mlir-opt %s -test-transform-dialect-erase-schedule -convert-linalg-to-loops -convert-scf-to-cf -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 | \ 2// RUN: mlir-runner -e main -entry-point-result=void \ 3// RUN: -shared-libs=%mlir_runner_utils \ 4// RUN: | FileCheck %s 5 6// RUN: mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule -convert-linalg-to-loops -convert-scf-to-cf \ 7// 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 | \ 8// RUN: mlir-runner -e main -entry-point-result=void \ 9// RUN: -shared-libs=%mlir_runner_utils \ 10// RUN: | FileCheck %s 11 12func.func private @printMemrefF32(memref<*xf32>) 13 14// Creates and returns 3-D buffer of size (%s1, %s2, %s3) filled with the value %f 15func.func @alloc_3d_filled_f32(%s1 : index, %s2 : index, %s3 : index, %f : f32) -> memref<?x?x?xf32> { 16 %buf = memref.alloc(%s1, %s2, %s3) : memref<?x?x?xf32> 17 linalg.fill ins(%f : f32) outs(%buf : memref<?x?x?xf32>) 18 return %buf : memref<?x?x?xf32> 19} 20 21func.func @conv_3d(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) { 22 linalg.conv_3d ins (%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>) 23 outs (%arg2: memref<?x?x?xf32>) 24 return 25} 26 27module attributes {transform.with_named_sequence} { 28 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 29 %0 = transform.structured.match ops{["linalg.conv_3d"]} in %arg1 : (!transform.any_op) -> !transform.any_op 30 %1, %loops:3 = transform.structured.tile_using_for %0 tile_sizes [2, 2, 2] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op) 31 transform.yield 32 } 33} 34 35func.func @main() { 36 %c0 = arith.constant 0 : index 37 %c1 = arith.constant 1 : index 38 %c3 = arith.constant 3 : index 39 %c6 = arith.constant 6 : index 40 %c8 = arith.constant 8 : index 41 %f10 = arith.constant 10.00000e+00 : f32 42 %val = arith.constant 2.00000e+00 : f32 43 %zero = arith.constant 0.00000e+00 : f32 44 45 %filter3D = call @alloc_3d_filled_f32(%c3, %c3, %c3, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>) 46 %in3D = call @alloc_3d_filled_f32(%c8, %c8, %c8, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>) 47 %out3D = call @alloc_3d_filled_f32(%c6, %c6, %c6, %zero) : (index, index, index, f32) -> (memref<?x?x?xf32>) 48 49 memref.store %f10, %in3D[%c0, %c0, %c3] : memref<?x?x?xf32> 50 call @conv_3d(%in3D, %filter3D, %out3D) : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>) -> () 51 %out3D_ = memref.cast %out3D : memref<?x?x?xf32> to memref<*xf32> 52 call @printMemrefF32(%out3D_): (memref<*xf32>) -> () 53 54 memref.dealloc %filter3D : memref<?x?x?xf32> 55 memref.dealloc %in3D : memref<?x?x?xf32> 56 memref.dealloc %out3D : memref<?x?x?xf32> 57 return 58} 59 60// CHECK: Unranked Memref {{.*}} 61// CHECK-NEXT: [ 62// CHECK-SAME: [ 63// CHECK-SAME: [108, 124, 124, 124, 108, 108], 64// CHECK-COUNT-5: [108, 108, 108, 108, 108, 108] 65// CHECK-SAME: ], 66// CHECK-NEXT: [ 67// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108] 68// CHECK-SAME: ], 69// CHECK-NEXT: [ 70// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108] 71// CHECK-SAME: ], 72// CHECK-NEXT: [ 73// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108] 74// CHECK-SAME: ], 75// CHECK-NEXT: [ 76// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108] 77// CHECK-SAME: ], 78// CHECK-NEXT: [ 79// CHECK-COUNT-6: [108, 108, 108, 108, 108, 108] 80// CHECK-SAME: ] 81// CHECK-SAME: ] 82