MLIR
20.0.0git
|
State for analysis-enabled bufferization. More...
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
Classes | |
class | Extension |
Base class for OneShotAnalysisState extensions that allow OneShotAnalysisState to contain user-specified information in the state object. More... | |
Public Member Functions | |
OneShotAnalysisState (Operation *op, const OneShotBufferizationOptions &options) | |
OneShotAnalysisState (const OneShotAnalysisState &)=delete | |
~OneShotAnalysisState () override=default | |
const OneShotBufferizationOptions & | getOptions () const |
Return a reference to the BufferizationOptions. More... | |
LogicalResult | analyzeOp (Operation *op, const DominanceInfo &domInfo) |
Analyze the given op and its nested ops. More... | |
LogicalResult | analyzeSingleOp (Operation *op, const DominanceInfo &domInfo) |
Analyze a single op (without nested ops). More... | |
void | applyOnEquivalenceClass (Value v, function_ref< void(Value)> fun) const |
Apply fun to all the members of the equivalence class of v . More... | |
void | applyOnAliases (Value v, function_ref< void(Value)> fun) const |
Apply fun to all aliases of v . 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... | |
void | bufferizeInPlace (OpOperand &operand) |
Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets. More... | |
void | bufferizeOutOfPlace (OpOperand &operand) |
Mark the given OpOperand as out-of-place. More... | |
void | createAliasInfoEntry (Value v) |
Add a new entry for v in the aliasInfo and equivalentInfo . More... | |
void | gatherUndefinedTensorUses (Operation *op) |
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses . More... | |
int64_t | getStatNumTensorOutOfPlace () const |
int64_t | getStatNumTensorInPlace () const |
bool | hasUndefinedContents (OpOperand *opOperand) const override |
Return true if the given tensor has undefined contents. More... | |
bool | isInPlace (OpOperand &opOperand) const override |
Return true if the given OpResult has been decided to bufferize inplace. 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... | |
const SetVector< Value > & | findDefinitionsCached (Value value) |
Find the definitions of the given tensor value or retrieve them from the cache. More... | |
void | resetCache () override |
Reset cached data structures. More... | |
void | unionAliasSets (Value v1, Value v2) |
Union the alias sets of v1 and v2 . More... | |
void | unionEquivalenceClasses (Value v1, Value v2) |
Union the equivalence classes of v1 and v2 . More... | |
template<typename Ty , typename... Args> | |
Ty & | addExtension (Args &&...args) |
Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided. More... | |
template<typename Ty > | |
Ty * | getExtension () |
Returns the extension of the specified type. More... | |
template<typename Ty > | |
const Ty * | getExtension () const |
Returns the extension of the specified type. More... | |
Public Member Functions inherited from mlir::bufferization::AnalysisState | |
AliasingOpOperandList | getAliasingOpOperands (Value value) const |
Determine which OpOperand* will alias with value if the op is bufferized in place. More... | |
AliasingValueList | getAliasingValues (OpOperand &opOperand) const |
Determine which Value 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 | bufferizesToMemoryWrite (Value value) const |
Return true if the given value 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, TraversalConfig config=TraversalConfig(), llvm::DenseSet< OpOperand * > *visitedOpOperands=nullptr) const |
Starting from value , follow the use-def chain in reverse, always selecting the aliasing OpOperands. More... | |
SetVector< Value > | findDefinitions (Value value) const |
Find the values that may define the contents of the given value at runtime. More... | |
const BufferizationOptions & | getOptions () const |
Return a reference to the BufferizationOptions. More... | |
AnalysisState (const BufferizationOptions &options) | |
AnalysisState (const AnalysisState &)=delete | |
virtual | ~AnalysisState ()=default |
TypeID | getType () const |
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... | |
Static Public Member Functions | |
static bool | classof (const AnalysisState *base) |
Static Public Member Functions inherited from mlir::bufferization::AnalysisState | |
static bool | classof (const AnalysisState *base) |
Additional Inherited Members | |
Protected Member Functions inherited from mlir::bufferization::AnalysisState | |
AnalysisState (const BufferizationOptions &options, TypeID type) | |
State for analysis-enabled bufferization.
This class keeps track of alias sets, equivalence sets, in-place OpOperands and other things.
Note: Modifying the IR generally invalidates the result of the analysis. Adding new operations is safe if they are analyzed subsequently.
Definition at line 62 of file OneShotAnalysis.h.
OneShotAnalysisState::OneShotAnalysisState | ( | Operation * | op, |
const OneShotBufferizationOptions & | options | ||
) |
Definition at line 111 of file OneShotAnalysis.cpp.
References createAliasInfoEntry(), mlir::Operation::getResults(), and mlir::Operation::walk().
|
delete |
|
overridedefault |
|
inline |
Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided.
The extension is owned by the OneShotAnalysisState. It is expected that the state does not already have an extension of the same type. Extension constructors are expected to take a reference to OneShotAnalysisState as first argument, automatically supplied by this call.
Definition at line 198 of file OneShotAnalysis.h.
LogicalResult OneShotAnalysisState::analyzeOp | ( | Operation * | op, |
const DominanceInfo & | domInfo | ||
) |
Analyze the given op and its nested ops.
Definition at line 1128 of file OneShotAnalysis.cpp.
References mlir::bufferization::OneShotBufferizationOptions::analysisHeuristic, analyzeSingleOp(), mlir::bufferization::OneShotBufferizationOptions::BottomUp, mlir::bufferization::OneShotBufferizationOptions::BottomUpFromTerminators, bottomUpFromTerminatorsHeuristic(), equivalenceAnalysis(), mlir::bufferization::OneShotBufferizationOptions::Fuzzer, getOptions(), mlir::bufferization::hasTensorSemantics(), mlir::bufferization::OneShotBufferizationOptions::TopDown, and mlir::Operation::walk().
LogicalResult OneShotAnalysisState::analyzeSingleOp | ( | Operation * | op, |
const DominanceInfo & | domInfo | ||
) |
Analyze a single op (without nested ops).
Definition at line 1005 of file OneShotAnalysis.cpp.
References bufferizableInPlaceAnalysisImpl(), and mlir::Operation::getOpOperands().
Referenced by analyzeOp().
void OneShotAnalysisState::applyOnAliases | ( | Value | v, |
function_ref< void(Value)> | fun | ||
) | const |
Apply fun
to all aliases of v
.
Definition at line 147 of file OneShotAnalysis.cpp.
Referenced by isValueWritten().
void OneShotAnalysisState::applyOnEquivalenceClass | ( | Value | v, |
function_ref< void(Value)> | fun | ||
) | const |
Apply fun
to all the members of the equivalence class of v
.
Definition at line 138 of file OneShotAnalysis.cpp.
Return true if v1
and v2
may bufferize to aliasing buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 160 of file OneShotAnalysis.cpp.
|
overridevirtual |
Return true if v1
and v2
bufferize to equivalent buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 155 of file OneShotAnalysis.cpp.
void OneShotAnalysisState::bufferizeInPlace | ( | OpOperand & | operand | ) |
Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets.
Definition at line 165 of file OneShotAnalysis.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get(), and mlir::bufferization::AnalysisState::getAliasingValues().
void OneShotAnalysisState::bufferizeOutOfPlace | ( | OpOperand & | operand | ) |
Mark the given OpOperand as out-of-place.
Definition at line 174 of file OneShotAnalysis.cpp.
|
inlinestatic |
Definition at line 71 of file OneShotAnalysis.h.
References mlir::bufferization::AnalysisState::getType().
void OneShotAnalysisState::createAliasInfoEntry | ( | Value | v | ) |
Add a new entry for v
in the aliasInfo
and equivalentInfo
.
In the beginning the alias and equivalence sets only contain v
itself.
Definition at line 180 of file OneShotAnalysis.cpp.
Referenced by OneShotAnalysisState().
const llvm::SetVector< Value > & OneShotAnalysisState::findDefinitionsCached | ( | Value | value | ) |
Find the definitions of the given tensor value or retrieve them from the cache.
Definition at line 970 of file OneShotAnalysis.cpp.
References mlir::bufferization::AnalysisState::findDefinitions().
Referenced by gatherUndefinedTensorUses().
void OneShotAnalysisState::gatherUndefinedTensorUses | ( | Operation * | op | ) |
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses
.
Definition at line 185 of file OneShotAnalysis.cpp.
References mlir::WalkResult::advance(), mlir::bufferization::BufferizationOptions::dynCastBufferizableOp(), findDefinitionsCached(), mlir::Operation::getOpResults(), getOptions(), mlir::WalkResult::skip(), and mlir::Operation::walk().
|
inline |
Returns the extension of the specified type.
Definition at line 210 of file OneShotAnalysis.h.
|
inline |
Returns the extension of the specified type.
Definition at line 222 of file OneShotAnalysis.h.
|
inline |
Return a reference to the BufferizationOptions.
Definition at line 76 of file OneShotAnalysis.h.
References mlir::bufferization::AnalysisState::getOptions().
Referenced by analyzeOp(), gatherUndefinedTensorUses(), and isWritable().
|
inline |
Definition at line 115 of file OneShotAnalysis.h.
|
inline |
Definition at line 114 of file OneShotAnalysis.h.
|
overridevirtual |
Return true
if the given tensor has undefined contents.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 208 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 212 of file OneShotAnalysis.cpp.
Referenced by isValueWritten().
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 216 of file OneShotAnalysis.cpp.
References applyOnAliases(), mlir::bufferization::AnalysisState::bufferizesToMemoryWrite(), mlir::Value::getUses(), and isInPlace().
bool OneShotAnalysisState::isWritable | ( | Value | value | ) | const |
Return true if the buffer of the given tensor value is writable.
Definition at line 226 of file OneShotAnalysis.cpp.
References getOptions(), and mlir::bufferization::getOwnerOfValue().
|
overridevirtual |
Reset cached data structures.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 976 of file OneShotAnalysis.cpp.
References mlir::bufferization::AnalysisState::resetCache().
Union the alias sets of v1
and v2
.
Definition at line 237 of file OneShotAnalysis.cpp.
Union the equivalence classes of v1
and v2
.
Definition at line 241 of file OneShotAnalysis.cpp.