62 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 private @cast_to_static_dim(%t: tensor<?xf32>) -> tensor<10xf32> {23 %0 = tensor.cast %t : tensor<?xf32> to tensor<10xf32>24 return %0 : tensor<10xf32>25}26 27func.func private @cast_to_ranked(%t: tensor<*xf32>) -> tensor<f32> {28 %0 = tensor.cast %t : tensor<*xf32> to tensor<f32>29 return %0 : tensor<f32>30}31 32func.func private @valid_cast(%t: tensor<*xf32>) -> tensor<?xf32> {33 %0 = tensor.cast %t : tensor<*xf32> to tensor<?xf32>34 return %0 : tensor<?xf32>35}36 37func.func @main() {38 // All casts inside the called functions are invalid at runtime, except for39 // the last one.40 %alloc = tensor.empty() : tensor<5xf32>41 42 // CHECK: ERROR: Runtime op verification failed43 // CHECK-NEXT: tensor.cast %{{.*}} : tensor<?xf32> to tensor<10xf32>44 // CHECK-NEXT: ^ size mismatch of dim 045 // CHECK-NEXT: Location: loc({{.*}})46 %1 = tensor.cast %alloc : tensor<5xf32> to tensor<?xf32>47 func.call @cast_to_static_dim(%1) : (tensor<?xf32>) -> (tensor<10xf32>)48 49 // CHECK-NEXT: ERROR: Runtime op verification failed50 // CHECK-NEXT: tensor.cast %{{.*}} : tensor<*xf32> to tensor<f32>51 // CHECK-NEXT: ^ rank mismatch52 // CHECK-NEXT: Location: loc({{.*}})53 %3 = tensor.cast %alloc : tensor<5xf32> to tensor<*xf32>54 func.call @cast_to_ranked(%3) : (tensor<*xf32>) -> (tensor<f32>)55 56 // A last cast that actually succeeds.57 // CHECK-NOT: ERROR: Runtime op verification failed58 func.call @valid_cast(%3) : (tensor<*xf32>) -> (tensor<?xf32>)59 60 return61}62