MLIR  16.0.0git
Classes | Namespaces | Typedefs | Enumerations | Functions
Transforms.h File Reference
#include <utility>
#include "mlir/Conversion/VectorToSCF/VectorToSCF.h"
#include "mlir/Dialect/Linalg/Utils/Utils.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/Dialect/Vector/Transforms/VectorTransforms.h"
#include "mlir/Dialect/X86Vector/Transforms.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/TilingInterface.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallSet.h"
+ Include dependency graph for Transforms.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mlir::linalg::TiledLinalgOp
 Perform standalone tiling of a single LinalgOp by tileSizes. More...
 
struct  mlir::linalg::LinalgPromotionOptions
 
struct  mlir::linalg::PromotionInfo
 Create a new buffer using the allocationFn provided. More...
 
struct  mlir::linalg::LinalgTransforms
 
struct  mlir::linalg::LinalgTransformationFilter
 Helper class to control application of linalg transformation patterns. More...
 
struct  mlir::linalg::MultiSizeSpecification
 A description of a multi-size tiling comprising tile sizes and numbers of tiles, expressed as Values which may or may not be constant. More...
 
struct  mlir::linalg::ForeachThreadTilingResult
 Rewrite a TilingInterface op to a tiled scf.foreach_thread, applying tiling by numThreads. More...
 
struct  mlir::linalg::LinalgPaddingOptions
 
struct  mlir::linalg::LinalgTilingAndFusionOptions
 
struct  mlir::linalg::LinalgTilingOptions
 
struct  mlir::linalg::LinalgTilingPattern
 Linalg tiling pattern. More...
 
struct  mlir::linalg::LinalgPaddingPattern
 Linalg padding pattern. More...
 
struct  mlir::linalg::DownscaleSizeOneWindowed2DConvolution< Conv2DOp, Conv1DOp >
 Rewrites 2-D convolution ops with size-1 window dimensions into 1-D convolution ops. More...
 
struct  mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp
 Rewrites 2-D depthwise convolution ops with size-1 (w, kw) or (h, kh) dimensions into 1-D depthwise convolution ops. More...
 
struct  mlir::linalg::LinalgTileAndFuseTensorOpsPattern
 Linalg tile and fuse tensor ops pattern. More...
 
struct  mlir::linalg::LinalgGeneralizationPattern
 Linalg generalization pattern. More...
 
struct  mlir::linalg::LinalgVectorizationOptions
 Linalg vectorization patterns. More...
 
struct  mlir::linalg::CopyVectorizationPattern
 filter controls LinalgTransformMarker matching and update when specified. More...
 
struct  mlir::linalg::LinalgEnablingOptions
 Options to control the application of enabling transformations. More...
 
struct  mlir::linalg::LinalgLoweringPattern< OpTy >
 
struct  mlir::linalg::PadOpTransformationPattern
 tensor::PadOp is not canonicalized away yet, so we provide a transformation to linalg.generic. More...
 
struct  mlir::linalg::GeneralizePadOpPattern
 Rewrite a tensor::PadOp into a sequence of EmptyOp, FillOp and InsertSliceOp. More...
 
struct  mlir::linalg::LinalgCopyVTRForwardingPattern
 Match and rewrite for the pattern: ``` alloc = ... More...
 
struct  mlir::linalg::LinalgCopyVTWForwardingPattern
 Match and rewrite for the pattern: ``` alloc = ... More...
 
struct  mlir::linalg::ExtractSliceOfPadTensorSwapPattern
 Rewrite extract_slice(tensor.pad(x)) into tensor.pad(extract_slice(x)). More...
 
class  mlir::linalg::VectorizationPatterns< OpTypes >
 
class  mlir::linalg::VectorizationPatterns<>
 
class  mlir::linalg::TilingPatterns< OpTypes >
 
class  mlir::linalg::TilingPatterns<>
 
class  mlir::linalg::TilingPatterns< OpTy, OpTypes... >
 
struct  mlir::linalg::SplitReductionOptions
 Split Reduction options. More...
 
struct  mlir::linalg::SplitReductionResult
 Filterless version of the above. More...
 

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::bufferization
 
 mlir::linalg
 

Typedefs

using mlir::linalg::LinalgLoops = SmallVector< Operation *, 4 >
 
using mlir::linalg::ControlFusionFn = std::function< bool(OpOperand *fusedOperand)>
 Function type which is used to control when to stop fusion. More...
 
