MLIR  19.0.0git
Bufferize.cpp
Go to the documentation of this file.
1 //===- Bufferize.cpp - Bufferization for `tensor` dialect ops -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements bufferization of `tensor` dialect ops
10 //
11 //===----------------------------------------------------------------------===//
12 
25 
26 namespace mlir {
27 namespace tensor {
28 #define GEN_PASS_DEF_TENSORBUFFERIZE
29 #include "mlir/Dialect/Tensor/Transforms/Passes.h.inc"
30 } // namespace tensor
31 } // namespace mlir
32 
33 using namespace mlir;
34 using namespace bufferization;
35 
36 namespace {
37 struct TensorBufferizePass
38  : public tensor::impl::TensorBufferizeBase<TensorBufferizePass> {
39  void runOnOperation() override {
41  options.opFilter.allowDialect<tensor::TensorDialect>();
42 
43  if (failed(bufferizeOp(getOperation(), options)))
44  signalPassFailure();
45  }
46 
47  void getDependentDialects(DialectRegistry &registry) const override {
48  registry
49  .insert<bufferization::BufferizationDialect, memref::MemRefDialect,
50  tensor::TensorDialect, scf::SCFDialect, arith::ArithDialect>();
52  }
53 };
54 } // namespace
55 
56 std::unique_ptr<Pass> mlir::tensor::createTensorBufferizePass() {
57  return std::make_unique<TensorBufferizePass>();
58 }
static llvm::ManagedStatic< PassManagerOptions > options
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Bufferize op and its nested ops that implement BufferizableOpInterface.
Definition: Bufferize.cpp:441
BufferizationOptions getPartialBufferizationOptions()
Return BufferizationOptions such that the bufferizeOp behaves like the old (deprecated) partial,...
Definition: Bufferize.cpp:645
void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry)
std::unique_ptr< Pass > createTensorBufferizePass()
Creates an instance of the tensor dialect bufferization pass.
Definition: Bufferize.cpp:56
Include the generated interface declarations.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
Definition: LogicalResult.h:72
Options for BufferizableOpInterface-based bufferization.