MLIR
15.0.0git
|
Options for BufferizableOpInterface-based bufferization. More...
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
Public Types | |
enum | LayoutMapOption : int8_t { LayoutMapOption::InferLayoutMap = 0, LayoutMapOption::IdentityLayoutMap = 1, LayoutMapOption::FullyDynamicLayoutMap = 2 } |
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 | DeallocationFn = std::function< LogicalResult(OpBuilder &, Location, Value)> |
Deallocator function: Deallocate a buffer that was allocated with AllocatorFn. 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 | DialectStateInitFn = std::function< std::unique_ptr< DialectAnalysisState >()> |
Initializer function for dialect-specific analysis state. More... | |
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 | createDealloc (OpBuilder &b, Location loc, Value allocatedBuffer) const |
Creates a memref deallocation. More... | |
LogicalResult | createMemCpy (OpBuilder &b, Location loc, Value from, Value to) const |
Creates a memcpy between two given buffers. More... | |
void | addDialectStateInitializer (StringRef name, const DialectStateInitFn &fn) |
Add a analysis state initializer that initializes the specified dialect-specific analysis state. More... | |
Public Attributes | |
OpFilter | opFilter |
A filter that specifies which ops should be bufferized and which ops should be ignored. More... | |
Optional< AllocationFn > | allocationFn |
Helper functions for allocation, deallocation, memory copying. More... | |
Optional< DeallocationFn > | deallocationFn |
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... | |
LayoutMapOption | functionBoundaryTypeConversion |
This flag controls buffer types on function signatures. More... | |
LayoutMapOption | unknownTypeConversion |
This flag controls buffer types on unknown ops (to_memref wrappers) and in other cases where a precise memref type cannot be inferred (e.g., the bufferization of "tensor.cast"). More... | |
bool | createDeallocs = true |
Specifies whether dealloc ops should be generated along with alloc ops. More... | |
unsigned | analysisFuzzerSeed = 0 |
Seed for the analysis fuzzer. 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... | |
bool | promoteBufferResultsToOutParams = false |
If set to true , buffers that are returned from functions are replaced with buffer "out" parameters. More... | |
bool | alwaysAliasingWithDest = true |
If set to true , an getAliasingOpResult will return the corresponding "out"/"dest" OpOperand for every op that has the notion of an "out"/"dest" operand. More... | |
unsigned int | bufferAlignment = 128 |
Buffer alignment for new memory allocations. More... | |
SmallVector< AnalysisStateInitFn > | stateInitializers |
Initializer functions for analysis state. More... | |
Options for BufferizableOpInterface-based bufferization.
Definition at line 165 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 169 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::AnalysisStateInitFn = std::function<void(AnalysisState &)> |
Initializer function for analysis state.
Definition at line 178 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::DeallocationFn = std::function<LogicalResult(OpBuilder &, Location, Value)> |
Deallocator function: Deallocate a buffer that was allocated with AllocatorFn.
Definition at line 173 of file BufferizableOpInterface.h.
using mlir::bufferization::BufferizationOptions::DialectStateInitFn = std::function<std::unique_ptr<DialectAnalysisState>()> |
Initializer function for dialect-specific analysis state.
Definition at line 181 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 176 of file BufferizableOpInterface.h.
|
strong |
Enumerator | |
---|---|
InferLayoutMap | |
IdentityLayoutMap | |
FullyDynamicLayoutMap |
Definition at line 183 of file BufferizableOpInterface.h.
|
default |
Referenced by mlir::bufferization::OpFilter::isOpAllowed().
void BufferizationOptions::addDialectStateInitializer | ( | StringRef | name, |
const DialectStateInitFn & | fn | ||
) |
Add a analysis state initializer that initializes the specified dialect-specific analysis state.
Definition at line 105 of file BufferizableOpInterface.cpp.
References mlir::bufferization::AnalysisState::insertDialectState().
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 390 of file BufferizableOpInterface.cpp.
References mlir::OpBuilder::create(), and mlir::Builder::getI64IntegerAttr().
Referenced by mlir::bufferization::createAllocDeallocOps().
LogicalResult BufferizationOptions::createDealloc | ( | OpBuilder & | b, |
Location | loc, | ||
Value | allocatedBuffer | ||
) | const |
Creates a memref deallocation.
The given memref buffer must have been allocated using createAlloc
.
Definition at line 404 of file BufferizableOpInterface.cpp.
References mlir::OpBuilder::create(), and mlir::success().
Referenced by mlir::bufferization::createAllocDeallocOps().
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 500 of file BufferizableOpInterface.cpp.
References mlir::OpBuilder::create(), and mlir::success().
Referenced by mlir::bufferization::BufferizationState::getBuffer().
BufferizableOpInterface BufferizationOptions::dynCastBufferizableOp | ( | Operation * | op | ) | const |
Try to cast the given op to BufferizableOpInterface if the op is allow listed.
Definition at line 88 of file BufferizableOpInterface.cpp.
Referenced by aliasesNonWritableBuffer(), annotateOpsWithBufferizationMarkers(), checkAliasInfoConsistency(), equivalenceAnalysis(), mlir::bufferization::OneShotAnalysisState::gatherUndefinedTensorUses(), hasReadAfterWriteInterference(), inPlaceAnalysis(), and isMemoryWrite().
BufferizableOpInterface BufferizationOptions::dynCastBufferizableOp | ( | Value | value | ) | const |
Try to cast the given value to BufferizableOpInterface if the op is allow listed.
Definition at line 98 of file BufferizableOpInterface.cpp.
References mlir::Value::getDefiningOp().
bool BufferizationOptions::isOpAllowed | ( | Operation * | op | ) | const |
Return true
if the given op should be bufferized.
Definition at line 77 of file BufferizableOpInterface.cpp.
References mlir::Operation::getDialect().
Referenced by assertDestinationPassingStyle(), mlir::bufferization::bufferizeOp(), and mlir::bufferization::OneShotAnalysisState::OneShotAnalysisState().
Optional<AllocationFn> mlir::bufferization::BufferizationOptions::allocationFn |
Helper functions for allocation, deallocation, memory copying.
Definition at line 207 of file BufferizableOpInterface.h.
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 227 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::bufferizeOp(), mlir::bufferization::getPartialBufferizationOptions(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
bool mlir::bufferization::BufferizationOptions::alwaysAliasingWithDest = true |
If set to true
, an getAliasingOpResult
will return the corresponding "out"/"dest" OpOperand for every op that has the notion of an "out"/"dest" operand.
I.e., the aliasing OpOperand of the i-th tensor OpResult is usually the i-th "out" tensor OpOperand. This is in line with destination-passing style and the default behavior. Op interface implementations must follow this contract to avoid surprising behavior.
If set to false
, BufferizableOpInterface implementations can try to be smart and choose to alias with "in" operands or other operands. E.g., the result of a linalg.generic
op could bufferize in-place with an "in" OpOperand if the corresponding "out" operand is not used within the computation. Whether this pays off or not can be very input IR-specific.
Definition at line 304 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
unsigned mlir::bufferization::BufferizationOptions::analysisFuzzerSeed = 0 |
Seed for the analysis fuzzer.
If set to 0
, the fuzzer is deactivated. Should be used only with testAnalysisOnly = true
.
Definition at line 278 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
unsigned int mlir::bufferization::BufferizationOptions::bufferAlignment = 128 |
Buffer alignment for new memory allocations.
Definition at line 307 of file BufferizableOpInterface.h.
bool mlir::bufferization::BufferizationOptions::bufferizeFunctionBoundaries = false |
Specifies whether function boundaries (ops in the func dialect) should be bufferized or not.
Definition at line 231 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::analyzeModuleOp(), mlir::bufferization::bufferizeOp(), mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns(), and mlir::bufferization::runOneShotModuleBufferize().
bool mlir::bufferization::BufferizationOptions::createDeallocs = true |
Specifies whether dealloc ops should be generated along with alloc ops.
If not, new memory allocations will leak.
Definition at line 274 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::bufferizeOp(), mlir::bufferization::BufferizationState::createAlloc(), mlir::bufferization::finalizeBuffers(), mlir::bufferization::getPartialBufferizationOptions(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
Optional<DeallocationFn> mlir::bufferization::BufferizationOptions::deallocationFn |
Definition at line 208 of file BufferizableOpInterface.h.
LayoutMapOption mlir::bufferization::BufferizationOptions::functionBoundaryTypeConversion |
This flag controls buffer types on function signatures.
If bufferizeFunctionBoundaries
is not set, this flag has no effect. If promoteBufferResultsToOutParams
is set, kInferMostPreciseLayoutMap
is is an invalid option.
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 253 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::func_ext::getBufferizedFunctionArgType(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
Definition at line 209 of file BufferizableOpInterface.h.
OpFilter mlir::bufferization::BufferizationOptions::opFilter |
A filter that specifies which ops should be bufferized and which ops should be ignored.
Definition at line 201 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
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 286 of file BufferizableOpInterface.h.
Referenced by hasReadAfterWriteInterference(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
bool mlir::bufferization::BufferizationOptions::promoteBufferResultsToOutParams = false |
If set to true
, buffers that are returned from functions are replaced with buffer "out" parameters.
At the call site, new buffers are allocated.
Definition at line 290 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::finalizeBuffers(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().
SmallVector<AnalysisStateInitFn> mlir::bufferization::BufferizationOptions::stateInitializers |
Initializer functions for analysis state.
These can be used to initialize dialect-specific analysis state.
Definition at line 311 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 282 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::analyzeModuleOp(), getAssumedUniqueReturnOp(), mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns(), mlir::bufferization::runOneShotBufferize(), and mlir::bufferization::runOneShotModuleBufferize().
LayoutMapOption mlir::bufferization::BufferizationOptions::unknownTypeConversion |
This flag controls buffer types on unknown ops (to_memref wrappers) and in other cases where a precise memref type cannot be inferred (e.g., the bufferization of "tensor.cast").
Definition at line 269 of file BufferizableOpInterface.h.
Referenced by mlir::bufferization::getMemRefType(), mlir::bufferization::getPartialBufferizationOptions(), and mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns().