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_1d_nwc_wcf(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) { 22 linalg.conv_1d_nwc_wcf {dilations = dense<1> : tensor<1xi64>, 23 strides = dense<1> : tensor<1xi64>} 24 ins (%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>) 25 outs (%arg2: memref<?x?x?xf32>) 26 return 27} 28 29module attributes {transform.with_named_sequence} { 30 transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) { 31 %0 = transform.structured.match ops{["linalg.conv_1d_nwc_wcf"]} in %arg1 : (!transform.any_op) -> !transform.any_op 32 %1, %loops:2 = transform.structured.tile_using_for %0 tile_sizes [2, 4] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) 33 transform.yield 34 } 35} 36 37func.func @main() { 38 %c0 = arith.constant 0 : index 39 %c1 = arith.constant 1 : index 40 %c3 = arith.constant 3 : index 41 %c6 = arith.constant 6 : index 42 %c8 = arith.constant 8 : index 43 %f10 = arith.constant 10.00000e+00 : f32 44 %val = arith.constant 2.00000e+00 : f32 45 %zero = arith.constant 0.00000e+00 : f32 46 47 %filter1D_nwc = call @alloc_3d_filled_f32(%c3, %c1, %c1, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>) 48 %in1D_nwc = call @alloc_3d_filled_f32(%c3, %c8, %c1, %val) : (index, index, index, f32) -> (memref<?x?x?xf32>) 49 %out1D_nwc = call @alloc_3d_filled_f32(%c3, %c6, %c1, %zero) : (index, index, index, f32) -> (memref<?x?x?xf32>) 50 51 memref.store %f10, %in1D_nwc[%c0, %c3, %c0] : memref<?x?x?xf32> 52 call @conv_1d_nwc_wcf(%in1D_nwc, %filter1D_nwc, %out1D_nwc) : (memref<?x?x?xf32>, memref<?x?x?xf32>, memref<?x?x?xf32>) -> () 53 %out1D_nwc_ = memref.cast %out1D_nwc : memref<?x?x?xf32> to memref<*xf32> 54 call @printMemrefF32(%out1D_nwc_): (memref<*xf32>) -> () 55 56 memref.dealloc %filter1D_nwc : memref<?x?x?xf32> 57 memref.dealloc %in1D_nwc : memref<?x?x?xf32> 58 memref.dealloc %out1D_nwc : memref<?x?x?xf32> 59 return 60} 61 62// CHECK: Unranked Memref {{.*}} 63// CHECK-NEXT: [ 64// CHECK-SAME: [ 65// CHECK-SAME: [12], 66// CHECK-COUNT-3: [28], 67// CHECK-NEXT: [12], 68// CHECK-NEXT: [12] 69// CHECK-SAME: ], 70// CHECK-NEXT: [ 71// CHECK-COUNT-5: [12], 72// CHECK-NEXT: [12] 73// CHECK-SAME: ], 74// CHECK-NEXT: [ 75// CHECK-COUNT-5: [12], 76// CHECK-NEXT: [12] 77// CHECK-SAME: ] 78// CHECK-SAME: ] 79