My Project
Namespaces | Classes | Enumerations | Functions
mlir::linalg Namespace Reference

Namespaces

 detail
 
 intrinsics
 

Classes

class  Aliases
 
struct  FusionInfo
 
class  LinalgDependenceGraph
 
class  LinalgDialect
 
struct  LinalgTransforms
 
struct  PromotionInfo
 
class  RangeType
 
struct  TiledLinalgOp
 

Enumerations

enum  LinalgTypes { Range = Type::FIRST_LINALG_TYPE, LAST_USED_LINALG_TYPE = Range }
 

Functions

std::string generateLibraryCallName (Operation *op)
 
SmallVector< AffineMap, 4 > loopToOperandRangesMaps (Operation *op)
 
std::unique_ptr< OpPassBase< FuncOp > > createLinalgFusionPass ()
 
std::unique_ptr< OpPassBase< FuncOp > > createLinalgTilingPass (ArrayRef< int64_t > tileSizes={})
 
std::unique_ptr< OpPassBase< FuncOp > > createLinalgPromotionPass (bool dynamicBuffers)
 
std::unique_ptr< OpPassBase< FuncOp > > createConvertLinalgToLoopsPass ()
 
std::unique_ptr< OpPassBase< FuncOp > > createConvertLinalgToAffineLoopsPass ()
 
std::unique_ptr< OpPassBase< ModuleOp > > createConvertLinalgToLLVMPass ()
 Create a pass to convert Linalg operations to the LLVMIR dialect. More...
 
template<typename OpTy >
bool isProducedByOpOfType (Operation *consumerOp, Value consumedView)
 
LogicalResult tileLinalgOpAndSetMarker (PatternRewriter &rewriter, Operation *op, ArrayRef< int64_t > sizes, StringRef linalgMarker, ArrayRef< unsigned > permutation)
 
LogicalResult tileAndFuseLinalgOpAndSetMarker (PatternRewriter &rewriter, Operation *op, ArrayRef< int64_t > sizes, ArrayRef< int64_t > operandIndicesToFuse, StringRef linalgMarker)
 
template<typename ConcreteOp >
LogicalResult linalgOpToLoops (PatternRewriter &rewriter, Operation *op)
 Emits a loop nest of loop.for with the proper body for op. More...
 
template<typename ConcreteOp >
LogicalResult linalgOpToAffineLoops (PatternRewriter &rewriter, Operation *op)
 Emits a loop nest of affine.for with the proper body for op. More...
 
LogicalResult vectorizeGenericLinalgOpPrecondition (Operation *op)
 Rewrite a linalg.generic into a suitable vector.contraction op. More...
 
SmallVector< Value, 0 > vectorizeGenericLinalgOp (PatternRewriter &rewriter, Operation *op)
 
LogicalResult permuteGenericLinalgOpPrecondition (Operation *op, ArrayRef< unsigned > permutation)
 
SmallVector< Value, 0 > permuteGenericLinalgOp (PatternRewriter &rewriter, Operation *op, ArrayRef< unsigned > permutation, StringRef linalgMarker)
 
LogicalResult promoteSubviewsLinalgOpPrecondition (Operation *op)
 Promote std.subviews feeding linalg operations. More...
 
SmallVector< Value, 0 > promoteSubviewsLinalgOp (PatternRewriter &rewriter, Operation *op)
 
bool isProducerLastWriteOfView (const LinalgDependenceGraph &graph, LinalgOp consumer, Value consumedView, LinalgOp producer)
 
bool isFusableInto (const LinalgDependenceGraph &graph, LinalgOp consumer, Value consumedView, LinalgOp producer)
 
Optional< FusionInfofuseProducerOf (OpBuilder &b, LinalgOp consumer, unsigned consumerIdx, const LinalgDependenceGraph &graph, OperationFolder *folder=nullptr)
 
template<typename ConcreteOp >
SmallVector< Value, 8 > getViewSizes (ConcreteOp linalgOp)
 
SmallVector< Value, 4 > applyMapToValues (OpBuilder &b, Location loc, AffineMap map, ArrayRef< Value > values, OperationFolder *folder=nullptr)
 
Optional< TiledLinalgOptileLinalgOp (OpBuilder &b, LinalgOp op, ArrayRef< Value > tileSizes, ArrayRef< unsigned > permutation={}, OperationFolder *folder=nullptr)
 
