1// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2
3func.func @alloc_tensor_missing_dims(%arg0: index)
4{
5  // expected-error @+1 {{expected 2 dynamic sizes}}
6  %0 = bufferization.alloc_tensor(%arg0) : tensor<4x?x?x5xf32>
7  return
8}
9
10// -----
11
12// expected-note @+1 {{prior use here}}
13func.func @alloc_tensor_type_mismatch(%t: tensor<?xf32>) {
14  // expected-error @+1{{expects different type than prior uses: 'tensor<5xf32>' vs 'tensor<?xf32>'}}
15  %0 = bufferization.alloc_tensor() copy(%t) : tensor<5xf32>
16  return
17}
18
19// -----
20
21func.func @alloc_tensor_copy_and_dims(%t: tensor<?xf32>, %sz: index) {
22  // expected-error @+1{{dynamic sizes not needed when copying a tensor}}
23  %0 = bufferization.alloc_tensor(%sz) copy(%t) : tensor<?xf32>
24  return
25}
26
27// -----
28
29func.func @alloc_tensor_invalid_escape_attr(%sz: index) {
30  // expected-error @+1{{op attribute 'escape' failed to satisfy constraint: bool attribute}}
31  %0 = bufferization.alloc_tensor(%sz) {escape = 5} : tensor<?xf32>
32  return
33}
34