Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Differential D114508 Diff 389894 mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
Changeset View
Changeset View
Standalone View
Standalone View
mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | struct AllocationCallbacks { | ||||
/// A function that deallocated memory. Must be allocated by `allocationFn`. | /// A function that deallocated memory. Must be allocated by `allocationFn`. | ||||
DeallocationFn deallocationFn; | DeallocationFn deallocationFn; | ||||
/// A function that copies memory between two allocations. | /// A function that copies memory between two allocations. | ||||
MemCpyFn memCpyFn; | MemCpyFn memCpyFn; | ||||
}; | }; | ||||
/// Dialect-specific bufferization state. Analysis/bufferization information | |||||
/// that is specific to ops from a certain dialect can be stored in derived | |||||
/// variants of this struct. | |||||
struct DialectBufferizationState { | |||||
virtual ~DialectBufferizationState() = default; | |||||
}; | |||||
/// BufferizationState keeps track of bufferization state and provides access to | /// BufferizationState keeps track of bufferization state and provides access to | ||||
/// the results of the analysis. | /// the results of the analysis. | ||||
struct BufferizationState { | struct BufferizationState { | ||||
BufferizationState(ModuleOp moduleOp, AllocationCallbacks &allocationFns) | BufferizationState(ModuleOp moduleOp, AllocationCallbacks &allocationFns) | ||||
: aliasInfo(moduleOp), allocationFns(allocationFns) {} | : aliasInfo(moduleOp), allocationFns(allocationFns) {} | ||||
// BufferizationState should be passed as a reference. | // BufferizationState should be passed as a reference. | ||||
BufferizationState(const BufferizationState &) = delete; | BufferizationState(const BufferizationState &) = delete; | ||||
Show All 25 Lines | struct BufferizationState { | ||||
bool isMapped(Value value) const; | bool isMapped(Value value) const; | ||||
/// Mark `op` as obsolete, so that it is deleted after bufferization. | /// Mark `op` as obsolete, so that it is deleted after bufferization. | ||||
void markOpObsolete(Operation *op); | void markOpObsolete(Operation *op); | ||||
/// Erase all ops that were marked obsolete. | /// Erase all ops that were marked obsolete. | ||||
void eraseObsoleteOps(); | void eraseObsoleteOps(); | ||||
/// Return dialect-specific bufferization state. | |||||
template <typename StateT> StateT &getDialectState(StringRef name) { | |||||
// Create state if it does not exist yet. | |||||
if (!dialectState.count(name)) | |||||
dialectState[name] = std::make_unique<StateT>(); | |||||
return static_cast<StateT &>(*dialectState[name]); | |||||
} | |||||
/// `aliasInfo` keeps track of aliasing and equivalent values. | /// `aliasInfo` keeps track of aliasing and equivalent values. | ||||
BufferizationAliasInfo aliasInfo; | BufferizationAliasInfo aliasInfo; | ||||
/// `allocationFns` contains helper functions for creating alloc ops, dealloc | /// `allocationFns` contains helper functions for creating alloc ops, dealloc | ||||
/// ops and memcpy ops. | /// ops and memcpy ops. | ||||
AllocationCallbacks &allocationFns; | AllocationCallbacks &allocationFns; | ||||
/// The mapping of tensors to buffers. May also contain mappings of non-tensor | /// The mapping of tensors to buffers. May also contain mappings of non-tensor | ||||
/// values. | /// values. | ||||
BlockAndValueMapping mapping; | BlockAndValueMapping mapping; | ||||
/// Obsolete ops that should be deleted after bufferization. | /// Obsolete ops that should be deleted after bufferization. | ||||
SmallVector<Operation *> obsoleteOps; | SmallVector<Operation *> obsoleteOps; | ||||
/// Dialect-specific bufferization state. | |||||
DenseMap<StringRef, std::unique_ptr<DialectBufferizationState>> dialectState; | |||||
}; | }; | ||||
/// Return the result buffer (memref) for a given OpResult (tensor). Allocate | /// Return the result buffer (memref) for a given OpResult (tensor). Allocate | ||||
/// a new buffer and copy over data from the existing buffer if out-of-place | /// a new buffer and copy over data from the existing buffer if out-of-place | ||||
/// bufferization is necessary. | /// bufferization is necessary. | ||||
Value getResultBuffer(OpBuilder &b, OpResult result, BufferizationState &state); | Value getResultBuffer(OpBuilder &b, OpResult result, BufferizationState &state); | ||||
/// Bufferize all ops in the given region. | /// Bufferize all ops in the given region. | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |