brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.2 KiB · 745eea3 Raw
129 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_slice(%tensor: tensor<1xf32>, %offset: index) {23    tensor.extract_slice %tensor[%offset] [1] [1] : tensor<1xf32> to tensor<1xf32>24    return25}26 27func.func @extract_slice_dynamic(%tensor: tensor<?x4xf32>, %offset: index, %size: index, %stride: index) {28    tensor.extract_slice %tensor[%offset, 0] [%size, 4] [%stride, 1] : tensor<?x4xf32> to tensor<?x4xf32>29    return30}31 32func.func @extract_slice_dynamic_rank_reduce(%tensor: tensor<?x4xf32>, %offset: index, %size: index, %stride: index) {33    tensor.extract_slice %tensor[%offset, 0] [%size, 1] [%stride, 1] : tensor<?x4xf32> to tensor<?xf32>34    return35}36 37func.func @extract_slice_zero_size_dim(%arg0: tensor<10x4x1xf32>, %dim_0: index, %dim_1: index, %dim_2: index) {38    tensor.extract_slice %arg0[0, 0, 0] [%dim_0, %dim_1, %dim_2] [1, 1, 1] : tensor<10x4x1xf32> to tensor<?x?x?xf32>39    return40}41 42func.func @extract_slice_empty_tensor(%arg0: tensor<10x4x1xf32>, %dim_0: index, %dim_1: index, %dim_2: index, %offset: index) {43    tensor.extract_slice %arg0[%offset, 0, 0] [%dim_0, %dim_1, %dim_2] [1, 1, 1] : tensor<10x4x1xf32> to tensor<?x?x?xf32>44    return45}46 47 48func.func @main() {49  %0 = arith.constant 0 : index50  %1 = arith.constant 1 : index51  %n1 = arith.constant -1 : index52  %4 = arith.constant 4 : index53  %5 = arith.constant 5 : index54 55  %alloca = tensor.empty() : tensor<1xf32>56  %alloca_4 = tensor.empty() : tensor<4x4xf32>57  %alloca_4_dyn = tensor.cast %alloca_4 : tensor<4x4xf32> to tensor<?x4xf32>58 59  // Offset is out-of-bounds and slice runs out-of-bounds60  //      CHECK: ERROR: Runtime op verification failed61  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}, 0] [%{{.*}}, 1] [%{{.*}}, 1] : tensor<?x4xf32> to tensor<?xf32>62  // CHECK-NEXT: ^ offset 0 is out-of-bounds63  // CHECK-NEXT: Location: loc({{.*}})64  //      CHECK: ERROR: Runtime op verification failed65  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}, 0] [%{{.*}}, 1] [%{{.*}}, 1] : tensor<?x4xf32> to tensor<?xf32>66  // CHECK-NEXT: ^ extract_slice runs out-of-bounds along dimension 067  // CHECK-NEXT: Location: loc({{.*}})68  func.call @extract_slice_dynamic_rank_reduce(%alloca_4_dyn, %5, %5, %1) : (tensor<?x4xf32>, index, index, index) -> ()69 70  // Offset is out-of-bounds and slice runs out-of-bounds71  //      CHECK: ERROR: Runtime op verification failed72  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}] [1] [1] : tensor<1xf32> to tensor<1xf32>73  // CHECK-NEXT: ^ offset 0 is out-of-bounds74  // CHECK-NEXT: Location: loc({{.*}})75  //      CHECK: ERROR: Runtime op verification failed76  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}] [1] [1] : tensor<1xf32> to tensor<1xf32>77  // CHECK-NEXT: ^ extract_slice runs out-of-bounds along dimension 078  // CHECK-NEXT: Location: loc({{.*}})79  func.call @extract_slice(%alloca, %1) : (tensor<1xf32>, index) -> ()80 81  // Offset is out-of-bounds and slice runs out-of-bounds82  //      CHECK: ERROR: Runtime op verification failed83  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}] [1] [1] : tensor<1xf32> to tensor<1xf32>84  // CHECK-NEXT: ^ offset 0 is out-of-bounds85  // CHECK-NEXT: Location: loc({{.*}})86  //      CHECK: ERROR: Runtime op verification failed87  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}] [1] [1] : tensor<1xf32> to tensor<1xf32>88  // CHECK-NEXT: ^ extract_slice runs out-of-bounds along dimension 089  // CHECK-NEXT: Location: loc({{.*}})90  func.call @extract_slice(%alloca, %n1) : (tensor<1xf32>, index) -> ()91 92  // Slice runs out-of-bounds due to size93  //      CHECK: ERROR: Runtime op verification failed94  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}, 0] [%{{.*}}, 4] [%{{.*}}, 1] : tensor<?x4xf32> to tensor<?x4xf32>95  // CHECK-NEXT: ^ extract_slice runs out-of-bounds along dimension 096  // CHECK-NEXT: Location: loc({{.*}})97  func.call @extract_slice_dynamic(%alloca_4_dyn, %0, %5, %1) : (tensor<?x4xf32>, index, index, index) -> ()98 99  // Slice runs out-of-bounds due to stride100  //      CHECK: ERROR: Runtime op verification failed101  // CHECK-NEXT: tensor.extract_slice %{{.*}}[%{{.*}}, 0] [%{{.*}}, 4] [%{{.*}}, 1] : tensor<?x4xf32> to tensor<?x4xf32>102  // CHECK-NEXT: ^ extract_slice runs out-of-bounds along dimension 0103  // CHECK-NEXT: Location: loc({{.*}})104  func.call @extract_slice_dynamic(%alloca_4_dyn, %0, %4, %4) : (tensor<?x4xf32>, index, index, index) -> ()105 106  // CHECK-NOT: ERROR: Runtime op verification failed107  func.call @extract_slice(%alloca, %0) : (tensor<1xf32>, index) -> ()108 109  // CHECK-NOT: ERROR: Runtime op verification failed110  func.call @extract_slice_dynamic(%alloca_4_dyn, %0, %4, %1) : (tensor<?x4xf32>, index, index, index) -> ()111 112  // CHECK-NOT: ERROR: Runtime op verification failed113  func.call @extract_slice_dynamic_rank_reduce(%alloca_4_dyn, %0, %1, %0) : (tensor<?x4xf32>, index, index, index) -> ()114 115  %cst10x4x1xf32 = arith.constant dense<1.0> : tensor<10x4x1xf32>116  117  // CHECK-NOT: ERROR: Runtime op verification failed118  %dim_0 = arith.constant 0 : index119  %dim_1 = arith.constant 4 : index120  %dim_2 = arith.constant 1 : index121  func.call @extract_slice_zero_size_dim(%cst10x4x1xf32, %dim_0, %dim_1, %dim_2) : (tensor<10x4x1xf32>, index, index, index) -> ()122 123  // CHECK-NOT: ERROR: Runtime op verification failed124  %offset = arith.constant 10 : index  125  func.call @extract_slice_empty_tensor(%cst10x4x1xf32, %dim_0, %dim_1, %dim_2, %offset) : (tensor<10x4x1xf32>, index, index, index, index) -> ()126 127  return128}129