Optional< TiledLinalgOptileLinalgOp (OpBuilder &b, LinalgOp op, ArrayRef< int64_t > tileSizes, ArrayRef< unsigned > permutation={}, OperationFolder *folder=nullptr)
 
template<typename... Args>
Optional< TiledLinalgOptileLinalgOperation (OpBuilder &b, Operation *op, Args... args)
 
SmallVector< PromotionInfo, 8 > promoteSubViews (OpBuilder &b, Location loc, ArrayRef< Value > subViews, bool dynamicBuffers=false, OperationFolder *folder=nullptr)
 
SmallVector< Value, 4 > getAssumedNonViewOperands (LinalgOp linalgOp)
 
template<typename T , unsigned N>
void applyPermutationToVector (SmallVector< T, N > &inVec, ArrayRef< unsigned > permutation)
 
LinalgOp promoteSubViewOperands (OpBuilder &b, LinalgOp op, llvm::SetVector< Value > subViews, bool dynamicBuffers=false, OperationFolder *folder=nullptr)
 

Enumeration Type Documentation

◆ LinalgTypes

Enumerator
Range 
LAST_USED_LINALG_TYPE 

Function Documentation

◆ applyMapToValues()

SmallVector< Value, 4 > mlir::linalg::applyMapToValues ( OpBuilder b,
Location  loc,
AffineMap  map,
ArrayRef< Value values,
OperationFolder folder = nullptr 
)

Returns the values obtained by applying map to the list of values. When non-null, the optional pointer folder is used to call into the createAndFold builder method. If folder is null, the regular create method is called.

◆ applyPermutationToVector()

template<typename T , unsigned N>
void mlir::linalg::applyPermutationToVector ( SmallVector< T, N > &  inVec,
ArrayRef< unsigned >  permutation 
)

Apply the permutation defined by permutation to inVec. Element i in inVec is mapped to location j = permutation[i]. E.g.: for an input vector `inVec = ['a', 'b', 'c']and a permutation vector permutation = [2, 0, 1], this function leavesinVec = ['c', 'a', 'b']`.

◆ createConvertLinalgToAffineLoopsPass()

std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createConvertLinalgToAffineLoopsPass ( )

Create a pass to convert Linalg operations to affine.for loops and affine_load/affine_store accesses. Placeholder for now, this is NYI.

◆ createConvertLinalgToLLVMPass()

std::unique_ptr< OpPassBase< ModuleOp > > mlir::linalg::createConvertLinalgToLLVMPass ( )

Create a pass to convert Linalg operations to the LLVMIR dialect.

◆ createConvertLinalgToLoopsPass()

std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createConvertLinalgToLoopsPass ( )

Create a pass to convert Linalg operations to loop.for loops and std.load/std.store accesses.

◆ createLinalgFusionPass()

std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgFusionPass ( )

◆ createLinalgPromotionPass()

std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgPromotionPass ( bool  dynamicBuffers)

◆ createLinalgTilingPass()

std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgTilingPass ( ArrayRef< int64_t >  tileSizes = {})

◆ fuseProducerOf()

Optional< FusionInfo > mlir::linalg::fuseProducerOf ( OpBuilder b,
LinalgOp  consumer,
unsigned  consumerIdx,
const LinalgDependenceGraph graph,
OperationFolder folder = nullptr 
)

Fuses producer into consumer if the producer is structurally feasible and the fusion would not violate dependencies. When non-null, the optional pointer folder is used to call into the createAndFold builder method. If folder is null, the regular create method is called.

◆ generateLibraryCallName()

std::string mlir::linalg::generateLibraryCallName ( Operation op)

Returns the name mangled library call name to disambiguate between different overloads at the C level. The name mangling scheme is basic and uses MLIR type names:

  1. form a string which is the concatenation of the linalg op name with all the operand type names, separate by underscores;
  2. drop the linalg. prefix, and the <, >, ? symbols from the type. Assumes op is a LinalgOp.

Examples:

  1. linalg.fill(A, f) : memref<f32>, f32 name mangles into linalg_fill_viewf32_f32_impl
  2. linalg.dot(A, B, C) : memref<?xf32, stride_specification>, memref<?xf32, stride_specification>, memref<f32> name mangles into linalg_dot_viewxf32_viewxf32_viewf32_impl
  3. linalg.matmul(...) : memref<?x?xf32, stride_specification>, memref<?x?xf32, stride_specification>, memref<?x?xf32, stride_specification> name mangles into linalg_matmul_viewxxf32_viewxxf32_viewxxf32_impl

