76 lines · plain
1// RUN: mlir-opt %s -generate-runtime-verification \2// RUN: -one-shot-bufferize="bufferize-function-boundaries" \3// RUN: -buffer-deallocation-pipeline=private-function-dynamic-ownership \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=%tlir_runner_utils 2>&1 | \9// RUN: FileCheck %s10 11// RUN: mlir-opt %s -generate-runtime-verification \12// RUN: -one-shot-bufferize="bufferize-function-boundaries" \13// RUN: -buffer-deallocation-pipeline=private-function-dynamic-ownership \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=%tlir_runner_utils 2>&1 | \20// RUN: FileCheck %s21 22func.func @extract(%tensor: tensor<1xf32>, %index: index) {23 tensor.extract %tensor[%index] : tensor<1xf32>24 return25}26 27func.func @extract_dynamic(%tensor: tensor<?xf32>, %index: index) {28 tensor.extract %tensor[%index] : tensor<?xf32>29 return30}31 32func.func @extract_nd_dynamic(%tensor: tensor<?x?x?xf32>, %index0: index, %index1: index, %index2: index) {33 tensor.extract %tensor[%index0, %index1, %index2] : tensor<?x?x?xf32>34 return35}36 37func.func @main() {38 %0 = arith.constant 0 : index39 %1 = arith.constant 1 : index40 %n1 = arith.constant -1 : index41 %2 = arith.constant 2 : index42 %alloca_1 = tensor.empty() : tensor<1xf32>43 %alloc_1 = tensor.empty(%1) : tensor<?xf32>44 %alloc_2x2x2 = tensor.empty(%2, %2, %2) : tensor<?x?x?xf32>45 46 // CHECK: ERROR: Runtime op verification failed47 // CHECK-NEXT: tensor.extract %{{.*}}[%{{.*}}] : tensor<1xf32>48 // CHECK-NEXT: ^ out-of-bounds access49 // CHECK-NEXT: Location: loc({{.*}})50 func.call @extract(%alloca_1, %1) : (tensor<1xf32>, index) -> ()51 52 // CHECK: ERROR: Runtime op verification failed53 // CHECK-NEXT: tensor.extract %{{.*}}[%{{.*}}] : tensor<?xf32>54 // CHECK-NEXT: ^ out-of-bounds access55 // CHECK-NEXT: Location: loc({{.*}})56 func.call @extract_dynamic(%alloc_1, %1) : (tensor<?xf32>, index) -> ()57 58 // CHECK: ERROR: Runtime op verification failed59 // CHECK-NEXT: tensor.extract %{{.*}}[%{{.*}}, %{{.*}}, %{{.*}}] : tensor<?x?x?xf32>60 // CHECK-NEXT: ^ out-of-bounds access61 // CHECK-NEXT: Location: loc({{.*}})62 func.call @extract_nd_dynamic(%alloc_2x2x2, %1, %n1, %0) : (tensor<?x?x?xf32>, index, index, index) -> ()63 64 // CHECK-NOT: ERROR: Runtime op verification failed65 func.call @extract(%alloca_1, %0) : (tensor<1xf32>, index) -> ()66 67 // CHECK-NOT: ERROR: Runtime op verification failed68 func.call @extract_dynamic(%alloc_1, %0) : (tensor<?xf32>, index) -> ()69 70 // CHECK-NOT: ERROR: Runtime op verification failed71 func.call @extract_nd_dynamic(%alloc_2x2x2, %1, %1, %0) : (tensor<?x?x?xf32>, index, index, index) -> ()72 73 return74}75 76