forked from OSchip/llvm-project
29 lines
962 B
MLIR
29 lines
962 B
MLIR
|
// RUN: mlir-opt %s -finalizing-bufferize -split-input-file -verify-diagnostics | FileCheck %s
|
||
|
|
||
|
// CHECK-LABEL: func @eliminate_materializations(
|
||
|
// CHECK-SAME: %[[ARG:.*]]: memref<f32>) -> memref<f32> {
|
||
|
// CHECK: return %[[ARG]] : memref<f32>
|
||
|
func @eliminate_materializations(%arg0: memref<f32>) -> memref<f32> {
|
||
|
%0 = tensor_load %arg0 : memref<f32>
|
||
|
%1 = tensor_to_memref %0 : memref<f32>
|
||
|
return %1 : memref<f32>
|
||
|
}
|
||
|
|
||
|
// -----
|
||
|
|
||
|
func @unable_to_convert_lone_tensor_to_memref() -> memref<f32> {
|
||
|
// expected-error @+1 {{failed to legalize operation 'test.source'}}
|
||
|
%0 = "test.source"() : () -> tensor<f32>
|
||
|
%1 = tensor_to_memref %0 : memref<f32>
|
||
|
return %1 : memref<f32>
|
||
|
}
|
||
|
|
||
|
// -----
|
||
|
|
||
|
func @unable_to_convert_lone_tensor_load(%arg0: memref<f32>) {
|
||
|
%0 = tensor_load %arg0 : memref<f32>
|
||
|
// expected-error @+1 {{failed to legalize operation 'test.sink'}}
|
||
|
"test.sink"(%0) : (tensor<f32>) -> ()
|
||
|
return
|
||
|
}
|