using mlir::linalg::AllocBufferCallbackFn = std::function< Optional< Value >(OpBuilder &b, memref::SubViewOp subView, ArrayRef< Value > boundingSubViewSize, DataLayout &layout)>
 Callback function type used to perform the allocation for the promoted subView. More...
 
using mlir::linalg::DeallocBufferCallbackFn = std::function< LogicalResult(OpBuilder &b, Value buffer)>
 Callback function type used to deallocate the buffers used to hold the promoted subview. More...
 
using mlir::linalg::CopyCallbackFn = std::function< LogicalResult(OpBuilder &b, Value src, Value dst)>
 Callback function type used to insert copy from original subview to subview of the promoted region for the read operands/subview of promoted region to original subview for the results. More...
 
using mlir::linalg::TileSizeComputationFunction = std::function< SmallVector< Value, 4 >(OpBuilder &, Operation *)>
 
using mlir::linalg::LoopIndexToRangeIndexMap = DenseMap< int, int >
 Creates a number of ranges equal to the number of non-zero in tileSizes. More...
 
using mlir::linalg::OptimizeCopyFn = std::function< LogicalResult(PatternRewriter &, tensor::PadOp, Value)>
 
using mlir::linalg::ControlSplitReductionFn = std::function< SplitReductionOptions(LinalgOp op)>
 Function signature to control reduction splitting. More...
 

Enumerations

enum  mlir::linalg::LinalgLoweringType { mlir::linalg::LinalgLoweringType::LibraryCall = 0, mlir::linalg::LinalgLoweringType::Loops = 1, mlir::linalg::LinalgLoweringType::AffineLoops = 2, mlir::linalg::LinalgLoweringType::ParallelLoops = 3 }
 Linalg lowering patterns. More...
 

Functions

void mlir::linalg::populatePadTensorTilingPatterns (RewritePatternSet &patterns, const LinalgTilingOptions &options)
 
void mlir::linalg::populateDecomposeLinalgOpsPattern (RewritePatternSet &patterns)
 Populate patterns for splitting a LinalgOp with multiple statements within its payload into multiple GenericOp that have a single statement. More...
 
void mlir::linalg::populateConvolutionVectorizationPatterns (RewritePatternSet &patterns, PatternBenefit benefit=1)
 Populate patterns for vectorizing low-D convolution ops. More...
 
void mlir::linalg::populateElementwiseToLinalgConversionPatterns (RewritePatternSet &patterns)
 Populate patterns that convert ElementwiseMappable ops to linalg parallel loops. More...
 
void mlir::linalg::populateSparseTensorRewriting (RewritePatternSet &patterns)
 Populate patterns that are only useful in the context of sparse tensors. More...
 
void mlir::linalg::populateElementwiseOpsFusionPatterns (RewritePatternSet &patterns, const ControlFusionFn &controlElementwiseOpFusion)
 Patterns for fusing linalg operation on tensors. More...
 
void mlir::linalg::populateFoldReshapeOpsByExpansionPatterns (RewritePatternSet &patterns, const ControlFusionFn &controlFoldingReshapes)
 Patterns to fold an expanding (collapsing) tensor_reshape operation with its producer (consumer) generic operation by expanding the dimensionality of the loop in the generic op. More...
 
void mlir::linalg::populateFoldReshapeOpsByCollapsingPatterns (RewritePatternSet &patterns, const ControlFusionFn &controlFoldingReshapes)
 Patterns to fold an expanding tensor.expand_shape operation with its producer generic operation by collapsing the dimensions of the generic op. More...
 
void mlir::linalg::populateConstantFoldLinalgOperations (RewritePatternSet &patterns, const ControlFusionFn &controlFn)
 Patterns to constant fold Linalg operations. More...
 
void mlir::linalg::populateFuseTensorPadWithProducerLinalgOpPatterns (RewritePatternSet &patterns)
 Pattern to fuse a tensor.pad operation with the producer of its source, if the producer is a linalg operation with all parallel iterator types. More...
 
void mlir::linalg::populateLinalgNamedOpConversionPatterns (RewritePatternSet &patterns)
 Patterns to convert from one named op to another. More...
 
void mlir::linalg::populateFoldUnitExtentDimsPatterns (RewritePatternSet &patterns)
 Patterns to fold unit-extent dimensions in operands/results of linalg ops on tensors. More...
 
void mlir::linalg::populateInlineConstantOperandsPatterns (RewritePatternSet &patterns)
 Patterns that are used to inline constant operands into linalg generic ops. More...
 
