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 populateComposeSubViewPatterns (RewritePatternSet &patterns, MLIRContext *context)
 
void populateExpandOpsPatterns (RewritePatternSet &patterns)
 Collects a set of patterns to rewrite ops within the memref dialect. More...
 
void populateFoldSubViewOpPatterns (RewritePatternSet &patterns)
 Appends patterns for folding memref.subview 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...
 
LogicalResult 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< PasscreateFoldSubViewOpsPass ()
 Creates an operation pass to fold memref.subview 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...
 

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 152 of file ExpandOps.cpp.

◆ createFoldSubViewOpsPass()

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

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

Definition at line 274 of file FoldSubViewOps.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 49 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 159 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 155 of file ResolveShapedTypeResultDims.cpp.

◆ findDealloc()

llvm::Optional< Operation * > mlir::memref::findDealloc ( Value  allocValue)

Finds a single dealloc operation for the given allocated value.

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::SideEffects::EffectInstance< EffectT >::getEffect(), and mlir::Value::getUsers().

Referenced by mlir::bufferization::BufferPlacementAllocs::BufferPlacementAllocs(), and mlir::bufferization::populateDynamicDimSizes().

◆ 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 computeMemRefRankReductionMask(), AllocaScopeHoister::matchAndRewrite(), CollapseShapeOpMemRefCastFolder::matchAndRewrite(), parseGlobalMemrefOpTypeAndInitialValue(), and mlir::bufferization::populateDynamicDimSizes().

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

LogicalResult 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 return success if the 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, #map0>
memref.copy %1, %sv : memref<4x128xf32> to memref<4x128xf32, #map0>
"some_use"(%sv) : (memref<4x128xf32, $map0>) -> ()
}

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

Definition at line 81 of file MultiBuffer.cpp.

References mlir::OpBuilder::create(), mlir::failure(), mlir::floorDiv(), mlir::AffineMap::get(), mlir::getAffineDimExpr(), mlir::Builder::getIndexAttr(), getOrCreateValue(), mlir::Operation::getUsers(), overrideBuffer(), replaceUsesAndPropagateType(), mlir::OpBuilder::setInsertionPoint(), and mlir::success().

◆ 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 147 of file ExpandOps.cpp.

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

◆ populateFoldSubViewOpPatterns()

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

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

Definition at line 245 of file FoldSubViewOps.cpp.

References mlir::RewritePatternSet::add(), mlir::applyPatternsAndFoldGreedily(), 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 populateResolveShapedTypeResultDimsPatterns().

◆ 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(), mlir::applyPatternsAndFoldGreedily(), mlir::failed(), mlir::RewritePatternSet::getContext(), and populateResolveRankedShapeTypeResultDimsPatterns().