brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.9 KiB · 09cfee1 Raw
147 lines · plain
1// RUN: mlir-opt %s -generate-runtime-verification \2// RUN:     -expand-strided-metadata \3// RUN:     -lower-affine \4// RUN:     -test-cf-assert \5// RUN:     -convert-scf-to-cf \6// RUN:     -convert-to-llvm | \7// RUN: mlir-runner -e main -entry-point-result=void \8// RUN:     -shared-libs=%mlir_runner_utils 2>&1 | \9// RUN: FileCheck %s10 11// RUN: mlir-opt %s -generate-runtime-verification \12// RUN:     -expand-strided-metadata \13// RUN:     -lower-affine \14// RUN:     -test-cf-assert \15// RUN:     -convert-scf-to-cf \16// RUN:     -convert-to-llvm="allow-pattern-rollback=0" \17// RUN:     -reconcile-unrealized-casts | \18// RUN: mlir-runner -e main -entry-point-result=void \19// RUN:     -shared-libs=%mlir_runner_utils 2>&1 | \20// RUN: FileCheck %s21 22func.func @subview(%memref: memref<1xf32>, %offset: index) {23    memref.subview %memref[%offset] [1] [1] : 24        memref<1xf32> to 25        memref<1xf32, strided<[1], offset: ?>>26    return27}28 29func.func @subview_dynamic(%memref: memref<?x4xf32>, %offset: index, %size: index, %stride: index) {30    memref.subview %memref[%offset, 0] [%size, 4] [%stride, 1] : 31        memref<?x4xf32> to 32        memref<?x4xf32, strided<[?, 1], offset: ?>>33    return34}35 36func.func @subview_dynamic_rank_reduce(%memref: memref<?x4xf32>, %offset: index, %size: index, %stride: index) {37    memref.subview %memref[%offset, 0] [%size, 1] [%stride, 1] :38        memref<?x4xf32> to39        memref<?xf32, strided<[?], offset: ?>>40    return41}42 43func.func @subview_zero_size_dim(%memref: memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>>, 44                                 %dim_0: index, 45                                 %dim_1: index, 46                                 %dim_2: index) {47    %subview = memref.subview %memref[0, 0, 0] [%dim_0, %dim_1, %dim_2] [1, 1, 1] :48        memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>> to49        memref<?x?x?xf32, strided<[?, ?, ?], offset: ?>>50    return51}52 53func.func @subview_with_empty_slice(%memref: memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>>, 54                                 %dim_0: index, 55                                 %dim_1: index, 56                                 %dim_2: index,57                                 %offset: index) {58    %subview = memref.subview %memref[%offset, 0, 0] [%dim_0, %dim_1, %dim_2] [1, 1, 1] :59        memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>> to60        memref<?x?x?xf32, strided<[?, ?, ?], offset: ?>>61    return62}63 64 65func.func @main() {66  %0 = arith.constant 0 : index67  %1 = arith.constant 1 : index68  %n1 = arith.constant -1 : index69  %4 = arith.constant 4 : index70  %5 = arith.constant 5 : index71 72  %alloca = memref.alloca() : memref<1xf32>73  %alloca_4 = memref.alloca() : memref<4x4xf32>74  %alloca_4_dyn = memref.cast %alloca_4 : memref<4x4xf32> to memref<?x4xf32>75 76  // Offset is out-of-bounds and slice runs out-of-bounds77  //      CHECK: ERROR: Runtime op verification failed78  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}, 0] [%{{.*}}, 1] [%{{.*}}, 1] : memref<?x4xf32> to memref<?xf32, strided<[?], offset: ?>>79  // CHECK-NEXT: ^ offset 0 is out-of-bounds80  // CHECK-NEXT: Location: loc({{.*}})81  //      CHECK: ERROR: Runtime op verification failed82  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}, 0] [%{{.*}}, 1] [%{{.*}}, 1] : memref<?x4xf32> to memref<?xf32, strided<[?], offset: ?>>83  // CHECK-NEXT: ^ subview runs out-of-bounds along dimension 084  // CHECK-NEXT: Location: loc({{.*}})85  func.call @subview_dynamic_rank_reduce(%alloca_4_dyn, %5, %5, %1) : (memref<?x4xf32>, index, index, index) -> ()86 87  // Offset is out-of-bounds and slice runs out-of-bounds88  //      CHECK: ERROR: Runtime op verification failed89  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}] [1] [1] : memref<1xf32> to memref<1xf32, strided<[1], offset: ?>>90  // CHECK-NEXT: ^ offset 0 is out-of-bounds91  // CHECK-NEXT: Location: loc({{.*}})92  //      CHECK: ERROR: Runtime op verification failed93  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}] [1] [1] : memref<1xf32> to memref<1xf32, strided<[1], offset: ?>>94  // CHECK-NEXT: ^ subview runs out-of-bounds along dimension 095  // CHECK-NEXT: Location: loc({{.*}})96  func.call @subview(%alloca, %1) : (memref<1xf32>, index) -> ()97 98  // Offset is out-of-bounds and slice runs out-of-bounds99  //      CHECK: ERROR: Runtime op verification failed100  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}] [1] [1] : memref<1xf32> to memref<1xf32, strided<[1], offset: ?>>101  // CHECK-NEXT: ^ offset 0 is out-of-bounds102  // CHECK-NEXT: Location: loc({{.*}})103  //      CHECK: ERROR: Runtime op verification failed104  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}] [1] [1] : memref<1xf32> to memref<1xf32, strided<[1], offset: ?>>105  // CHECK-NEXT: ^ subview runs out-of-bounds along dimension 0106  // CHECK-NEXT: Location: loc({{.*}})107  func.call @subview(%alloca, %n1) : (memref<1xf32>, index) -> ()108 109  // Slice runs out-of-bounds due to size110  //      CHECK: ERROR: Runtime op verification failed111  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}, 0] [%{{.*}}, 4] [%{{.*}}, 1] : memref<?x4xf32> to memref<?x4xf32, strided<[?, 1], offset: ?>>112  // CHECK-NEXT: ^ subview runs out-of-bounds along dimension 0113  // CHECK-NEXT: Location: loc({{.*}})114  func.call @subview_dynamic(%alloca_4_dyn, %0, %5, %1) : (memref<?x4xf32>, index, index, index) -> ()115 116  // Slice runs out-of-bounds due to stride117  //      CHECK: ERROR: Runtime op verification failed118  // CHECK-NEXT: memref.subview %{{.*}}[%{{.*}}, 0] [%{{.*}}, 4] [%{{.*}}, 1] : memref<?x4xf32> to memref<?x4xf32, strided<[?, 1], offset: ?>>119  // CHECK-NEXT: ^ subview runs out-of-bounds along dimension 0120  // CHECK-NEXT: Location: loc({{.*}})121  func.call @subview_dynamic(%alloca_4_dyn, %0, %4, %4) : (memref<?x4xf32>, index, index, index) -> ()122 123  // CHECK-NOT: ERROR: Runtime op verification failed124  func.call @subview(%alloca, %0) : (memref<1xf32>, index) -> ()125 126  // CHECK-NOT: ERROR: Runtime op verification failed127  func.call @subview_dynamic(%alloca_4_dyn, %0, %4, %1) : (memref<?x4xf32>, index, index, index) -> ()128 129  // CHECK-NOT: ERROR: Runtime op verification failed130  func.call @subview_dynamic_rank_reduce(%alloca_4_dyn, %0, %1, %0) : (memref<?x4xf32>, index, index, index) -> ()131 132  %alloca_10x4x1 = memref.alloca() : memref<10x4x1xf32>133  %alloca_10x4x1_dyn_stride = memref.cast %alloca_10x4x1 : memref<10x4x1xf32> to memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>>134  // CHECK-NOT: ERROR: Runtime op verification failed135  %dim_0 = arith.constant 0 : index136  %dim_1 = arith.constant 4 : index137  %dim_2 = arith.constant 1 : index138  func.call @subview_zero_size_dim(%alloca_10x4x1_dyn_stride, %dim_0, %dim_1, %dim_2)139                                        : (memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>>, index, index, index) -> ()140 141  // CHECK-NOT: ERROR: Runtime op verification failed142  %offset = arith.constant 10 : index143  func.call @subview_with_empty_slice(%alloca_10x4x1_dyn_stride, %dim_0, %dim_1, %dim_2, %offset)144                                        : (memref<10x4x1xf32, strided<[?, ?, ?], offset: ?>>, index, index, index, index) -> ()145  return146}147