MLIR
17.0.0git
|
Namespaces | |
detail | |
func_ext | |
Classes | |
struct | AliasingOpOperand |
A maybe aliasing OpOperand. More... | |
struct | AliasingOpResult |
A maybe aliasing OpResult. More... | |
class | AliasList |
class | OpFilter |
struct | BufferizationOptions |
Options for BufferizableOpInterface-based bufferization. More... | |
struct | TraversalConfig |
Traversal parameters for findValueInReverseUseDefChain . More... | |
class | AnalysisState |
AnalysisState provides a variety of helper functions for dealing with tensor values. More... | |
struct | DstBufferizableOpInterfaceExternalModel |
Bufferizable ops that implement the DestinationStyleOpInterface can use this external model base class. More... | |
struct | BufferizationStatistics |
Bufferization statistics for debugging. More... | |
class | BufferizeTypeConverter |
A helper type converter class that automatically populates the relevant materializations and type conversions for bufferization. More... | |
class | BufferPlacementAllocs |
A simple analysis that detects allocation operations. More... | |
class | BufferPlacementTransformationBase |
The base class for all BufferPlacement transformations. More... | |
struct | OneShotBufferizationOptions |
Options for analysis-enabled bufferization. More... | |
class | OneShotAnalysisState |
State for analysis-enabled bufferization. More... | |
struct | BufferResultsToOutParamsOptions |
Typedefs | |
using | AliasingOpOperandList = AliasList< AliasingOpOperand > |
A list of possible aliasing OpOperands. More... | |
using | AliasingOpResultList = AliasList< AliasingOpResult > |
A list of possible aliasing OpResults. More... | |
using | AnchorMatchFn = std::function< bool(OpOperand &, SmallVector< Value > &)> |
A function that matches anchor OpOperands for tensor::EmptyOp elimination. More... | |
using | RewriteFn = std::function< Value(OpBuilder &, Location, OpOperand &)> |
A function that rewrites matched anchors. More... | |
Enumerations | |
enum class | BufferRelation { Unknown , Equivalent } |
Specifies a fine-grain relationship between buffers to enable more analysis. More... | |
Functions | |
bool | isFunctionArgument (Value value) |
Return true if the given value is a BlockArgument of a func::FuncOp. More... | |
FailureOr< Value > | allocateTensorForShapedValue (OpBuilder &b, Location loc, Value shapedValue, bool escape, const BufferizationOptions &options, bool copy=true) |
Create an AllocTensorOp for the given shaped value (memref or tensor). More... | |
bool | allocationDoesNotEscape (OpResult opResult) |
Return true if the allocation of the given op is guaranteed to not escape the containing block. More... | |
FailureOr< Value > | getBuffer (RewriterBase &rewriter, Value value, const BufferizationOptions &options) |
Lookup the buffer for the given value. More... | |
FailureOr< BaseMemRefType > | getBufferType (Value value, const BufferizationOptions &options) |
Return the buffer type for a given Value (tensor) after bufferization without bufferizing any IR. More... | |
FailureOr< BaseMemRefType > | getBufferType (Value value, const BufferizationOptions &options, const DenseMap< Value, BaseMemRefType > &fixedTypes) |
Return the buffer type for a given Value (tensor) after bufferization without bufferizing any IR. More... | |
void | replaceOpWithBufferizedValues (RewriterBase &rewriter, Operation *op, ValueRange values) |
Replace an op with replacement values. More... | |
template<typename OpTy , typename... Args> | |
OpTy | replaceOpWithNewBufferizedOp (RewriterBase &rewriter, Operation *op, Args &&...args) |
Replace an op with a new op. More... | |
bool | shouldDeallocateOpResult (OpResult opResult, const BufferizationOptions &options) |
Return true if the buffer of given OpResult should be deallocated. More... | |
BaseMemRefType | getMemRefType (Value value, const BufferizationOptions &options, MemRefLayoutAttrInterface layout={}, Attribute memorySpace=nullptr) |
Return a MemRefType to which the type of the given value can be bufferized. More... | |
BaseMemRefType | getMemRefTypeWithFullyDynamicLayout (TensorType tensorType, Attribute memorySpace=nullptr) |
Return a MemRef type with fully dynamic layout. More... | |
BaseMemRefType | getMemRefTypeWithStaticIdentityLayout (TensorType tensorType, Attribute memorySpace=nullptr) |
Return a MemRef type with a static identity layout (i.e., no layout map). More... | |
Operation * | getOwnerOfValue (Value value) |
Return the owner of the given value. More... | |
Region * | getEnclosingRepetitiveRegion (Operation *op, const BufferizationOptions &options) |
Return the closest enclosing repetitive region around the given op. More... | |
Region * | getEnclosingRepetitiveRegion (Value value, const BufferizationOptions &options) |
Return the closest enclosing repetitive region around the place where the given value is defined. More... | |
Region * | getEnclosingRepetitiveRegion (Block *block, const BufferizationOptions &options) |
Return the closest enclosing repetitive region around the given block. More... | |
Region * | getNextEnclosingRepetitiveRegion (Region *region, const BufferizationOptions &options) |
Assuming that the given region is repetitive, find the next enclosing repetitive region. More... | |
void | populateDynamicDimSizes (OpBuilder &b, Location loc, Value shapedValue, SmallVector< Value > &dynamicDims) |
Populate dynamicDims with tensor::DimOp / memref::DimOp results for all dynamic dimensions of the given shaped value. More... | |
FailureOr< Value > | castOrReallocMemRefValue (OpBuilder &b, Value value, MemRefType type) |
Try to cast the given ranked MemRef-typed value to the given ranked MemRef type. More... | |
LogicalResult | foldToMemrefToTensorPair (RewriterBase &rewriter, ToMemrefOp toMemref) |
Try to fold to_memref(to_tensor(x)). More... | |
void | registerTransformDialectExtension (DialectRegistry ®istry) |
void | populateBufferizeMaterializationLegality (ConversionTarget &target) |
Marks ops used by bufferization for type conversion materializations as "legal" in the given ConversionTarget. More... | |
void | populateEliminateBufferizeMaterializationsPatterns (BufferizeTypeConverter &typeConverter, RewritePatternSet &patterns) |
Populate patterns to eliminate bufferize materializations. More... | |
LogicalResult | bufferizeOp (Operation *op, const BufferizationOptions &options, bool copyBeforeWrite=true, const OpFilter *opFilter=nullptr, BufferizationStatistics *statistics=nullptr) |
Bufferize op and its nested ops that implement BufferizableOpInterface . More... | |
BufferizationOptions | getPartialBufferizationOptions () |
FailureOr< memref::GlobalOp > | getGlobalFor (arith::ConstantOp constantOp, uint64_t alignment, Attribute memorySpace={}) |
LogicalResult | analyzeOp (Operation *op, OneShotAnalysisState &state, BufferizationStatistics *statistics=nullptr) |
Analyze op and its nested ops. More... | |
LogicalResult | runOneShotBufferize (Operation *op, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr) |
Run One-Shot Bufferize on the given op: Analysis + Bufferization. More... | |
LogicalResult | analyzeModuleOp (ModuleOp moduleOp, OneShotAnalysisState &state, BufferizationStatistics *statistics=nullptr) |
Analyze moduleOp and its nested ops. More... | |
LogicalResult | bufferizeModuleOp (ModuleOp moduleOp, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr) |
Bufferize op and its nested ops that implement BufferizableOpInterface . More... | |
void | removeBufferizationAttributesInModule (ModuleOp moduleOp) |
Remove bufferization attributes on every FuncOp arguments in the ModuleOp. More... | |
LogicalResult | runOneShotModuleBufferize (ModuleOp moduleOp, const bufferization::OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr) |
Run One-Shot Module Bufferization on the given module. More... | |
std::unique_ptr< Pass > | createBufferDeallocationPass () |
Creates an instance of the BufferDeallocation pass to free all allocated buffers. More... | |
LogicalResult | deallocateBuffers (Operation *op) |
Run buffer deallocation. More... | |
std::unique_ptr< Pass > | createBufferHoistingPass () |
Creates a pass that moves allocations upwards to reduce the number of required copies that are inserted during the BufferDeallocation pass. More... | |
std::unique_ptr< Pass > | createBufferLoopHoistingPass () |
Creates a pass that moves allocations upwards out of loops. More... | |
std::unique_ptr< Pass > | createBufferResultsToOutParamsPass (const BufferResultsToOutParamsOptions &options={}) |
Creates a pass that converts memref function results to out-params. More... | |
LogicalResult | promoteBufferResultsToOutParams (ModuleOp module, const BufferResultsToOutParamsOptions &options) |
Replace buffers that are returned from a function with an out parameter. More... | |
std::unique_ptr< Pass > | createDropEquivalentBufferResultsPass () |
Creates a pass that drops memref function results that are equivalent to a function argument. More... | |
std::unique_ptr< Pass > | createEmptyTensorToAllocTensorPass () |
Create a pass that rewrites tensor.empty to bufferization.alloc_tensor. More... | |
LogicalResult | dropEquivalentBufferResults (ModuleOp module) |
Drop all memref function results that are equivalent to a function argument. More... | |
std::unique_ptr< OperationPass< func::FuncOp > > | createFinalizingBufferizePass () |
Creates a pass that finalizes a partial bufferization by removing remaining bufferization.to_tensor and bufferization.to_memref operations. More... | |
std::unique_ptr< Pass > | createOneShotBufferizePass () |
Create a pass that bufferizes all ops that implement BufferizableOpInterface with One-Shot Bufferize. More... | |
std::unique_ptr< Pass > | createOneShotBufferizePass (const OneShotBufferizationOptions &options) |
Create a pass that bufferizes all ops that implement BufferizableOpInterface with One-Shot Bufferize and the specified bufferization options. More... | |
std::unique_ptr< Pass > | createPromoteBuffersToStackPass (unsigned maxAllocSizeInBytes=1024, unsigned maxRankOfAllocatedMemRef=1) |
Creates a pass that promotes heap-based allocations to stack-based ones. More... | |
std::unique_ptr< Pass > | createPromoteBuffersToStackPass (std::function< bool(Value)> isSmallAlloc) |
Creates a pass that promotes heap-based allocations to stack-based ones. More... | |
std::unique_ptr< Pass > | createEmptyTensorEliminationPass () |
Create a pass that tries to eliminate tensor.empty ops that are anchored on insert_slice ops. More... | |
std::unique_ptr< Pass > | createBufferizationBufferizePass () |
Create a pass that bufferizes ops from the bufferization dialect. More... | |
void | registerAllocationOpInterfaceExternalModels (DialectRegistry ®istry) |
Register external models for AllocationOpInterface. More... | |
LogicalResult | eliminateEmptyTensors (RewriterBase &rewriter, Operation *op, OneShotAnalysisState &state, AnchorMatchFn anchorMatchFunc, RewriteFn rewriteFunc) |
Try to eliminate tensor::EmptyOps inside op . More... | |
LogicalResult | insertSliceAnchoredEmptyTensorEliminationStep (RewriterBase &rewriter, Operation *op, OneShotAnalysisState &state) |
Try to eliminate tensor::EmptyOps inside op that are anchored on an InsertSliceOp, i.e., if it is eventually inserted into another tensor (and some other conditions are met). More... | |
LogicalResult | insertTensorCopies (Operation *op, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr) |
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops. More... | |
LogicalResult | insertTensorCopies (Operation *op, const AnalysisState &state) |
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops. More... | |
void | populateEmptyTensorToAllocTensorPattern (RewritePatternSet &patterns) |
Populate patterns to lower tensor.empty ops to bufferization.alloc_tensor ops. More... | |
using mlir::bufferization::AliasingOpOperandList = typedef AliasList<AliasingOpOperand> |
A list of possible aliasing OpOperands.
This list models the runtime aliasing relationship for an OpResult.
Definition at line 93 of file BufferizableOpInterface.h.
using mlir::bufferization::AliasingOpResultList = typedef AliasList<AliasingOpResult> |
A list of possible aliasing OpResults.
This list models the runtime aliasing relationship for an OpOperand.
Definition at line 97 of file BufferizableOpInterface.h.
using mlir::bufferization::AnchorMatchFn = typedef std::function<bool(OpOperand &, SmallVector<Value> &)> |
A function that matches anchor OpOperands for tensor::EmptyOp elimination.
If an OpOperand is matched, the function should populate the SmallVector with all values that are needed during RewriteFn
to produce the replacement value.
Definition at line 26 of file Transforms.h.
using mlir::bufferization::RewriteFn = typedef std::function<Value(OpBuilder &, Location, OpOperand &)> |
A function that rewrites matched anchors.
Definition at line 29 of file Transforms.h.
|
strong |
Specifies a fine-grain relationship between buffers to enable more analysis.
Enumerator | |
---|---|
Unknown | |
Equivalent |
Definition at line 32 of file BufferizableOpInterface.h.
FailureOr< Value > mlir::bufferization::allocateTensorForShapedValue | ( | OpBuilder & | b, |
Location | loc, | ||
Value | shapedValue, | ||
bool | escape, | ||
const BufferizationOptions & | options, | ||
bool | copy = true |
||
) |
Create an AllocTensorOp for the given shaped value (memref or tensor).
Create an AllocTensorOp for the given shaped value.
If copy
is set, the shaped value is copied. Otherwise, a tensor with undefined contents is allocated.
Definition at line 118 of file BufferizableOpInterface.cpp.
References copy(), mlir::OpBuilder::create(), mlir::Operation::emitError(), mlir::detail::enumerate(), mlir::failed(), mlir::failure(), mlir::Builder::getBoolArrayAttr(), getBufferType(), mlir::Value::getDefiningOp(), mlir::Builder::getI64IntegerAttr(), getOwnerOfValue(), mlir::Value::getType(), options, populateDynamicDimSizes(), mlir::reifyResultShapes(), mlir::Operation::setAttr(), and mlir::succeeded().
bool mlir::bufferization::allocationDoesNotEscape | ( | OpResult | opResult | ) |
Return true
if the allocation of the given op is guaranteed to not escape the containing block.
Definition at line 99 of file BufferizableOpInterface.cpp.
References mlir::Value::getDefiningOp().
LogicalResult mlir::bufferization::analyzeModuleOp | ( | ModuleOp | moduleOp, |
OneShotAnalysisState & | state, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Analyze moduleOp
and its nested ops.
Bufferization decisions are stored in state
.
Definition at line 358 of file OneShotModuleBufferize.cpp.
References mlir::bufferization::func_ext::FuncAnalysisState::analyzedFuncOps, analyzeOp(), mlir::bufferization::BufferizationOptions::bufferizeFunctionBoundaries, equivalenceAnalysis(), mlir::failed(), mlir::failure(), getFuncOpsOrderedByCalls(), mlir::bufferization::OneShotAnalysisState::getOptions(), getOrCreateFuncAnalysisState(), mlir::bufferization::BufferizationOptions::isOpAllowed(), mlir::bufferization::func_ext::FuncAnalysisState::startFunctionAnalysis(), and mlir::success().
LogicalResult mlir::bufferization::analyzeOp | ( | Operation * | op, |
OneShotAnalysisState & | state, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Analyze op
and its nested ops.
Bufferization decisions are stored in state
.
Definition at line 1090 of file OneShotAnalysis.cpp.
Referenced by analyzeModuleOp().
LogicalResult mlir::bufferization::bufferizeModuleOp | ( | ModuleOp | moduleOp, |
const OneShotBufferizationOptions & | options, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Bufferize op
and its nested ops that implement BufferizableOpInterface
.
Note: This function does not run One-Shot Analysis. No buffer copies are inserted except two cases:
options.copyBeforeWrite
is set, in which case buffers are copied before every write.options.copyBeforeWrite
is not set and options.noAnalysisFuncFilter
is not empty. The FuncOps it contains were not analyzed. Buffer copies will be inserted only to these FuncOps. Definition at line 409 of file OneShotModuleBufferize.cpp.
References bufferizeOp(), mlir::failed(), mlir::failure(), foldMemRefCasts(), getFuncOpsOrderedByCalls(), options, removeBufferizationAttributesInModule(), and mlir::success().
LogicalResult mlir::bufferization::bufferizeOp | ( | Operation * | op, |
const BufferizationOptions & | options, | ||
bool | copyBeforeWrite = true , |
||
const OpFilter * | opFilter = nullptr , |
||
BufferizationStatistics * | statistics = nullptr |
||
) |
Bufferize op
and its nested ops that implement BufferizableOpInterface
.
If copyBeforeWrite
, buffers are duplicated and copied before any tensor use that bufferizes to a memory write.
Note: In the general case, it unsafe to run with copyBeforeWrite = false
because read-after-write conflicts may materialize during bufferization. copyBeforeWrite = false
is safe only if the input IR is guaranteed to not require any out-of-place bufferization.
Note: This function bufferizes ops without utilizing analysis results. It can be used to implement partial bufferization passes.
Check the result of bufferization. Return an error if an op was not bufferized, unless partial bufferization is allowed.
Definition at line 428 of file Bufferize.cpp.
Referenced by bufferizeModuleOp().
FailureOr< Value > mlir::bufferization::castOrReallocMemRefValue | ( | OpBuilder & | b, |
Value | value, | ||
MemRefType | type | ||
) |
Try to cast the given ranked MemRef-typed value to the given ranked MemRef type.
Insert a reallocation + copy if it cannot be statically guaranteed that a direct cast would be valid.
E.g., when casting from a ranked MemRef type with dynamic layout to a ranked MemRef type with static layout, it is not statically known whether the cast will succeed or not. Such memref.cast
ops may fail at runtime. This function never generates such casts and conservatively inserts a copy.
This function returns failure()
in case of unsupported casts. E.g., casts with differing element types or memory spaces.
Definition at line 28 of file BufferizationOps.cpp.
References copy(), mlir::OpBuilder::create(), mlir::OpBuilder::createOrFold(), mlir::failed(), mlir::failure(), mlir::Value::getLoc(), mlir::getStridesAndOffset(), and mlir::Value::getType().
Referenced by mlir::bufferization::BufferizeTypeConverter::BufferizeTypeConverter(), and foldToMemrefToTensorPair().
std::unique_ptr< Pass > mlir::bufferization::createBufferDeallocationPass | ( | ) |
Creates an instance of the BufferDeallocation pass to free all allocated buffers.
Definition at line 724 of file BufferDeallocation.cpp.
std::unique_ptr< Pass > mlir::bufferization::createBufferHoistingPass | ( | ) |
Creates a pass that moves allocations upwards to reduce the number of required copies that are inserted during the BufferDeallocation pass.
Definition at line 435 of file BufferOptimizations.cpp.
std::unique_ptr< Pass > mlir::bufferization::createBufferizationBufferizePass | ( | ) |
Create a pass that bufferizes ops from the bufferization dialect.
Definition at line 307 of file Bufferize.cpp.
std::unique_ptr< Pass > mlir::bufferization::createBufferLoopHoistingPass | ( | ) |
Creates a pass that moves allocations upwards out of loops.
This avoids reallocations inside of loops.
Definition at line 439 of file BufferOptimizations.cpp.
std::unique_ptr< Pass > mlir::bufferization::createBufferResultsToOutParamsPass | ( | const BufferResultsToOutParamsOptions & | options = {} | ) |
Creates a pass that converts memref function results to out-params.
Definition at line 221 of file BufferResultsToOutParams.cpp.
References options.
std::unique_ptr< Pass > mlir::bufferization::createDropEquivalentBufferResultsPass | ( | ) |
Creates a pass that drops memref function results that are equivalent to a function argument.
Definition at line 158 of file DropEquivalentBufferResults.cpp.
std::unique_ptr< Pass > mlir::bufferization::createEmptyTensorEliminationPass | ( | ) |
Create a pass that tries to eliminate tensor.empty ops that are anchored on insert_slice ops.
Definition at line 281 of file EmptyTensorElimination.cpp.
std::unique_ptr< Pass > mlir::bufferization::createEmptyTensorToAllocTensorPass | ( | ) |
Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
Definition at line 68 of file EmptyTensorToAllocTensor.cpp.
Referenced by mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation().
std::unique_ptr< OperationPass< func::FuncOp > > mlir::bufferization::createFinalizingBufferizePass | ( | ) |
Creates a pass that finalizes a partial bufferization by removing remaining bufferization.to_tensor and bufferization.to_memref operations.
Definition at line 321 of file Bufferize.cpp.
Referenced by mlir::sparse_tensor::buildSparseCompiler().
std::unique_ptr< Pass > mlir::bufferization::createOneShotBufferizePass | ( | ) |
Create a pass that bufferizes all ops that implement BufferizableOpInterface with One-Shot Bufferize.
Definition at line 311 of file Bufferize.cpp.
std::unique_ptr< Pass > mlir::bufferization::createOneShotBufferizePass | ( | const OneShotBufferizationOptions & | options | ) |
Create a pass that bufferizes all ops that implement BufferizableOpInterface with One-Shot Bufferize and the specified bufferization options.
Definition at line 315 of file Bufferize.cpp.
References options.
std::unique_ptr< Pass > mlir::bufferization::createPromoteBuffersToStackPass | ( | std::function< bool(Value)> | isSmallAlloc | ) |
Creates a pass that promotes heap-based allocations to stack-based ones.
Only buffers smaller with isSmallAlloc(alloc) == true
are promoted.
Definition at line 449 of file BufferOptimizations.cpp.
std::unique_ptr< Pass > mlir::bufferization::createPromoteBuffersToStackPass | ( | unsigned | maxAllocSizeInBytes = 1024 , |
unsigned | maxRankOfAllocatedMemRef = 1 |
||
) |
Creates a pass that promotes heap-based allocations to stack-based ones.
Only buffers smaller than the provided size are promoted. Dynamic shaped buffers are promoted up to the given rank.
Definition at line 443 of file BufferOptimizations.cpp.
LogicalResult mlir::bufferization::deallocateBuffers | ( | Operation * | op | ) |
Run buffer deallocation.
Definition at line 676 of file BufferDeallocation.cpp.
LogicalResult mlir::bufferization::dropEquivalentBufferResults | ( | ModuleOp | module | ) |
Drop all memref function results that are equivalent to a function argument.
Definition at line 71 of file DropEquivalentBufferResults.cpp.
References mlir::WalkResult::advance(), mlir::OpBuilder::create(), mlir::detail::enumerate(), getAssumedUniqueReturnOp(), getCalledFunction(), mlir::Value::getDefiningOp(), mlir::Value::getType(), mlir::RewriterBase::replaceOp(), mlir::OpBuilder::setInsertionPoint(), mlir::WalkResult::skip(), and mlir::success().
LogicalResult mlir::bufferization::eliminateEmptyTensors | ( | RewriterBase & | rewriter, |
Operation * | op, | ||
OneShotAnalysisState & | state, | ||
AnchorMatchFn | anchorMatchFunc, | ||
RewriteFn | rewriteFunc | ||
) |
Try to eliminate tensor::EmptyOps inside op
.
rewriteFunc
generates the replacement for the tensor::EmptyOp.Only tensor::EmptyOps that are anchored on a matching OpOperand as per anchorMatchFunc
are considered. "Anchored" means that there is a path on the reverse SSA use-def chain, starting from the OpOperand and always following the aliasing OpOperand, that eventually ends at a single tensor::EmptyOp.
A tensor::EmptyOp is replaced with the result of rewriteFunc
if it is anchored on a matching OpOperand. "Anchored" means that there is a path on the reverse SSA use-def chain, starting from the OpOperand and always following the aliasing OpOperand, that eventually ends at the tensor::EmptyOp.
E.g.: %0 = tensor.empty() : tensor<10xf32> %1 = linalg.fill ... outs(%0 : tensor<10xf32>) %2 = tensor.insert_slice %0 into t ...
In the above example, the anchor is the source operand of the insert_slice op. When tracing back the reverse use-def chain, we end up at a tensor.empty op.
Definition at line 116 of file EmptyTensorElimination.cpp.
LogicalResult mlir::bufferization::foldToMemrefToTensorPair | ( | RewriterBase & | rewriter, |
ToMemrefOp | toMemref | ||
) |
Try to fold to_memref(to_tensor(x)).
If x's type and the result type of the to_memref op are different, a memref.cast is needed.
Definition at line 88 of file BufferizationOps.cpp.
References castOrReallocMemRefValue(), mlir::failed(), mlir::failure(), mlir::RewriterBase::replaceOp(), mlir::RewriterBase::replaceOpWithNewOp(), and mlir::success().
FailureOr< Value > mlir::bufferization::getBuffer | ( | RewriterBase & | rewriter, |
Value | value, | ||
const BufferizationOptions & | options | ||
) |
Lookup the buffer for the given value.
If the value was not bufferized yet, wrap it in a ToMemrefOp. Otherwise, it is the result of a ToTensorOp, from which the memref operand is returned.
Definition at line 681 of file BufferizableOpInterface.cpp.
References mlir::OpBuilder::create(), ensureToMemrefOpIsValid(), mlir::failed(), mlir::failure(), getBufferType(), mlir::Value::getDefiningOp(), mlir::Value::getLoc(), mlir::Value::getType(), options, and setInsertionPointAfter().
FailureOr< BaseMemRefType > mlir::bufferization::getBufferType | ( | Value | value, |
const BufferizationOptions & | options | ||
) |
Return the buffer type for a given Value (tensor) after bufferization without bufferizing any IR.
Return the buffer type for a given Value (tensor) after bufferization.
Note: It should be sufficient to call getBuffer()->getType()
in most cases. However, when a buffer type should be predicted without modifying any IR, this function can be used.
This function is a wrapper around BufferizableOpInterface::getBufferType.
Definition at line 706 of file BufferizableOpInterface.cpp.
References options.
Referenced by allocateTensorForShapedValue(), and getBuffer().
FailureOr< BaseMemRefType > AllocTensorOp::getBufferType | ( | Value | value, |
const BufferizationOptions & | options, | ||
const DenseMap< Value, BaseMemRefType > & | fixedTypes | ||
) |
Return the buffer type for a given Value (tensor) after bufferization without bufferizing any IR.
Return the buffer type for a given Value (tensor) after bufferization.
If at any point during the type computation, the type of a value in fixedTypes
in required, the mapped type is used.
Note: It should be sufficient to call getBuffer()->getType()
in most cases. However, when a buffer type should be predicted without modifying any IR, this function can be used.
This function is a wrapper around BufferizableOpInterface::getBufferType.
Definition at line 712 of file BufferizableOpInterface.cpp.
References mlir::Value::getType().
Region * mlir::bufferization::getEnclosingRepetitiveRegion | ( | Block * | block, |
const BufferizationOptions & | options | ||
) |
Return the closest enclosing repetitive region around the given block.
Definition at line 71 of file BufferizableOpInterface.cpp.
References mlir::Block::getParent().
Region * mlir::bufferization::getEnclosingRepetitiveRegion | ( | Operation * | op, |
const BufferizationOptions & | options | ||
) |
Return the closest enclosing repetitive region around the given op.
Definition at line 53 of file BufferizableOpInterface.cpp.
Region * mlir::bufferization::getEnclosingRepetitiveRegion | ( | Value | value, |
const BufferizationOptions & | options | ||
) |
Return the closest enclosing repetitive region around the place where the given value is defined.
Definition at line 60 of file BufferizableOpInterface.cpp.
References mlir::Region::getParentRegion(), mlir::Value::getParentRegion(), isRepetitiveRegion(), and options.
FailureOr< memref::GlobalOp > mlir::bufferization::getGlobalFor | ( | arith::ConstantOp | constantOp, |
uint64_t | alignment, | ||
Attribute | memorySpace = {} |
||
) |
Definition at line 150 of file BufferUtils.cpp.
References mlir::failure().
BaseMemRefType mlir::bufferization::getMemRefType | ( | Value | value, |
const BufferizationOptions & | options, | ||
MemRefLayoutAttrInterface | layout = {} , |
||
Attribute | memorySpace = nullptr |
||
) |
Return a MemRefType to which the type of the given value can be bufferized.
If possible, op bufferization implementations should not use this function and instead infer precise memref types for tensor results by themselves.
Unless a layout map was specified, options.unknownTypeConverterFn
determines what kind of layout map will be used. For best composability (without copies), the fully dynamic layout map is used by default.
Note: Canonicalization patterns could clean up layout maps and infer more precise layout maps after bufferization. However, many possible canonicalizations are currently not implemented.
Definition at line 820 of file BufferizableOpInterface.cpp.
References mlir::get(), mlir::Value::getType(), and options.
Referenced by mlir::bufferization::detail::defaultGetBufferType(), and mlir::sparse_tensor::reshapeValuesToLevels().
BaseMemRefType mlir::bufferization::getMemRefTypeWithFullyDynamicLayout | ( | TensorType | tensorType, |
Attribute | memorySpace = nullptr |
||
) |
Return a MemRef type with fully dynamic layout.
If the given tensor type is unranked, return an unranked MemRef type.
Definition at line 846 of file BufferizableOpInterface.cpp.
References mlir::get(), and mlir::Type::getContext().
Referenced by mlir::sparse_tensor::LoopEmitter::initializeLoopEmit(), and mlir::bufferization::BufferizationOptions::setFunctionBoundaryTypeConversion().
BaseMemRefType mlir::bufferization::getMemRefTypeWithStaticIdentityLayout | ( | TensorType | tensorType, |
Attribute | memorySpace = nullptr |
||
) |
Return a MemRef type with a static identity layout (i.e., no layout map).
If the given tensor type is unranked, return an unranked MemRef type.
Definition at line 870 of file BufferizableOpInterface.cpp.
References mlir::get().
Referenced by getBufferizationOptions(), getPartialBufferizationOptions(), and mlir::bufferization::BufferizationOptions::setFunctionBoundaryTypeConversion().
Region * mlir::bufferization::getNextEnclosingRepetitiveRegion | ( | Region * | region, |
const BufferizationOptions & | options | ||
) |
Assuming that the given region is repetitive, find the next enclosing repetitive region.
Definition at line 83 of file BufferizableOpInterface.cpp.
References mlir::Region::getParentRegion(), isRepetitiveRegion(), and options.
Referenced by canUseOpDominance().
Return the owner of the given value.
In case of a BlockArgument that is the owner of the block. In case of an OpResult that is the defining op.
Definition at line 93 of file BufferizableOpInterface.cpp.
References mlir::Operation::getParentOp().
Referenced by allocateTensorForShapedValue(), and mlir::bufferization::BufferizationOptions::dynCastBufferizableOp().
BufferizationOptions mlir::bufferization::getPartialBufferizationOptions | ( | ) |
Definition at line 545 of file Bufferize.cpp.
References getMemRefTypeWithStaticIdentityLayout(), mlir::Value::getType(), and options.
LogicalResult mlir::bufferization::insertSliceAnchoredEmptyTensorEliminationStep | ( | RewriterBase & | rewriter, |
Operation * | op, | ||
OneShotAnalysisState & | state | ||
) |
Try to eliminate tensor::EmptyOps inside op
that are anchored on an InsertSliceOp, i.e., if it is eventually inserted into another tensor (and some other conditions are met).
Definition at line 239 of file EmptyTensorElimination.cpp.
LogicalResult mlir::bufferization::insertTensorCopies | ( | Operation * | op, |
const AnalysisState & | state | ||
) |
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
After applying this transform, the IR can be bufferized without inserting additional buffer allocations.
Definition at line 124 of file TensorCopyInsertion.cpp.
LogicalResult mlir::bufferization::insertTensorCopies | ( | Operation * | op, |
const OneShotBufferizationOptions & | options, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
After applying this transform, the IR can be bufferized without inserting additional buffer allocations.
Definition at line 99 of file TensorCopyInsertion.cpp.
Referenced by runOneShotModuleBufferize(), and mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation().
bool mlir::bufferization::isFunctionArgument | ( | Value | value | ) |
Return true
if the given value is a BlockArgument of a func::FuncOp.
Definition at line 813 of file BufferizableOpInterface.cpp.
void mlir::bufferization::populateBufferizeMaterializationLegality | ( | ConversionTarget & | target | ) |
Marks ops used by bufferization for type conversion materializations as "legal" in the given ConversionTarget.
This function should be called by all bufferization passes using BufferizeTypeConverter so that materializations work properly. One exception is bufferization passes doing "full" conversions, where it can be desirable for even the materializations to remain illegal so that they are eliminated, such as via the patterns in populateEliminateBufferizeMaterializationsPatterns.
Definition at line 92 of file Bufferize.cpp.
References mlir::ConversionTarget::addLegalOp().
void mlir::bufferization::populateDynamicDimSizes | ( | OpBuilder & | b, |
Location | loc, | ||
Value | shapedValue, | ||
SmallVector< Value > & | dynamicDims | ||
) |
Populate dynamicDims
with tensor::DimOp / memref::DimOp results for all dynamic dimensions of the given shaped value.
Definition at line 132 of file BufferizationOps.cpp.
References mlir::OpBuilder::create(), and mlir::Value::getType().
Referenced by allocateTensorForShapedValue().
void mlir::bufferization::populateEliminateBufferizeMaterializationsPatterns | ( | BufferizeTypeConverter & | typeConverter, |
RewritePatternSet & | patterns | ||
) |
Populate patterns to eliminate bufferize materializations.
In particular, these are the tensor_load/buffer_cast ops.
Definition at line 129 of file Bufferize.cpp.
References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().
void mlir::bufferization::populateEmptyTensorToAllocTensorPattern | ( | RewritePatternSet & | patterns | ) |
Populate patterns to lower tensor.empty ops to bufferization.alloc_tensor ops.
Definition at line 54 of file EmptyTensorToAllocTensor.cpp.
References mlir::RewritePatternSet::getContext(), and mlir::RewritePatternSet::insert().
LogicalResult mlir::bufferization::promoteBufferResultsToOutParams | ( | ModuleOp | module, |
const BufferResultsToOutParamsOptions & | options | ||
) |
Replace buffers that are returned from a function with an out parameter.
Also update all call sites.
Definition at line 184 of file BufferResultsToOutParams.cpp.
References mlir::failed(), mlir::failure(), options, mlir::success(), updateCalls(), updateFuncOp(), and updateReturnOps().
void mlir::bufferization::registerAllocationOpInterfaceExternalModels | ( | DialectRegistry & | registry | ) |
Register external models for AllocationOpInterface.
Definition at line 712 of file BufferDeallocation.cpp.
References mlir::DialectRegistry::addExtension().
void mlir::bufferization::registerTransformDialectExtension | ( | DialectRegistry & | registry | ) |
Definition at line 140 of file BufferizationTransformOps.cpp.
References mlir::DialectRegistry::addExtensions().
Referenced by mlir::registerAllDialects().
void mlir::bufferization::removeBufferizationAttributesInModule | ( | ModuleOp | moduleOp | ) |
Remove bufferization attributes on every FuncOp arguments in the ModuleOp.
Definition at line 401 of file OneShotModuleBufferize.cpp.
Referenced by bufferizeModuleOp().
void mlir::bufferization::replaceOpWithBufferizedValues | ( | RewriterBase & | rewriter, |
Operation * | op, | ||
ValueRange | values | ||
) |
Replace an op with replacement values.
The op is deleted. Tensor OpResults must be replaced with memref values.
Definition at line 737 of file BufferizableOpInterface.cpp.
OpTy mlir::bufferization::replaceOpWithNewBufferizedOp | ( | RewriterBase & | rewriter, |
Operation * | op, | ||
Args &&... | args | ||
) |
Replace an op with a new op.
The new op must have the same number of results as the replaced op. The new op may not return any tensor values.
Definition at line 610 of file BufferizableOpInterface.h.
LogicalResult mlir::bufferization::runOneShotBufferize | ( | Operation * | op, |
const OneShotBufferizationOptions & | options, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Run One-Shot Bufferize on the given op: Analysis + Bufferization.
Definition at line 1135 of file OneShotAnalysis.cpp.
LogicalResult mlir::bufferization::runOneShotModuleBufferize | ( | ModuleOp | moduleOp, |
const bufferization::OneShotBufferizationOptions & | options, | ||
BufferizationStatistics * | statistics = nullptr |
||
) |
Run One-Shot Module Bufferization on the given module.
Performs a simple function call analysis to determine which function arguments are inplaceable. Then analyzes and bufferizes FuncOps one-by-one with One-Shot Bufferize.
Definition at line 446 of file OneShotModuleBufferize.cpp.
References mlir::failed(), mlir::failure(), insertTensorCopies(), and options.
bool mlir::bufferization::shouldDeallocateOpResult | ( | OpResult | opResult, |
const BufferizationOptions & | options | ||
) |
Return true
if the buffer of given OpResult should be deallocated.
This function should be called during BufferizableOpInterface::bufferize
implementations that allocate a new buffer for the given OpResult.
Definition at line 274 of file BufferizableOpInterface.cpp.