Files
clang-p2996/mlir/test/Transforms/finalizing-bufferize.mlir
Sean Silva 774f1d3ffd [mlir] Small cleanups to func-bufferize/finalizing-bufferize
- Address TODO in scf-bufferize: the argument materialization issue is
  now fixed and the code is now in Transforms/Bufferize.cpp
- Tighten up finalizing-bufferize to avoid creating invalid IR when
  operand types potentially change
- Tidy up the testing of func-bufferize, and move appropriate tests
  to a new finalizing-bufferize.mlir
- The new stricter checking in finalizing-bufferize revealed that we
  needed a DimOp conversion pattern (found when integrating into npcomp).
  Previously, the converion infrastructure was blindly changing the
  operand type during finalization, which happened to work due to
  DimOp's tensor/memref polymorphism, but is generally not encouraged
  (the new pattern is the way to tell the conversion infrastructure that
  it is legal to change that type).
2020-11-30 17:04:14 -08:00

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
}