MLIR  16.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...
 
Optional< Operation * > findDealloc (Value allocValue)
 Finds a single dealloc operation for the given allocated value. More...
 
void registerTransformDialectExtension (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 (memref::AllocOp allocOp, unsigned multiplier)
 Transformation to do multi-buffering/array expansion to remove dependencies on the temporary allocation between consecutive loop iterations. 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...
 

Function Documentation

◆ 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 776 of file ExpandStridedMetadata.cpp.

◆ 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 560 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 170 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 166 of file ResolveShapedTypeResultDims.cpp.

◆ findDealloc()

llvm::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 None, else returns the single deallocate if it exists or nullptr.

Definition at line 46 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().

◆ 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()

FailureOr< memref::AllocOp > mlir::memref::multiBuffer ( memref::AllocOp  allocOp,
unsigned  multiplier 
)

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. 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 80 of file MultiBuffer.cpp.

References mlir::OpBuilder::create(), mlir::DominanceInfo::dominates(), mlir::failure(), mlir::floorDiv(), mlir::AffineMap::get(), mlir::getAffineConstantExpr(), mlir::getAffineDimExpr(), mlir::getConstantIntValue(), mlir::Builder::getIndexAttr(), getOrCreateValue(), mlir::Operation::getUsers(), overrideBuffer(), replaceUsesAndPropagateType(), mlir::OpBuilder::setInsertionPoint(), and value.

◆ 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 740 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 522 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 145 of file EmulateWideInt.cpp.

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

◆ 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 137 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 134 of file ResolveShapedTypeResultDims.cpp.

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

◆ 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 141 of file ResolveShapedTypeResultDims.cpp.

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

◆ registerTransformDialectExtension()

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

Definition at line 66 of file MemRefTransformOps.cpp.

References mlir::DialectRegistry::addExtensions().

Referenced by mlir::registerAllDialects().