1// RUN: mlir-opt %s -finalizing-bufferize -split-input-file -verify-diagnostics | FileCheck %s
2
3// CHECK-LABEL:   func @eliminate_materializations(
4// CHECK-SAME:                                     %[[ARG:.*]]: memref<f32>) -> memref<f32> {
5// CHECK:           return %[[ARG]] : memref<f32>
6func @eliminate_materializations(%arg0: memref<f32>) -> memref<f32> {
7  %0 = tensor_load %arg0 : memref<f32>
8  %1 = tensor_to_memref %0 : memref<f32>
9  return %1 : memref<f32>
10}
11
12// -----
13
14func @unable_to_convert_lone_tensor_to_memref() -> memref<f32> {
15  // expected-error @+1 {{failed to legalize operation 'test.source'}}
16  %0 = "test.source"() : () -> tensor<f32>
17  %1 = tensor_to_memref %0 : memref<f32>
18  return %1 : memref<f32>
19}
20
21// -----
22
23func @unable_to_convert_lone_tensor_load(%arg0: memref<f32>) {
24  %0 = tensor_load %arg0 : memref<f32>
25  // expected-error @+1 {{failed to legalize operation 'test.sink'}}
26  "test.sink"(%0) : (tensor<f32>) -> ()
27  return
28}
29