1 // RUN: mlir-opt %s -generate-runtime-verification \
2 // RUN: -expand-strided-metadata \
3 // RUN: -lower-affine \
4 // RUN: -finalize-memref-to-llvm \
5 // RUN: -test-cf-assert \
6 // RUN: -convert-func-to-llvm \
7 // RUN: -convert-arith-to-llvm \
8 // RUN: -reconcile-unrealized-casts | \
9 // RUN: mlir-cpu-runner -e main -entry-point-result=void \
10 // RUN: -shared-libs=%mlir_runner_utils 2>&1 | \
13 func.func @subview(%memref: memref<1xf32>, %offset: index) {
14 memref.subview %memref[%offset] [1] [1] :
16 memref<1xf32, strided<[1], offset: ?>>
20 func.func @subview_dynamic(%memref: memref<?x4xf32>, %offset: index, %size: index, %stride: index) {
21 memref.subview %memref[%offset, 0] [%size, 4] [%stride, 1] :
23 memref<?x4xf32, strided<[?, 1], offset: ?>>
27 func.func @subview_dynamic_rank_reduce(%memref: memref<?x4xf32>, %offset: index, %size: index, %stride: index) {
28 memref.subview %memref[%offset, 0] [%size, 1] [%stride, 1] :
30 memref<?xf32, strided<[?], offset: ?>>
35 %0 = arith.constant 0 : index
36 %1 = arith.constant 1 : index
37 %n1 = arith.constant -1 : index
38 %4 = arith.constant 4 : index
39 %5 = arith.constant 5 : index
41 %alloca = memref.alloca() : memref<1xf32>
42 %alloca_4 = memref.alloca() : memref<4x4xf32>
43 %alloca_4_dyn = memref.cast %alloca_4 : memref<4x4xf32> to memref<?x4xf32>
45 // Offset is out-of-bounds
46 // CHECK: ERROR: Runtime op verification failed
47 // CHECK-NEXT: "memref.subview"
48 // CHECK-NEXT: ^ subview is out-of-bounds of the base memref
49 // CHECK-NEXT: Location: loc({{.*}})
50 func.call @subview_dynamic_rank_reduce(%alloca_4_dyn, %5, %5, %1) : (memref<?x4xf32>, index, index, index) -> ()
52 // Offset is out-of-bounds
53 // CHECK: ERROR: Runtime op verification failed
54 // CHECK-NEXT: "memref.subview"
55 // CHECK-NEXT: ^ subview is out-of-bounds of the base memref
56 // CHECK-NEXT: Location: loc({{.*}})
57 func.call @subview(%alloca, %1) : (memref<1xf32>, index) -> ()
59 // Offset is out-of-bounds
60 // CHECK: ERROR: Runtime op verification failed
61 // CHECK-NEXT: "memref.subview"
62 // CHECK-NEXT: ^ subview is out-of-bounds of the base memref
63 // CHECK-NEXT: Location: loc({{.*}})
64 func.call @subview(%alloca, %n1) : (memref<1xf32>, index) -> ()
66 // Size is out-of-bounds
67 // CHECK: ERROR: Runtime op verification failed
68 // CHECK-NEXT: "memref.subview"
69 // CHECK-NEXT: ^ subview is out-of-bounds of the base memref
70 // CHECK-NEXT: Location: loc({{.*}})
71 func.call @subview_dynamic(%alloca_4_dyn, %0, %5, %1) : (memref<?x4xf32>, index, index, index) -> ()
73 // Stride is out-of-bounds
74 // CHECK: ERROR: Runtime op verification failed
75 // CHECK-NEXT: "memref.subview"
76 // CHECK-NEXT: ^ subview is out-of-bounds of the base memref
77 // CHECK-NEXT: Location: loc({{.*}})
78 func.call @subview_dynamic(%alloca_4_dyn, %0, %4, %4) : (memref<?x4xf32>, index, index, index) -> ()
80 // CHECK-NOT: ERROR: Runtime op verification failed
81 func.call @subview(%alloca, %0) : (memref<1xf32>, index) -> ()
83 // CHECK-NOT: ERROR: Runtime op verification failed
84 func.call @subview_dynamic(%alloca_4_dyn, %0, %4, %1) : (memref<?x4xf32>, index, index, index) -> ()
86 // CHECK-NOT: ERROR: Runtime op verification failed
87 func.call @subview_dynamic_rank_reduce(%alloca_4_dyn, %0, %1, %0) : (memref<?x4xf32>, index, index, index) -> ()