◆ getAssumedNonViewOperands()

SmallVector< Value, 4 > mlir::linalg::getAssumedNonViewOperands ( LinalgOp  linalgOp)

Returns all the operands of linalgOp that are not views. Asserts that these operands are value types to allow transformations like tiling to just use the values when cloning linalgOp.

◆ getViewSizes()

template<typename ConcreteOp >
SmallVector<Value, 8> mlir::linalg::getViewSizes ( ConcreteOp  linalgOp)

Returns the linearized list of all view dimensions in a linalgOp. Applying the inverse, concatenated loopToOperandRangeMaps to this list allows the derivation of loop ranges for any linalgOp.

◆ isFusableInto()

bool mlir::linalg::isFusableInto ( const LinalgDependenceGraph graph,
LinalgOp  consumer,
Value  consumedView,
LinalgOp  producer 
)

Checks whether fusing the specific producer of the consumedView is feasible. This checks producer is the last write of consumedView and that no interleaved dependence would be violated (RAW, WAR or WAW).

◆ isProducedByOpOfType()

template<typename OpTy >
bool mlir::linalg::isProducedByOpOfType ( Operation consumerOp,
Value  consumedView 
)

◆ isProducerLastWriteOfView()

bool mlir::linalg::isProducerLastWriteOfView ( const LinalgDependenceGraph graph,
LinalgOp  consumer,
Value  consumedView,
LinalgOp  producer 
)

Checks whether the specific producer is the last write to exactly the whole consumedView. This checks structural dominance, that the dependence is a RAW without any interleaved write to any piece of consumedView.

◆ linalgOpToAffineLoops()

template<typename ConcreteOp >
LogicalResult mlir::linalg::linalgOpToAffineLoops ( PatternRewriter rewriter,
Operation op 
)

Emits a loop nest of affine.for with the proper body for op.

◆ linalgOpToLoops()

template<typename ConcreteOp >
LogicalResult mlir::linalg::linalgOpToLoops ( PatternRewriter rewriter,
Operation op 
)

Emits a loop nest of loop.for with the proper body for op.

◆ loopToOperandRangesMaps()

SmallVector< AffineMap, 4 > mlir::linalg::loopToOperandRangesMaps ( Operation op)

Returns the list of maps that map loops to operands of a Linalg op. The i-th affine map identifies loop indices to subscripts that are used when accessing the i-th operand. For instance, a matmul that can be written in index notation as: A(i, k) * B(k, j) -> C(i, j) will have the following, ordered, list of affine maps:

(
(i, j, k) -> (i, k),
(i, j, k) -> (k, j),
(i, j, k) -> (i, j)
)

Only permutation maps are currently supported.

◆ permuteGenericLinalgOp()

SmallVector< Value, 0 > mlir::linalg::permuteGenericLinalgOp ( PatternRewriter rewriter,
Operation op,
ArrayRef< unsigned >  permutation,
StringRef  linalgMarker 
)

◆ permuteGenericLinalgOpPrecondition()

LogicalResult mlir::linalg::permuteGenericLinalgOpPrecondition ( Operation op,
ArrayRef< unsigned >  permutation 
)

Emits a generic or indexed_generic operation with the indexing_maps and iterator_types permutated according to permutation.

◆ promoteSubViewOperands()

LinalgOp mlir::linalg::promoteSubViewOperands ( OpBuilder b,
LinalgOp  op,
llvm::SetVector< Value subViews,
bool  dynamicBuffers = false,
OperationFolder folder = nullptr 
)

Prepares the SubView promotion later performed by promoteSubViews (where most of the transformation happens). It arranges the new operands for LinalgOp op and deallocates the new buffer(s) It is the entry point for declarative transformation Returns the cloned LinalgOp with the new operands

◆ promoteSubViews()

SmallVector< PromotionInfo, 8 > mlir::linalg::promoteSubViews ( OpBuilder b,
Location  loc,
ArrayRef< Value subViews,
bool  dynamicBuffers = false,
OperationFolder folder = nullptr 
)

Promotes the subViews into a new buffer allocated at the insertion point b. For now, promotion occurs in 3 steps:

  1. Create a new buffer for a full tile (i.e. not clipped at the boundary).
  2. Take a full view on the buffer and linalg.fill it with zeros (use float zero for now).
  3. Take a partial slice of the full view in step 2. and copy into it. Infers statically sized buffers from subViews unless dynamicBuffers is true.

