22 lines · plain
1// RUN: mlir-opt %s -one-shot-bufferize="must-infer-memory-space" -split-input-file -verify-diagnostics2 3func.func @inconsistent_memory_space_arith_select(%c: i1) -> tensor<10xf32> {4 // Selecting 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 @+2 {{inconsistent memory space on true/false operands}}9 // expected-error @+1 {{failed to bufferize op}}10 %r = arith.select %c, %0, %1 : tensor<10xf32>11 func.return %r : tensor<10xf32>12}13 14// -----15 16func.func @unknown_memory_space(%idx: index, %v: i32) -> tensor<3xi32> {17 // expected-error @+2 {{could not infer memory space}}18 // expected-error @+1 {{failed to bufferize op}}19 %cst = arith.constant dense<[5, 1000, 20]> : tensor<3xi32>20 %0 = tensor.insert %v into %cst[%idx] : tensor<3xi32>21 return %0 : tensor<3xi32>22}