MLIR  19.0.0git
Bufferize.cpp
Go to the documentation of this file.
1 //===- Bufferize.cpp - Bufferization of linalg 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 
10 
19 #include "mlir/IR/BuiltinDialect.h"
20 #include "mlir/IR/Operation.h"
21 #include "mlir/Pass/Pass.h"
22 
23 namespace mlir {
24 #define GEN_PASS_DEF_LINALGBUFFERIZEPASS
25 #include "mlir/Dialect/Linalg/Passes.h.inc"
26 } // namespace mlir
27 
28 using namespace mlir;
29 using namespace bufferization;
30 
31 namespace {
32 /// Converts Linalg operations that work on tensor-type operands or results to
33 /// work on buffers.
34 struct LinalgBufferizePass
35  : public impl::LinalgBufferizePassBase<LinalgBufferizePass> {
36  using impl::LinalgBufferizePassBase<
37  LinalgBufferizePass>::LinalgBufferizePassBase;
38  void runOnOperation() override {
40  options.opFilter.allowDialect<linalg::LinalgDialect>();
41 
42  if (failed(bufferizeOp(getOperation(), options)))
43  signalPassFailure();
44  }
45 
46  void getDependentDialects(DialectRegistry &registry) const override {
47  registry.insert<bufferization::BufferizationDialect, memref::MemRefDialect,
48  tensor::TensorDialect, linalg::LinalgDialect>();
50  }
51 };
52 } // namespace
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)
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.