#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/Matchers.h"
#include <optional>
usingnamespacemlir;
usingnamespacemlir::bufferization;
FailureOr<Value> mlir::bufferization::castOrReallocMemRefValue(
OpBuilder &b, Value value, MemRefType destType,
const BufferizationOptions &options) { … }
LogicalResult mlir::bufferization::foldToMemrefToTensorPair(
RewriterBase &rewriter, ToMemrefOp toMemref,
const BufferizationOptions &options) { … }
void mlir::bufferization::populateDynamicDimSizes(
OpBuilder &b, Location loc, Value shapedValue,
SmallVector<Value> &dynamicDims) { … }
LogicalResult AllocTensorOp::bufferize(RewriterBase &rewriter,
const BufferizationOptions &options) { … }
bool AllocTensorOp::resultBufferizesToMemoryWrite(OpResult opResult,
const AnalysisState &state) { … }
bool AllocTensorOp::bufferizesToMemoryRead(OpOperand &opOperand,
const AnalysisState &state) { … }
bool AllocTensorOp::bufferizesToMemoryWrite(OpOperand &opOperand,
const AnalysisState &state) { … }
AliasingValueList AllocTensorOp::getAliasingValues(OpOperand &opOperand,
const AnalysisState &state) { … }
FailureOr<BaseMemRefType>
AllocTensorOp::getBufferType(Value value, const BufferizationOptions &options,
SmallVector<Value> &invocationStack) { … }
LogicalResult AllocTensorOp::verify() { … }
void AllocTensorOp::build(OpBuilder &builder, OperationState &result,
RankedTensorType type, ValueRange dynamicSizes) { … }
void AllocTensorOp::build(OpBuilder &builder, OperationState &result,
RankedTensorType type, ValueRange dynamicSizes,
Value copy) { … }
void AllocTensorOp::build(OpBuilder &builder, OperationState &result,
TensorType type, ValueRange dynamicSizes, Value copy,
IntegerAttr memorySpace) { … }
namespace {
struct ReplaceStaticShapeDims : OpRewritePattern<AllocTensorOp> { … };
struct FoldDimOfAllocTensorOp : public OpRewritePattern<tensor::DimOp> { … };
}
void AllocTensorOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *ctx) { … }
LogicalResult AllocTensorOp::reifyResultShapes(
OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
ParseResult AllocTensorOp::parse(OpAsmParser &parser, OperationState &result) { … }
void AllocTensorOp::print(OpAsmPrinter &p) { … }
Value AllocTensorOp::getDynamicSize(OpBuilder &b, unsigned idx) { … }
OpFoldResult CloneOp::fold(FoldAdaptor adaptor) { … }
namespace {
struct SimplifyClones : public OpRewritePattern<CloneOp> { … };
}
void CloneOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
LogicalResult DeallocTensorOp::bufferize(RewriterBase &rewriter,
const BufferizationOptions &options) { … }
bool MaterializeInDestinationOp::bufferizesToMemoryRead(
OpOperand &opOperand, const AnalysisState &state) { … }
bool MaterializeInDestinationOp::bufferizesToMemoryWrite(
OpOperand &opOperand, const AnalysisState &state) { … }
bool MaterializeInDestinationOp::mustBufferizeInPlace(
OpOperand &opOperand, const AnalysisState &state) { … }
AliasingValueList
MaterializeInDestinationOp::getAliasingValues(OpOperand &opOperand,
const AnalysisState &state) { … }
LogicalResult
MaterializeInDestinationOp::bufferize(RewriterBase &rewriter,
const BufferizationOptions &options) { … }
bool MaterializeInDestinationOp::bufferizesToElementwiseAccess(
const AnalysisState &state, ArrayRef<OpOperand *> opOperands) { … }
LogicalResult MaterializeInDestinationOp::reifyResultShapes(
OpBuilder &builder, ReifiedRankedShapedTypeDims &reifiedReturnShapes) { … }
Value MaterializeInDestinationOp::buildSubsetExtraction(OpBuilder &builder,
Location loc) { … }
bool MaterializeInDestinationOp::isEquivalentSubset(
Value candidate, function_ref<bool(Value, Value)> equivalenceFn) { … }
SmallVector<Value>
MaterializeInDestinationOp::getValuesNeededToBuildSubsetExtraction() { … }
OpOperand &MaterializeInDestinationOp::getSourceOperand() { … }
bool MaterializeInDestinationOp::operatesOnEquivalentSubset(
SubsetOpInterface subsetOp,
function_ref<bool(Value, Value)> equivalenceFn) { … }
bool MaterializeInDestinationOp::operatesOnDisjointSubset(
SubsetOpInterface subsetOp,
function_ref<bool(Value, Value)> equivalenceFn) { … }
LogicalResult MaterializeInDestinationOp::verify() { … }
void MaterializeInDestinationOp::build(OpBuilder &builder,
OperationState &state, Value source,
Value dest) { … }
bool MaterializeInDestinationOp::isWritable(Value value,
const AnalysisState &state) { … }
MutableOperandRange MaterializeInDestinationOp::getDpsInitsMutable() { … }
void MaterializeInDestinationOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
&effects) { … }
bool ToTensorOp::isWritable(Value value, const AnalysisState &state) { … }
OpFoldResult ToTensorOp::fold(FoldAdaptor) { … }
namespace {
struct DimOfToTensorFolder : public OpRewritePattern<tensor::DimOp> { … };
}
void ToTensorOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
OpFoldResult ToMemrefOp::fold(FoldAdaptor) { … }
namespace {
struct ToMemrefOfCast : public OpRewritePattern<ToMemrefOp> { … };
struct ToMemrefToTensorFolding : public OpRewritePattern<ToMemrefOp> { … };
struct LoadOfToMemref : public OpRewritePattern<memref::LoadOp> { … };
struct DimOfCastOp : public OpRewritePattern<memref::DimOp> { … };
}
void ToMemrefOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
LogicalResult ToMemrefOp::bufferize(RewriterBase &rewriter,
const BufferizationOptions &options) { … }
std::optional<Operation *> CloneOp::buildDealloc(OpBuilder &builder,
Value alloc) { … }
std::optional<Value> CloneOp::buildClone(OpBuilder &builder, Value alloc) { … }
LogicalResult DeallocOp::inferReturnTypes(
MLIRContext *context, std::optional<::mlir::Location> location,
ValueRange operands, DictionaryAttr attributes, OpaqueProperties properties,
RegionRange regions, SmallVectorImpl<Type> &inferredReturnTypes) { … }
LogicalResult DeallocOp::verify() { … }
static LogicalResult updateDeallocIfChanged(DeallocOp deallocOp,
ValueRange memrefs,
ValueRange conditions,
PatternRewriter &rewriter) { … }
namespace {
struct DeallocRemoveDuplicateDeallocMemrefs
: public OpRewritePattern<DeallocOp> { … };
struct DeallocRemoveDuplicateRetainedMemrefs
: public OpRewritePattern<DeallocOp> { … };
struct EraseEmptyDealloc : public OpRewritePattern<DeallocOp> { … };
struct EraseAlwaysFalseDealloc : public OpRewritePattern<DeallocOp> { … };
struct SkipExtractMetadataOfAlloc : public OpRewritePattern<DeallocOp> { … };
struct RemoveAllocDeallocPairWhenNoOtherUsers
: public OpRewritePattern<DeallocOp> { … };
}
void DeallocOp::getCanonicalizationPatterns(RewritePatternSet &results,
MLIRContext *context) { … }
void bufferization::populateDeallocOpCanonicalizationPatterns(
RewritePatternSet &patterns, MLIRContext *context) { … }
#define GET_OP_CLASSES
#include "mlir/Dialect/Bufferization/IR/BufferizationOps.cpp.inc"