MLIR
16.0.0git
|
State for analysis-enabled bufferization. More...
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
Public Member Functions | |
OneShotAnalysisState (Operation *op, const OneShotBufferizationOptions &options) | |
OneShotAnalysisState (const OneShotAnalysisState &)=delete | |
virtual | ~OneShotAnalysisState ()=default |
BufferizationAliasInfo & | getAliasInfo () |
Return a reference to the BufferizationAliasInfo. More... | |
bool | isInPlace (OpOperand &opOperand) const override |
Return true if the given OpResult has been decided to bufferize inplace. More... | |
bool | areEquivalentBufferizedValues (Value v1, Value v2) const override |
Return true if v1 and v2 bufferize to equivalent buffers. More... | |
bool | areAliasingBufferizedValues (Value v1, Value v2) const override |
Return true if v1 and v2 may bufferize to aliasing buffers. More... | |
bool | hasUndefinedContents (OpOperand *opOperand) const override |
Return true if the given tensor has undefined contents. More... | |
bool | isTensorYielded (Value tensor) const override |
Return true if the given tensor (or an aliasing tensor) is yielded from the containing block. More... | |
void | gatherUndefinedTensorUses (Operation *op) |
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses . More... | |
void | gatherYieldedTensors (Operation *op) |
Find all tensors that are yielded/returned from a block and store them in yieldedTensors . More... | |
bool | isValueWritten (Value value) const |
Return true if the buffer of the given tensor value is written to. More... | |
bool | isWritable (Value value) const |
Return true if the buffer of the given tensor value is writable. More... | |
![]() | |
SmallVector< OpOperand * > | getAliasingOpOperand (OpResult result) const |
Determine which OpOperand* will alias with result if the op is bufferized in place. More... | |
SmallVector< OpResult > | getAliasingOpResult (OpOperand &opOperand) const |
Determine which OpResult will alias with opOperand if the op is bufferized in place. More... | |
bool | bufferizesToMemoryRead (OpOperand &opOperand) const |
Return true if opOperand bufferizes to a memory read. More... | |
bool | bufferizesToMemoryWrite (OpOperand &opOperand) const |
Return true if opOperand bufferizes to a memory write. More... | |
bool | bufferizesToAliasOnly (OpOperand &opOperand) const |
Return true if opOperand does neither read nor write but bufferizes to an alias. More... | |
bool | canOmitTensorCopy (OpOperand &opOperand) const |
Return true if a copy can always be avoided when allocating a new tensor for the given OpOperand. More... | |
bool | isValueRead (Value value) const |
Return true if the given value is read by an op that bufferizes to a memory read. More... | |
SetVector< Value > | findValueInReverseUseDefChain (Value value, llvm::function_ref< bool(Value)> condition) const |
Starting from value , follow the use-def chain in reverse, always selecting the aliasing OpOperands. More... | |
SetVector< Value > | findLastPrecedingWrite (Value value) const |
Find the Values of the last preceding write of a given Value. More... | |
bool | hasDialectState (StringRef name) const |
Return true if the given dialect state exists. More... | |
template<typename StateT > | |
Optional< const StateT * > | getDialectState (StringRef name) const |
Return dialect-specific bufferization state. More... | |
template<typename StateT > | |
StateT & | getOrCreateDialectState (StringRef name) |
Return dialect-specific analysis state or create one if none exists. More... | |
void | insertDialectState (StringRef name, std::unique_ptr< DialectAnalysisState > state) |
const BufferizationOptions & | getOptions () const |
Return a reference to the BufferizationOptions. More... | |
AnalysisState (const BufferizationOptions &options) | |
AnalysisState (const AnalysisState &)=delete | |
virtual | ~AnalysisState ()=default |
State for analysis-enabled bufferization.
This class keeps track of alias (via BufferizationAliasInfo) to decide if tensor OpOperands should bufferize in-place.
Definition at line 126 of file OneShotAnalysis.h.
OneShotAnalysisState::OneShotAnalysisState | ( | Operation * | op, |
const OneShotBufferizationOptions & | options | ||
) |
Definition at line 190 of file OneShotAnalysis.cpp.
References mlir::WalkResult::advance(), mlir::bufferization::BufferizationOptions::isOpAllowed(), mlir::bufferization::BufferizationAliasInfo::markInPlace(), mlir::WalkResult::skip(), mlir::bufferization::BufferizationAliasInfo::unionAliasSets(), and mlir::Operation::walk().
|
delete |
|
virtualdefault |
Return true if v1
and v2
may bufferize to aliasing buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 220 of file OneShotAnalysis.cpp.
References mlir::bufferization::BufferizationAliasInfo::areAliasingBufferizedValues().
Referenced by getAssumedUniqueReturnOp().
|
overridevirtual |
Return true if v1
and v2
bufferize to equivalent buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 215 of file OneShotAnalysis.cpp.
References mlir::bufferization::BufferizationAliasInfo::areEquivalentBufferizedValues().
Referenced by getAssumedUniqueReturnOp().
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses
.
Definition at line 258 of file OneShotAnalysis.cpp.
References mlir::WalkResult::advance(), mlir::Value::cast(), mlir::bufferization::BufferizationOptions::dynCastBufferizableOp(), mlir::bufferization::AnalysisState::findLastPrecedingWrite(), mlir::Operation::getOpResults(), mlir::bufferization::AnalysisState::getOptions(), mlir::WalkResult::skip(), and mlir::Operation::walk().
Referenced by mlir::bufferization::analyzeOp().
Find all tensors that are yielded/returned from a block and store them in yieldedTensors
.
Also include all aliasing tensors in the same block.
Definition at line 229 of file OneShotAnalysis.cpp.
References mlir::WalkResult::advance(), mlir::bufferization::BufferizationAliasInfo::applyOnAliases(), mlir::Value::dyn_cast(), mlir::Value::getDefiningOp(), mlir::Operation::getOpOperands(), mlir::bufferization::AnalysisState::getOptions(), mlir::Operation::getParentOp(), mlir::Value::getType(), mlir::Type::isa(), mlir::isRegionReturnLike(), and mlir::Operation::walk().
Referenced by mlir::bufferization::analyzeOp().
|
inline |
Return a reference to the BufferizationAliasInfo.
Definition at line 136 of file OneShotAnalysis.h.
References mlir::bufferization::analyzeOp(), options, mlir::bufferization::runOneShotBufferize(), and value.
Referenced by mlir::bufferization::analyzeModuleOp(), and mlir::bufferization::analyzeOp().
|
overridevirtual |
Return true
if the given tensor has undefined contents.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 291 of file OneShotAnalysis.cpp.
|
overridevirtual |
Return true
if the given OpResult has been decided to bufferize inplace.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 211 of file OneShotAnalysis.cpp.
References mlir::bufferization::BufferizationAliasInfo::isInPlace().
Referenced by equivalenceAnalysis(), and isValueWritten().
|
overridevirtual |
Return true if the given tensor (or an aliasing tensor) is yielded from the containing block.
Also include all aliasing tensors in the same block.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 295 of file OneShotAnalysis.cpp.
bool OneShotAnalysisState::isValueWritten | ( | Value | value | ) | const |
Return true if the buffer of the given tensor value is written to.
Must not be called for values inside not yet analyzed functions.
Definition at line 299 of file OneShotAnalysis.cpp.
References mlir::bufferization::BufferizationAliasInfo::applyOnAliases(), mlir::bufferization::AnalysisState::bufferizesToMemoryWrite(), mlir::Value::getUses(), and isInPlace().
Referenced by getAssumedUniqueReturnOp().
bool OneShotAnalysisState::isWritable | ( | Value | value | ) | const |
Return true if the buffer of the given tensor value is writable.
Definition at line 309 of file OneShotAnalysis.cpp.
References mlir::Value::dyn_cast(), and mlir::bufferization::AnalysisState::getOptions().
Referenced by hasPrecedingAliasingNonWritableTensor().