40 lines · plain
1// RUN: mlir-opt %s -convert-linalg-to-loops -convert-scf-to-cf -expand-strided-metadata -lower-affine -convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts | \2// RUN: mlir-runner -O3 -e main -entry-point-result=void \3// RUN: -shared-libs=%mlir_runner_utils \4// RUN: | FileCheck %s5 6func.func private @printMemrefF32(memref<*xf32>)7 8func.func @main() {9 %c0 = arith.constant 0 : index10 %c1 = arith.constant 1 : index11 %c2 = arith.constant 2 : index12 %f0 = arith.constant 0.0 : f3213 %f1 = arith.constant 1.0 : f3214 %f2 = arith.constant 2.0 : f3215 %f3 = arith.constant 3.0 : f3216 %A = memref.alloc(%c2, %c2) : memref<?x?xf32>17 memref.store %f0, %A[%c0, %c0] : memref<?x?xf32>18 memref.store %f1, %A[%c0, %c1] : memref<?x?xf32>19 memref.store %f2, %A[%c1, %c0] : memref<?x?xf32>20 memref.store %f3, %A[%c1, %c1] : memref<?x?xf32>21 %B = memref.subview %A[%c1, 0][1, %c2][1, 1] : memref<?x?xf32> to memref<?xf32, strided<[1], offset: ?>>22 %C = memref.subview %A[0, %c1][%c2, 1][1, 1] : memref<?x?xf32> to memref<?xf32, strided<[?], offset: ?>>23 %A_ = memref.cast %A : memref<?x?xf32> to memref<*xf32>24 call @printMemrefF32(%A_) : (memref<*xf32>) -> ()25 %B_ = memref.cast %B : memref<?xf32, strided<[1], offset: ?>> to memref<*xf32>26 call @printMemrefF32(%B_) : (memref<*xf32>) -> ()27 %C_ = memref.cast %C : memref<?xf32, strided<[?], offset: ?>> to memref<*xf32>28 call @printMemrefF32(%C_) : (memref<*xf32>) -> ()29 memref.dealloc %A : memref<?x?xf32>30 return31}32 33// CHECK: Unranked Memref base@ = {{.*}} rank = 2 offset = 0 sizes = [2, 2] strides = [2, 1] data =34// CHECK-NEXT: [35// CHECK-SAME: [0, 1],36// CHECK-NEXT: [2, 3]37// CHECK-SAME: ]38// CHECK: [2, 3]39// CHECK: [1, 3]40