brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 9d206b1 Raw
56 lines · plain
1// RUN: mlir-opt %s -one-shot-bufferize="allow-unknown-ops allow-return-allocs-from-loops" -split-input-file -verify-diagnostics2 3func.func @inconsistent_memory_space_scf_if(%c: i1) -> tensor<10xf32> {4  // Yielding tensors with different memory spaces. Such IR cannot be5  // bufferized.6  %0 = bufferization.alloc_tensor() {memory_space = 0 : ui64} : tensor<10xf32>7  %1 = bufferization.alloc_tensor() {memory_space = 1 : ui64} : tensor<10xf32>8  // expected-error @+1 {{inconsistent memory space on then/else branches}}9  %r = scf.if %c -> tensor<10xf32> {10    // expected-error @+1 {{failed to bufferize op}}11    scf.yield %0 : tensor<10xf32>12  } else {13    scf.yield %1 : tensor<10xf32>14  }15  func.return %r : tensor<10xf32>16}17 18// -----19 20func.func @execute_region_multiple_yields(%t: tensor<5xf32>) -> tensor<5xf32> {21  // expected-error @below{{op op without unique scf.yield is not supported}}22  %0 = scf.execute_region -> tensor<5xf32> {23    scf.yield %t : tensor<5xf32>24  ^bb1(%arg1 : tensor<5xf32>):25    scf.yield %arg1 : tensor<5xf32>26  }27  func.return %0 : tensor<5xf32>28}29 30// -----31 32func.func @execute_region_no_yield(%t: tensor<5xf32>) -> tensor<5xf32> {33  // expected-error @below{{op op without unique scf.yield is not supported}}34  %0 = scf.execute_region -> tensor<5xf32> {35    cf.br ^bb0(%t : tensor<5xf32>)36  ^bb0(%arg0 : tensor<5xf32>):37    cf.br ^bb1(%arg0: tensor<5xf32>)38  ^bb1(%arg1 : tensor<5xf32>):39    cf.br ^bb0(%arg1: tensor<5xf32>)40  }41  func.return %0 : tensor<5xf32>42}43 44// -----45 46func.func @inconsistent_memory_space_scf_for(%lb: index, %ub: index, %step: index) -> tensor<10xf32> {47  %0 = bufferization.alloc_tensor() {memory_space = 0 : ui64} : tensor<10xf32>48  %1 = bufferization.alloc_tensor() {memory_space = 1 : ui64} : tensor<10xf32>49  // expected-error @below{{init_arg and yielded value bufferize to inconsistent memory spaces}}50  %2 = scf.for %iv = %lb to %ub step %step iter_args(%arg = %0) -> tensor<10xf32> {51    // expected-error @below {{failed to bufferize op}}52    scf.yield %1 : tensor<10xf32>53  }54  return %2 : tensor<10xf32>55}56