MLIR
20.0.0git
|
Options for BufferizableOpInterface-based bufferization. More...
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
Public Types | |
using | AllocationFn = std::function< FailureOr< Value >(OpBuilder &, Location, MemRefType, ValueRange, unsigned int)> |
Allocator function: Generate a memref allocation with the given type, dynamic extents and alignment. More... | |
using | MemCpyFn = std::function< LogicalResult(OpBuilder &, Location, Value, Value)> |
Memcpy function: Generate a memcpy between two buffers. More... | |
using | AnalysisStateInitFn = std::function< void(AnalysisState &)> |
Initializer function for analysis state. More... | |
using | FunctionArgTypeConverterFn = std::function< BaseMemRefType(TensorType, Attribute memorySpace, func::FuncOp, const BufferizationOptions &)> |
Tensor -> MemRef type converter. More... | |
using | UnknownTypeConverterFn = std::function< BaseMemRefType(Value, Attribute memorySpace, const BufferizationOptions &)> |
Tensor -> MemRef type converter. More... | |
using | DefaultMemorySpaceFn = std::function< std::optional< Attribute >(TensorType t)> |
Public Member Functions | |
BufferizationOptions () | |
BufferizableOpInterface | dynCastBufferizableOp (Operation *op) const |
Try to cast the given op to BufferizableOpInterface if the op is allow listed. More... | |
BufferizableOpInterface | dynCastBufferizableOp (Value value) const |
Try to cast the given value to BufferizableOpInterface if the op is allow listed. More... | |
bool | isOpAllowed (Operation *op) const |
Return true if the given op should be bufferized. More... | |
FailureOr< Value > | createAlloc (OpBuilder &b, Location loc, MemRefType type, ValueRange dynShape) const |
Create a memref allocation with the given type and dynamic extents. More... | |
LogicalResult | createMemCpy (OpBuilder &b, Location loc, Value from, Value to) const |
Creates a memcpy between two given buffers. More... | |
void | setFunctionBoundaryTypeConversion (LayoutMapOption layoutMapOption) |
This function controls buffer types on function signatures. More... | |
Public Attributes | |
OpFilter | opFilter |
A filter that specifies which ops should be bufferized and which ops should be ignored. More... | |
std::optional< AllocationFn > | allocationFn |
Helper functions for allocation and memory copying. More... | |
std::optional< MemCpyFn > | memCpyFn |
bool | allowUnknownOps = false |
Specifies whether not bufferizable ops are allowed in the input. More... | |
bool | bufferizeFunctionBoundaries = false |
Specifies whether function boundaries (ops in the func dialect) should be bufferized or not. More... | |
bool | checkParallelRegions = true |
bool | enforceAliasingInvariants = true |
Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for). More... | |
FunctionArgTypeConverterFn | functionArgTypeConverterFn = nullptr |
Type converter from tensors to memrefs. More... | |
bool | inferFunctionResultLayout = true |
If true, function result types are inferred from the body of the function. More... | |
UnknownTypeConverterFn | unknownTypeConverterFn = nullptr |
Type converter from tensors to memrefs. More... | |
DefaultMemorySpaceFn | defaultMemorySpaceFn |
bool | copyBeforeWrite = false |
If set to true , the analysis is skipped. More... | |
bool | testAnalysisOnly = false |
If set to true , does not modify the IR apart from adding attributes (for checking the results of the analysis) and post analysis steps. More... | |
bool | printConflicts = false |
If set to true , the IR is annotated with details about RaW conflicts. More... | |
unsigned int | bufferAlignment = 64 |
Buffer alignment for new memory allocations. More... | |
SmallVector< AnalysisStateInitFn > | stateInitializers |
Initializer functions for analysis state. More... | |
Options for BufferizableOpInterface-based bufferization.
Definition at line 252 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::AllocationFn = std::function<FailureOr<Value>( OpBuilder &, Location, MemRefType, ValueRange, unsigned int)> |
Allocator function: Generate a memref allocation with the given type, dynamic extents and alignment.
Definition at line 255 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::AnalysisStateInitFn = std::function<void(AnalysisState &)> |
Initializer function for analysis state.
Definition at line 261 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::DefaultMemorySpaceFn = std::function<std::optional<Attribute>(TensorType t)> |
Definition at line 272 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::FunctionArgTypeConverterFn = std::function<BaseMemRefType(TensorType, Attribute memorySpace, func::FuncOp, const BufferizationOptions &)> |
Tensor -> MemRef type converter.
Parameters: tensor type, memory space, func op, bufferization options
Definition at line 264 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::MemCpyFn = std::function<LogicalResult(OpBuilder &, Location, Value, Value)> |
Memcpy function: Generate a memcpy between two buffers.
Definition at line 258 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::UnknownTypeConverterFn = std::function<BaseMemRefType( Value, Attribute memorySpace, const BufferizationOptions &)> |
Tensor -> MemRef type converter.
Parameters: Value, memory space, bufferization options
Definition at line 269 of file BufferizableOpInterface.h.
BufferizationOptions::BufferizationOptions | ( | ) |
Definition at line 332 of file BufferizableOpInterface.cpp.
FailureOr< Value > BufferizationOptions::createAlloc | ( | OpBuilder & | b, |
Location | loc, | ||
MemRefType | type, | ||
ValueRange | dynShape | ||
) | const |
Create a memref allocation with the given type and dynamic extents.
Definition at line 734 of file BufferizableOpInterface.cpp.
References allocationFn, bufferAlignment, mlir::OpBuilder::create(), and mlir::Builder::getI64IntegerAttr().
LogicalResult BufferizationOptions::createMemCpy | ( | OpBuilder & | b, |
Location | loc, | ||
Value | from, | ||
Value | to | ||
) | const |
Creates a memcpy between two given buffers.
Create a memory copy between two memref buffers.
Definition at line 750 of file BufferizableOpInterface.cpp.
References mlir::OpBuilder::create(), and memCpyFn.
BufferizableOpInterface BufferizationOptions::dynCastBufferizableOp | ( | Operation * | op | ) | const |
Try to cast the given op to BufferizableOpInterface if the op is allow listed.
Definition at line 347 of file BufferizableOpInterface.cpp.
References isOpAllowed().
Referenced by mlir::bufferization::AnalysisState::bufferizesToMemoryWrite(), dynCastBufferizableOp(), mlir::bufferization::AnalysisState::findValueInReverseUseDefChain(), and mlir::bufferization::OneShotAnalysisState::gatherUndefinedTensorUses().
BufferizableOpInterface BufferizationOptions::dynCastBufferizableOp | ( | Value | value | ) | const |
Try to cast the given value to BufferizableOpInterface if the op is allow listed.
Definition at line 357 of file BufferizableOpInterface.cpp.
References dynCastBufferizableOp(), and mlir::bufferization::getOwnerOfValue().
bool BufferizationOptions::isOpAllowed | ( | Operation * | op | ) | const |
Return true
if the given op should be bufferized.
Definition at line 336 of file BufferizableOpInterface.cpp.
References bufferizeFunctionBoundaries, mlir::Operation::getDialect(), mlir::bufferization::OpFilter::isOpAllowed(), and opFilter.
Referenced by dynCastBufferizableOp().
void BufferizationOptions::setFunctionBoundaryTypeConversion | ( | LayoutMapOption | layoutMapOption | ) |
This function controls buffer types on function signatures.
Sets functionArgTypeConverterFn
and inferFunctionResultLayout
accordingly.
Note: Inferred layout maps may not be desireable when interacting with external functions, because the generated function signatures will be less predictable.
Definition at line 361 of file BufferizableOpInterface.cpp.
References functionArgTypeConverterFn, mlir::bufferization::getMemRefTypeWithFullyDynamicLayout(), mlir::bufferization::getMemRefTypeWithStaticIdentityLayout(), inferFunctionResultLayout, and options.
std::optional<AllocationFn> mlir::bufferization::BufferizationOptions::allocationFn |
Helper functions for allocation and memory copying.
Definition at line 293 of file BufferizableOpInterface.h.
Referenced by createAlloc().
bool mlir::bufferization::BufferizationOptions::allowUnknownOps = false |
Specifies whether not bufferizable ops are allowed in the input.
If so, bufferization.to_memref and bufferization.to_tensor ops are inserted at the boundaries.
Definition at line 307 of file BufferizableOpInterface.h.
unsigned int mlir::bufferization::BufferizationOptions::bufferAlignment = 64 |
Buffer alignment for new memory allocations.
Definition at line 388 of file BufferizableOpInterface.h.
Referenced by createAlloc().
bool mlir::bufferization::BufferizationOptions::bufferizeFunctionBoundaries = false |
Specifies whether function boundaries (ops in the func dialect) should be bufferized or not.
Definition at line 311 of file BufferizableOpInterface.h.
Referenced by isOpAllowed().
bool mlir::bufferization::BufferizationOptions::checkParallelRegions = true |
Definition at line 316 of file BufferizableOpInterface.h.
bool mlir::bufferization::BufferizationOptions::copyBeforeWrite = false |
If set to true
, the analysis is skipped.
A buffer is copied before every write. This flag cannot be used together with testAnalysisOnly = true
.
Definition at line 377 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::bufferizeModuleOp().
DefaultMemorySpaceFn mlir::bufferization::BufferizationOptions::defaultMemorySpaceFn |
Definition at line 372 of file BufferizableOpInterface.h.
bool mlir::bufferization::BufferizationOptions::enforceAliasingInvariants = true |
Certain ops have aliasing OpOperand/OpResult invariants (e.g., scf.for).
If this flag is set to false
, those invariants are no longer enforced with buffer copies.
Note: Deactivating this flag can lead to incorrect bufferization results when used incorrectly. This flag is useful with AlwaysCopyAnalysisState
which bufferizes all writing tensor OpOperands out-of-place.
Definition at line 326 of file BufferizableOpInterface.h.
FunctionArgTypeConverterFn mlir::bufferization::BufferizationOptions::functionArgTypeConverterFn = nullptr |
Type converter from tensors to memrefs.
This type converter is used to determine bufferized function argument and result types. By default, a type converter that returns a memref type with a fully dynamic layout map is used.
If bufferizeFunctionBoundaries
is not set, this function isn't used.
Definition at line 353 of file BufferizableOpInterface.h.
Referenced by setFunctionBoundaryTypeConversion().
bool mlir::bufferization::BufferizationOptions::inferFunctionResultLayout = true |
If true, function result types are inferred from the body of the function.
Otherwise, function result type is determined by functionArgTypeConverterFn
.
If bufferizeFunctionBoundaries
is not set, this flag has no effect.
Definition at line 360 of file BufferizableOpInterface.h.
Referenced by setFunctionBoundaryTypeConversion().
std::optional<MemCpyFn> mlir::bufferization::BufferizationOptions::memCpyFn |
Definition at line 294 of file BufferizableOpInterface.h.
Referenced by createMemCpy().
OpFilter mlir::bufferization::BufferizationOptions::opFilter |
A filter that specifies which ops should be bufferized and which ops should be ignored.
Definition at line 287 of file BufferizableOpInterface.h.
Referenced by isOpAllowed(), mlir::sparse_tensor::SparsificationAndBufferizationPass::runDenseBufferization(), and mlir::bufferization::runOneShotModuleBufferize().
bool mlir::bufferization::BufferizationOptions::printConflicts = false |
If set to true
, the IR is annotated with details about RaW conflicts.
For debugging only. Should be used together with testAnalysisOnly
.
Definition at line 385 of file BufferizableOpInterface.h.
SmallVector<AnalysisStateInitFn> mlir::bufferization::BufferizationOptions::stateInitializers |
Initializer functions for analysis state.
These can be used to initialize dialect-specific analysis state.
Definition at line 392 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::AnalysisState::AnalysisState().
bool mlir::bufferization::BufferizationOptions::testAnalysisOnly = false |
If set to true
, does not modify the IR apart from adding attributes (for checking the results of the analysis) and post analysis steps.
Definition at line 381 of file BufferizableOpInterface.h.
Referenced by mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation().
UnknownTypeConverterFn mlir::bufferization::BufferizationOptions::unknownTypeConverterFn = nullptr |
Type converter from tensors to memrefs.
This type converter is used if no memref type could be inferred during bufferization. By default, a type converter that returns a memref type with a fully dynamic layout map is used.
Definition at line 366 of file BufferizableOpInterface.h.