61 lines · plain
1// DEFINE: %{compile} = mlir-opt %s \2// DEFINE: -transform-interpreter -test-transform-dialect-erase-schedule \3// DEFINE: -one-shot-bufferize="bufferize-function-boundaries" -lower-vector-mask -buffer-deallocation-pipeline -cse -canonicalize -convert-vector-to-scf -arm-sve-legalize-vector-storage \4// DEFINE: -convert-vector-to-llvm="enable-arm-sve" -test-lower-to-llvm -o %t5// DEFINE: %{entry_point} = conv6// DEFINE: %{run} = %mcr_aarch64_cmd %t -e %{entry_point} -entry-point-result=void --march=aarch64 --mattr="+sve"\7// DEFINE: -shared-libs=%native_mlir_runner_utils,%native_mlir_c_runner_utils8 9// RUN: rm -f %t && %{compile} && %{run} | FileCheck %s10 11func.func @conv() {12 // Define input/output tensors13 %input_init = tensor.empty() : tensor<1x8x6xi32>14 %output_init = tensor.empty() : tensor<1x7x6xi32>15 16 %five = arith.constant 5 : i3217 %zero = arith.constant 0 : i3218 %input = linalg.fill ins(%five : i32) outs(%input_init : tensor<1x8x6xi32>) -> tensor<1x8x6xi32>19 %output = linalg.fill ins(%zero : i32) outs(%output_init : tensor<1x7x6xi32>) -> tensor<1x7x6xi32>20 21 // Define the filter tensor22 %filter = arith.constant dense<[23 [ 1, 2, 3, 4, 5, 6],24 [ 11, 12, 13, 14, 15, 16]25 ]> : tensor<2x6xi32>26 27 // static sizes -> dynamic sizes28 %input_dyn = tensor.cast %input_init : tensor<1x8x6xi32> to tensor<1x8x?xi32>29 %output_dyn = tensor.cast %output : tensor<1x7x6xi32> to tensor<1x7x?xi32>30 %filter_dyn = tensor.cast %filter : tensor<2x6xi32> to tensor<2x?xi32>31 32 // Run the convolution33 %res = linalg.depthwise_conv_1d_nwc_wc34 ins(%input_dyn, %filter_dyn : tensor<1x8x?xi32>, tensor<2x?xi32>)35 outs(%output_dyn : tensor<1x7x?xi32>) -> tensor<1x7x?xi32>36 37 // Print the results38 // CHECK: SVE: START OF TEST OUTPUT39 vector.print str "SVE: START OF TEST OUTPUT\n"40 41 // CHECK-NEXT: Unranked Memref base@ = {{.*}} rank = 3 offset = 0 sizes = [1, 7, 6] strides = [42, 6, 1] data =42 // CHECK-COUNT-7: [60, 70, 80, 90, 100, 110]43 %xf = tensor.cast %res : tensor<1x7x?xi32> to tensor<*xi32>44 call @printMemrefI32(%xf) : (tensor<*xi32>) -> ()45 46 // CHECK-NEXT: SVE: END OF TEST OUTPUT47 vector.print str "SVE: END OF TEST OUTPUT\n"48 49 return50}51 52module attributes {transform.with_named_sequence} {53 transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {54 %0 = transform.structured.match ops{["linalg.depthwise_conv_1d_nwc_wc"]} in %arg0 : (!transform.any_op) -> !transform.any_op55 transform.structured.vectorize %0 vector_sizes [1, 7, [8], 2] : !transform.any_op56 transform.yield57 }58}59 60func.func private @printMemrefI32(%ptr : tensor<*xi32>)61