Returns a list of PromotionInfo which hold the promoted buffer and the full and partial views indexing into the buffer.

◆ promoteSubviewsLinalgOp()

SmallVector< Value, 0 > mlir::linalg::promoteSubviewsLinalgOp ( PatternRewriter rewriter,
Operation op 
)

◆ promoteSubviewsLinalgOpPrecondition()

LogicalResult mlir::linalg::promoteSubviewsLinalgOpPrecondition ( Operation op)

Promote std.subviews feeding linalg operations.

◆ tileAndFuseLinalgOpAndSetMarker()

LogicalResult mlir::linalg::tileAndFuseLinalgOpAndSetMarker ( PatternRewriter rewriter,
Operation op,
ArrayRef< int64_t >  sizes,
ArrayRef< int64_t >  operandIndicesToFuse,
StringRef  linalgMarker 
)

Tiles op by sizes, fuses the producers of operandIndicesToFuse and sets the attribute kLinalgTransformMarker to linalgMarker.

◆ tileLinalgOp() [1/2]

Optional< TiledLinalgOp > mlir::linalg::tileLinalgOp ( OpBuilder b,
LinalgOp  op,
ArrayRef< Value tileSizes,
ArrayRef< unsigned >  permutation = {},
OperationFolder folder = nullptr 
)

Performs standalone tiling of a single LinalgOp by tileSizes. and permute the loop nest according to permutation The permutation is expressed as a list of integers that specify the new ordering of the loop nest. The length of permutation must be equal to the length of tileSizes. E.g. the permutation (i,j,k) -> (j,k,i) will be expressed with permutation = [1,2,0]. All values in permutation must be integers, in the range 0..tileSizes.size() without duplications (i.e. [1,1,2] is an invalid permutation). An empty list states for the identity permutation. Returns a struct containing the tiled loops in the specified order and the cloned op if successful, llvm::None otherwise. When non-null, the optional pointer folder is used to call into the createAndFold builder method. If folder is null, the regular create method is called.

◆ tileLinalgOp() [2/2]

Optional< TiledLinalgOp > mlir::linalg::tileLinalgOp ( OpBuilder b,
LinalgOp  op,
ArrayRef< int64_t >  tileSizes,
ArrayRef< unsigned >  permutation = {},
OperationFolder folder = nullptr 
)

Performs standalone tiling of a single LinalgOp by constant tileSizes. and permute the loop nest according to permutation The permutation is expressed as a list of integers that specify the new ordering of the loop nest. The length of permutation must be equal to the length of tileSizes. E.g. the permutation (i,j,k) -> (j,k,i) will be expressed with permutation = [1,2,0]. All values in permutation must be integers, in the range 0..tileSizes.size() without duplications (i.e. [1,1,2] is an invalid permutation). An empty list states for the identity permutation. Returns a struct containing the tiled loops in the specified order and the cloned op if successful, llvm::None otherwise. When non-null, the optional pointer folder is used to call into the createAndFold builder method. If folder is null, the regular create method is called.

◆ tileLinalgOpAndSetMarker()

LogicalResult mlir::linalg::tileLinalgOpAndSetMarker ( PatternRewriter rewriter,
Operation op,
ArrayRef< int64_t >  sizes,
StringRef  linalgMarker,
ArrayRef< unsigned >  permutation 
)

Tiles op by sizes permuting the loops according to permutation and sets the attribute kLinalgTransformMarker to linalgMarker. The permutation is expressed as a list of integers that specify the new ordering of the loop nest. The length of permutation must be equal to the length of tileSizes. E.g. the permutation (i,j,k) -> (j,k,i) will be expressed with permutation = [1,2,0]. All values in permutation must be integers, in the range 0..tileSizes.size() without duplications (i.e. [1,1,2] is an invalid permutation). An empty list states for the identity permutation.

◆ tileLinalgOperation()

template<typename... Args>
Optional<TiledLinalgOp> mlir::linalg::tileLinalgOperation ( OpBuilder b,
Operation op,
Args...  args 
)

◆ vectorizeGenericLinalgOp()

SmallVector< Value, 0 > mlir::linalg::vectorizeGenericLinalgOp ( PatternRewriter rewriter,
Operation op 
)

◆ vectorizeGenericLinalgOpPrecondition()

LogicalResult mlir::linalg::vectorizeGenericLinalgOpPrecondition ( Operation op)

Rewrite a linalg.generic into a suitable vector.contraction op.