MLIR 22.0.0git
Bufferize.h
Go to the documentation of this file.
1//===- Bufferize.h - Bufferization Utilities --------------------*- C++ -*-===//
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// We use the term "bufferize" to mean conversion from tensor types to
10// memref types.
11//
12// Generally speaking, for each op that operates on tensor types, the
13// `BufferizableOpInterface` needs to be implemented. This file contains the
14// bufferization driver that is responsible for bufferizing the ops in the right
15// order, etc.
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERIZE_H
20#define MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERIZE_H
21
23
24namespace mlir {
25namespace bufferization {
26
27class AnalysisState;
28struct BufferizationOptions;
29class BufferizationState;
30class OpFilter;
31
32/// Bufferization statistics for debugging. These can be printed after running
33/// the OneShotBufferizePass with `-mlir-pass-statistics`. See the pass
34/// definition for more details.
41
42/// Bufferize `op` and its nested ops that implement `BufferizableOpInterface`.
43///
44/// Note: This function does not resolve read-after-write conflicts. Use this
45/// function only if it is guaranteed that the input IR can bufferize without
46/// additional buffer copies or set "options.copyBeforeWrite = true". The
47/// general bufferization entry point is `runOneShotBufferize`.
48LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options,
49 BufferizationState &bufferizationState,
50 BufferizationStatistics *statistics = nullptr);
51
52/// Bufferize the signature of `block` and its callers (i.e., ops that have the
53/// given block as a successor). All block argument types are changed to memref
54/// types. All corresponding operands of all callers are wrapped in
55/// bufferization.to_buffer ops. All uses of bufferized tensor block arguments
56/// are wrapped in bufferization.to_tensor ops.
57///
58/// It is expected that all callers implement the `BranchOpInterface`.
59/// Otherwise, this function will fail. The `BranchOpInterface` is used to query
60/// the range of operands that are forwarded to this block.
61///
62/// It is expected that the parent op of this block implements the
63/// `BufferizableOpInterface`. The buffer types of tensor block arguments are
64/// computed with `BufferizableOpIntercace::getBufferType`.
65LogicalResult bufferizeBlockSignature(Block *block, RewriterBase &rewriter,
67 BufferizationState &state);
68
69} // namespace bufferization
70} // namespace mlir
71
72#endif // MLIR_DIALECT_BUFFERIZATION_TRANSFORMS_BUFFERIZE_H
static llvm::ManagedStatic< PassManagerOptions > options
Block represents an ordered list of Operations.
Definition Block.h:33
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
LogicalResult bufferizeOp(Operation *op, const BufferizationOptions &options, BufferizationState &bufferizationState, BufferizationStatistics *statistics=nullptr)
Bufferize op and its nested ops that implement BufferizableOpInterface.
LogicalResult bufferizeBlockSignature(Block *block, RewriterBase &rewriter, const BufferizationOptions &options, BufferizationState &state)
Bufferize the signature of block and its callers (i.e., ops that have the given block as a successor)...
Include the generated interface declarations.
Bufferization statistics for debugging.
Definition Bufferize.h:35