MLIR  17.0.0git
Functions
mlir::memref Namespace Reference

Functions

LogicalResult foldMemRefCast (Operation *op, Value inner=nullptr)
 This is a common utility used for patterns of the form "someop(memref.cast) -> someop". More...
 
Type getTensorTypeFromMemRefType (Type type)
 Return an unranked/ranked tensor type for the given unranked/ranked memref type. More...
 
std::optional< Operation * > findDealloc (Value allocValue)
 Finds a single dealloc operation for the given allocated value. More...
 
SmallVector< OpFoldResultgetMixedSizes (OpBuilder &builder, Location loc, Value value)
 Return the dimensions of the given memref value. More...
 
Value createCanonicalRankReducingSubViewOp (OpBuilder &b, Location loc, Value memref, ArrayRef< int64_t > targetShape)
 Create a rank-reducing SubViewOp @[0 . More...
 
void registerTransformDialectExtension (DialectRegistry &registry)
 
void registerBufferizableOpInterfaceExternalModels (DialectRegistry &registry)
 
void populateComposeSubViewPatterns (RewritePatternSet &patterns, MLIRContext *context)
 
void populateExpandOpsPatterns (RewritePatternSet &patterns)
 Collects a set of patterns to rewrite ops within the memref dialect. More...
 
void populateFoldMemRefAliasOpPatterns (RewritePatternSet &patterns)
 Appends patterns for folding memref aliasing ops into consumer load/store ops into patterns. More...
 
void populateResolveRankedShapeTypeResultDimsPatterns (RewritePatternSet &patterns)
 Appends patterns that resolve memref.dim operations with values that are defined by operations that implement the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands. More...
 
void populateResolveShapedTypeResultDimsPatterns (RewritePatternSet &patterns)
 Appends patterns that resolve memref.dim operations with values that are defined by operations that implement the InferShapedTypeOpInterface, in terms of shapes of its input operands. More...
 
void populateExpandStridedMetadataPatterns (RewritePatternSet &patterns)
 Appends patterns for expanding memref operations that modify the metadata (sizes, offset, strides) of a memref into easier to analyze constructs. More...
 
void populateMemRefWideIntEmulationPatterns (arith::WideIntEmulationConverter &typeConverter, RewritePatternSet &patterns)
 Appends patterns for emulating wide integer memref operations with ops over narrower integer types. More...
 
void populateMemRefWideIntEmulationConversions (arith::WideIntEmulationConverter &typeConverter)
 Appends type converions for emulating wide integer memref operations with ops over narrowe integer types. More...
 
FailureOr< memref::AllocOp > multiBuffer (RewriterBase &rewriter, memref::AllocOp allocOp, unsigned multiplier, bool skipOverrideAnalysis=false)
 Transformation to do multi-buffering/array expansion to remove dependencies on the temporary allocation between consecutive loop iterations. More...
 
FailureOr< memref::AllocOp > multiBuffer (memref::AllocOp allocOp, unsigned multiplier, bool skipOverrideAnalysis=false)
 Call into multiBuffer with locally constructed IRRewriter. More...
 
std::unique_ptr< PasscreateExpandOpsPass ()
 Creates an instance of the ExpandOps pass that legalizes memref dialect ops to be convertible to LLVM. More...
 
std::unique_ptr< PasscreateFoldMemRefAliasOpsPass ()
 Creates an operation pass to fold memref aliasing ops into consumer load/store ops into patterns. More...
 
std::unique_ptr< OperationPass< ModuleOp > > createNormalizeMemRefsPass ()
 Creates an interprocedural pass to normalize memrefs to have a trivial (identity) layout map. More...
 
std::unique_ptr< PasscreateResolveRankedShapeTypeResultDimsPass ()
 Creates an operation pass to resolve memref.dim operations with values that are defined by operations that implement the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands. More...
 
std::unique_ptr< PasscreateResolveShapedTypeResultDimsPass ()
 Creates an operation pass to resolve memref.dim operations with values that are defined by operations that implement the InferShapedTypeOpInterface or the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands. More...
 
std::unique_ptr< PasscreateExpandStridedMetadataPass ()
 Creates an operation pass to expand some memref operation into easier to reason about operations. More...
 
void registerRuntimeVerifiableOpInterfaceExternalModels (DialectRegistry &registry)
 

Function Documentation

◆ createCanonicalRankReducingSubViewOp()

Value mlir::memref::createCanonicalRankReducingSubViewOp ( OpBuilder b,
Location  loc,
Value  memref,
ArrayRef< int64_t >  targetShape 
)

Create a rank-reducing SubViewOp @[0 .

. 0] with strides [1 .. 1] and appropriate sizes (i.e. memref.getSizes()) to reduce the rank of memref to that of targetShape.

Definition at line 2963 of file MemRefOps.cpp.

References mlir::Type::cast(), mlir::OpBuilder::createOrFold(), mlir::Builder::getIndexAttr(), getMixedSizes(), and mlir::Value::getType().

◆ createExpandOpsPass()

std::unique_ptr< Pass > mlir::memref::createExpandOpsPass ( )

Creates an instance of the ExpandOps pass that legalizes memref dialect ops to be convertible to LLVM.

For example, memref.reshape gets converted to memref_reinterpret_cast.

Definition at line 158 of file ExpandOps.cpp.

◆ createExpandStridedMetadataPass()

std::unique_ptr< Pass > mlir::memref::createExpandStridedMetadataPass ( )

Creates an operation pass to expand some memref operation into easier to reason about operations.

Definition at line 786 of file ExpandStridedMetadata.cpp.

Referenced by mlir::sparse_tensor::buildSparseCompiler().

◆ createFoldMemRefAliasOpsPass()

std::unique_ptr< Pass > mlir::memref::createFoldMemRefAliasOpsPass ( )

Creates an operation pass to fold memref aliasing ops into consumer load/store ops into patterns.

Definition at line 631 of file FoldMemRefAliasOps.cpp.

◆ createNormalizeMemRefsPass()

std::unique_ptr< OperationPass< ModuleOp > > mlir::memref::createNormalizeMemRefsPass ( )

Creates an interprocedural pass to normalize memrefs to have a trivial (identity) layout map.

Definition at line 56 of file NormalizeMemRefs.cpp.

◆ createResolveRankedShapeTypeResultDimsPass()

std::unique_ptr< Pass > mlir::memref::createResolveRankedShapeTypeResultDimsPass ( )

Creates an operation pass to resolve memref.dim operations with values that are defined by operations that implement the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands.

Definition at line 157 of file ResolveShapedTypeResultDims.cpp.

◆ createResolveShapedTypeResultDimsPass()

std::unique_ptr< Pass > mlir::memref::createResolveShapedTypeResultDimsPass ( )

Creates an operation pass to resolve memref.dim operations with values that are defined by operations that implement the InferShapedTypeOpInterface or the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands.

Definition at line 153 of file ResolveShapedTypeResultDims.cpp.

◆ findDealloc()

std::optional< Operation * > mlir::memref::findDealloc ( Value  allocValue)

Finds a single dealloc operation for the given allocated value.

Finds the unique dealloc operation (if one exists) for allocValue.

If there are > 1 deallocates for allocValue, returns std::nullopt, else returns the single deallocate if it exists or nullptr.

Definition at line 47 of file MemRefDialect.cpp.

References mlir::Value::getUsers().

◆ foldMemRefCast()

LogicalResult mlir::memref::foldMemRefCast ( Operation op,
Value  inner = nullptr 
)

This is a common utility used for patterns of the form "someop(memref.cast) -> someop".

This is a common class used for patterns of the form "someop(memrefcast) -> someop".

It folds the source of any memref.cast into the root operation directly.

Definition at line 89 of file MemRefOps.cpp.

References mlir::Operation::getOpOperands(), mlir::Value::getType(), mlir::Type::isa(), and mlir::success().

Referenced by mlir::AffineDmaStartOp::fold(), and mlir::AffineDmaWaitOp::fold().

◆ getMixedSizes()

SmallVector< OpFoldResult > mlir::memref::getMixedSizes ( OpBuilder builder,
Location  loc,
Value  value 
)

Return the dimensions of the given memref value.

Definition at line 112 of file MemRefOps.cpp.

References mlir::Type::cast(), mlir::OpBuilder::create(), mlir::Builder::getIndexAttr(), and mlir::Value::getType().

Referenced by createCanonicalRankReducingSubViewOp().

◆ getTensorTypeFromMemRefType()

Type mlir::memref::getTensorTypeFromMemRefType ( Type  type)

Return an unranked/ranked tensor type for the given unranked/ranked memref type.

Definition at line 104 of file MemRefOps.cpp.

References mlir::Type::dyn_cast(), and mlir::Type::getContext().

Referenced by parseGlobalMemrefOpTypeAndInitialValue().

◆ multiBuffer() [1/2]

FailureOr< memref::AllocOp > mlir::memref::multiBuffer ( memref::AllocOp  allocOp,
unsigned  multiplier,
bool  skipOverrideAnalysis = false 
)

Call into multiBuffer with locally constructed IRRewriter.

Definition at line 243 of file MultiBuffer.cpp.

References multiBuffer().

◆ multiBuffer() [2/2]

FailureOr< memref::AllocOp > mlir::memref::multiBuffer ( RewriterBase rewriter,
memref::AllocOp  allocOp,
unsigned  multiplier,
bool  skipOverrideAnalysis = false 
)

Transformation to do multi-buffering/array expansion to remove dependencies on the temporary allocation between consecutive loop iterations.

It returns the new allocation if the original allocation was multi-buffered and returns failure() otherwise. When skipOverrideAnalysis, the pass will apply the transformation without checking thwt the buffer is overrided at the beginning of each iteration. This implies that user knows that there is no data carried across loop iterations. Example:

%0 = memref.alloc() : memref<4x128xf32>
scf.for %iv = %c1 to %c1024 step %c3 {
memref.copy %1, %0 : memref<4x128xf32> to memref<4x128xf32>
"some_use"(%0) : (memref<4x128xf32>) -> ()
}

into:

%0 = memref.alloc() : memref<5x4x128xf32>
scf.for %iv = %c1 to %c1024 step %c3 {
%s = arith.subi %iv, %c1 : index
%d = arith.divsi %s, %c3 : index
%i = arith.remsi %d, %c5 : index
%sv = memref.subview %0[%i, 0, 0] [1, 4, 128] [1, 1, 1] :
memref<5x4x128xf32> to memref<4x128xf32, strided<[128, 1], offset: ?>>
memref.copy %1, %sv : memref<4x128xf32> to memref<4x128xf32, strided<...>>
"some_use"(%sv) : (memref<4x128xf32, strided<...>) -> ()
}

Make sure there is no loop-carried dependency on the allocation.

Definition at line 98 of file MultiBuffer.cpp.

References mlir::bindDims(), mlir::OpBuilder::create(), DBGS, mlir::DominanceInfo::dominates(), mlir::RewriterBase::eraseOp(), mlir::failure(), mlir::floorDiv(), mlir::Builder::getContext(), mlir::Builder::getIndexAttr(), mlir::Operation::getUsers(), mlir::getValueOrCreateConstantIndexOp(), mlir::makeComposedAffineApply(), overrideBuffer(), replaceUsesAndPropagateType(), mlir::OpBuilder::setInsertionPoint(), mlir::OpBuilder::setInsertionPointToStart(), and mlir::MemRefType::Builder::setShape().

Referenced by multiBuffer().

◆ populateComposeSubViewPatterns()

void mlir::memref::populateComposeSubViewPatterns ( RewritePatternSet patterns,
MLIRContext context 
)

Definition at line 130 of file ComposeSubView.cpp.

References mlir::RewritePatternSet::add().

◆ populateExpandOpsPatterns()

void mlir::memref::populateExpandOpsPatterns ( RewritePatternSet patterns)

Collects a set of patterns to rewrite ops within the memref dialect.

Definition at line 153 of file ExpandOps.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateExpandStridedMetadataPatterns()

void mlir::memref::populateExpandStridedMetadataPatterns ( RewritePatternSet patterns)

Appends patterns for expanding memref operations that modify the metadata (sizes, offset, strides) of a memref into easier to analyze constructs.

Definition at line 751 of file ExpandStridedMetadata.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateFoldMemRefAliasOpPatterns()

void mlir::memref::populateFoldMemRefAliasOpPatterns ( RewritePatternSet patterns)

Appends patterns for folding memref aliasing ops into consumer load/store ops into patterns.

Definition at line 592 of file FoldMemRefAliasOps.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateMemRefWideIntEmulationConversions()

void mlir::memref::populateMemRefWideIntEmulationConversions ( arith::WideIntEmulationConverter typeConverter)

Appends type converions for emulating wide integer memref operations with ops over narrowe integer types.

Definition at line 147 of file EmulateWideInt.cpp.

References mlir::TypeConverter::addConversion(), mlir::TypeConverter::convertType(), and mlir::arith::WideIntEmulationConverter::getMaxTargetIntBitWidth().

◆ populateMemRefWideIntEmulationPatterns()

void mlir::memref::populateMemRefWideIntEmulationPatterns ( arith::WideIntEmulationConverter typeConverter,
RewritePatternSet patterns 
)

Appends patterns for emulating wide integer memref operations with ops over narrower integer types.

Definition at line 139 of file EmulateWideInt.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

◆ populateResolveRankedShapeTypeResultDimsPatterns()

void mlir::memref::populateResolveRankedShapeTypeResultDimsPatterns ( RewritePatternSet patterns)

Appends patterns that resolve memref.dim operations with values that are defined by operations that implement the ReifyRankedShapeTypeShapeOpInterface, in terms of shapes of its input operands.

Definition at line 123 of file ResolveShapedTypeResultDims.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

Referenced by mlir::linalg::populateFoldUnitExtentDimsViaReshapesPatterns(), and mlir::linalg::populateFoldUnitExtentDimsViaSlicesPatterns().

◆ populateResolveShapedTypeResultDimsPatterns()

void mlir::memref::populateResolveShapedTypeResultDimsPatterns ( RewritePatternSet patterns)

Appends patterns that resolve memref.dim operations with values that are defined by operations that implement the InferShapedTypeOpInterface, in terms of shapes of its input operands.

Definition at line 130 of file ResolveShapedTypeResultDims.cpp.

References mlir::RewritePatternSet::add(), and mlir::RewritePatternSet::getContext().

Referenced by mlir::linalg::populateFoldUnitExtentDimsViaReshapesPatterns(), and mlir::linalg::populateFoldUnitExtentDimsViaSlicesPatterns().

◆ registerBufferizableOpInterfaceExternalModels()

void mlir::memref::registerBufferizableOpInterfaceExternalModels ( DialectRegistry registry)

◆ registerRuntimeVerifiableOpInterfaceExternalModels()

void mlir::memref::registerRuntimeVerifiableOpInterfaceExternalModels ( DialectRegistry registry)

◆ registerTransformDialectExtension()

void mlir::memref::registerTransformDialectExtension ( DialectRegistry registry)

Definition at line 98 of file MemRefTransformOps.cpp.

References mlir::DialectRegistry::addExtensions().

Referenced by mlir::registerAllDialects().