MLIR  16.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::createTensorBufferizePass() {
57  return std::make_unique<TensorBufferizePass>();
58 }
Include the generated interface declarations.
OpFilter opFilter
A filter that specifies which ops should be bufferized and which ops should be ignored.
void allowDialect()
Allow the given dialects.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value...
Definition: LogicalResult.h:72
std::unique_ptr< Pass > createTensorBufferizePass()
Creates an instance of tensor dialect bufferization pass.
Definition: Bufferize.cpp:56
Options for BufferizableOpInterface-based bufferization.
static llvm::ManagedStatic< PassManagerOptions > options
void registerBufferizableOpInterfaceExternalModels(DialectRegistry &registry)
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options, bool copyBeforeWrite=true, const OpFilter *opFilter=nullptr)
Bufferize op and its nested ops that implement BufferizableOpInterface.
Definition: Bufferize.cpp:388
BufferizationOptions getPartialBufferizationOptions()
Definition: Bufferize.cpp:485