void mlir::linalg::populateBubbleUpExtractSliceOpPatterns (RewritePatternSet &patterns)
 Patterns that are used to bubble up extract slice op above linalg op. More...
 
void mlir::linalg::populateSwapExtractSliceWithFillPatterns (RewritePatternSet &patterns)
 Adds patterns that waps tensor.extract_slice(linalg.fill(cst, init)) into linalg.fill(cst, tensor.extract_slice(init)). More...
 
bool mlir::linalg::areElementwiseOpsFusable (OpOperand *fusedOperand)
 Return true if two linalg.generic operations with producer/consumer relationship through fusedOperand can be fused using elementwise op fusion. More...
 
FailureOr< Operation * > mlir::linalg::fuseElementwiseOps (RewriterBase &rewriter, OpOperand *fusedOperand)
 Fuse two linalg.generic operations that have a producer-consumer relationship captured through fusedOperand. More...
 
std::pair< TilingInterface, TilingInterface > mlir::linalg::splitOp (RewriterBase &rewriter, TilingInterface op, unsigned dimension, OpFoldResult splitPoint)
 Split the given op into two parts along the given iteration space dimension at the specified splitPoint, and return the two parts. More...
 
FailureOr< TiledLinalgOpmlir::linalg::tileLinalgOp (RewriterBase &b, LinalgOp op, const LinalgTilingOptions &options)
 
void mlir::linalg::peelLoops (RewriterBase &rewriter, ArrayRef< scf::ForOp > loops)
 Peel and canonicalize 'loops'. More...
 
void mlir::linalg::peelTiledLinalgOp (RewriterBase &rewriter, TiledLinalgOp &res, ArrayRef< int64_t > peeledLoops, LinalgTilingLoopType loopType)
 Peel the loops of a TiledLinalgOp. More...
 
FailureOr< GenericOp > mlir::linalg::interchangeGenericOp (RewriterBase &rewriter, GenericOp genericOp, ArrayRef< unsigned > interchangeVector)
 Interchange the iterator_types and iterator_maps dimensions and adapts the index accesses of op. More...
 
FailureOr< GenericOp > mlir::linalg::generalizeNamedOp (RewriterBase &rewriter, LinalgOp namedOp)
 Create a GenericOp from the given named operation namedOp and replace namedOp. More...
 
FailureOr< PromotionInfomlir::linalg::promoteSubviewAsNewBuffer (OpBuilder &b, Location loc, memref::SubViewOp subView, const AllocBufferCallbackFn &allocationFn, DataLayout &layout)
 
FailureOr< LinalgOp > mlir::linalg::promoteSubViews (OpBuilder &b, LinalgOp op, const LinalgPromotionOptions &options)
 Promote the subViews into a new buffer allocated at the insertion point b. More...
 
LogicalResult mlir::linalg::vectorize (RewriterBase &builder, LinalgOp linalgOp)
 Emit a suitable vector form for a Linalg op with fully static shape. More...
 
LogicalResult mlir::linalg::vectorizeCopy (RewriterBase &builder, memref::CopyOp copyOp)
 Emit a suitable vector form for a Copy op with fully static shape. More...
 
FailureOr< LinalgLoopsmlir::linalg::linalgOpToLoops (PatternRewriter &rewriter, LinalgOp linalgOp)
 Emit a loop nest of scf.for with the proper body for linalgOp. More...
 
FailureOr< LinalgLoopsmlir::linalg::linalgOpToParallelLoops (PatternRewriter &rewriter, LinalgOp linalgOp)
 Emit a loop nest of scf.parallel with the proper body for linalgOp. More...
 
FailureOr< LinalgLoopsmlir::linalg::linalgOpToAffineLoops (PatternRewriter &rewriter, LinalgOp linalgOp)
 Emit a loop nest of affine.for with the proper body for linalgOp. More...
 
LogicalResult mlir::linalg::promoteSubviewsPrecondition (Operation *op, LinalgPromotionOptions options)
 Promote memref.subviews feeding linalg-on-buffers operations. More...
 
LogicalResult mlir::linalg::vectorizeLinalgOpPrecondition (LinalgOp linalgOp)
 Return success if the operation can be vectorized. More...
 
std::tuple< SmallVector< Range, 4 >, LoopIndexToRangeIndexMapmlir::linalg::makeTiledLoopRanges (RewriterBase &b, Location loc, AffineMap map, ArrayRef< OpFoldResult > allShapeSizes, ArrayRef< OpFoldResult > allTileSizes)
 
FailureOr< MultiSizeSpecificationmlir::linalg::computeMultiTileSizes (OpBuilder &builder, LinalgOp op, unsigned dimension, OpFoldResult targetSize, OpFoldResult divisor, bool emitAssertions=true)
 Emits the IR computing the multi-sized tiling specification with two tile sizes not exceeding targetSize, each divisible by sizeDivisor, such that there exist numbers of tiles with these sizes that fully cover the given iteration space dimension of the structured op. More...
 
FailureOr< ForeachThreadTilingResultmlir::linalg::tileToForeachThreadOp (RewriterBase &builder, TilingInterface op, ArrayRef< OpFoldResult > numThreads, ArrayRef< int64_t > threadDimMapping={})
 
FailureOr< ForeachThreadTilingResultmlir::linalg::tileToForeachThreadOpUsingTileSizes (RewriterBase &builder, TilingInterface op, ArrayRef< OpFoldResult > tileSizes, ArrayRef< int64_t > threadDimMapping={})
 Same as tileToForeachThreadOp, but calculate the number of threads required using the given tileSizes. More...
 
void mlir::linalg::transformIndexOps (RewriterBase &b, LinalgOp op, SmallVectorImpl< Value > &ivs, const LoopIndexToRangeIndexMap &loopIndexToRangeIndex)
 All indices returned by IndexOp should be invariant with respect to tiling. More...
 
RewritePatternSet mlir::linalg::getLinalgTilingCanonicalizationPatterns (MLIRContext *ctx)
 Canonicalization patterns relevant to apply after tiling patterns. More...
 
void mlir::linalg::populateLinalgTilingCanonicalizationPatterns (RewritePatternSet &patterns)
 
llvm::Optional< vector::CombiningKind > mlir::linalg::getCombinerOpKind (Operation *combinerOp)
 Return vector::CombiningKind for the given op. More...
 
void mlir::linalg::populateLinalgNamedOpsGeneralizationPatterns (RewritePatternSet &patterns, const LinalgTransformationFilter &filter=LinalgTransformationFilter())
 Linalg generalization patterns. More...
 
void mlir::linalg::populateDecomposeConvolutionPatterns (RewritePatternSet &patterns, const LinalgTransformationFilter &filter=LinalgTransformationFilter(), PatternBenefit benefit=1)
 Linalg decompose convolutions patterns. More...
 
FailureOr< SmallVector< Value > > mlir::linalg::rewriteAsPaddedOp (OpBuilder &b, LinalgOp opToPad, ArrayRef< int64_t > paddingDimensions, ArrayRef< Attribute > paddingValues, ArrayRef< bool > packPaddings, LinalgOp &paddedOp)
 Pad the iterator dimensions paddingDimensions of all opToPad operands to a static bounding box. More...
 
void mlir::linalg::populatePadOpVectorizationPatterns (RewritePatternSet &patterns, PatternBenefit baseBenefit=1)
 Populates patterns with patterns that vectorize tensor.pad. More...
 
LogicalResult mlir::linalg::applyStagedPatterns (Operation *op, ArrayRef< FrozenRewritePatternSet > stage1Patterns, const FrozenRewritePatternSet &stage2Patterns, function_ref< LogicalResult(Operation *)> stage3Lambda=nullptr)
 Helper function to allow applying rewrite patterns, interleaved with more global transformations, in a staged fashion: More...
 
void mlir::linalg::populateSplitReductionPattern (RewritePatternSet &patterns, const ControlSplitReductionFn &controlSplitReductionFn, const LinalgTransformationFilter &f=LinalgTransformationFilter(), bool useAlloc=false)
 Patterns to apply splitReduction below. More...
 
FailureOr< LinalgOp > mlir::linalg::splitReduction (PatternRewriter &b, LinalgOp op, const ControlSplitReductionFn &controlSplitReductionFn, const LinalgTransformationFilter &f, bool useAlloc=false)
 Apply transformation to split the single linalg op reduction into a parallel and reduction dimension. More...
 
FailureOr< SplitReductionResultmlir::linalg::splitReduction (PatternRewriter &b, LinalgOp op, const ControlSplitReductionFn &controlSplitReductionFn, bool useAlloc=false)
 
FailureOr< SplitReductionResultmlir::linalg::splitReductionByScaling (PatternRewriter &b, LinalgOp op, const ControlSplitReductionFn &controlSplitReductionFn, bool useAlloc=false)
 Scaling-based implementation of the split reduction transformation. More...