My Project
|
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< FusionInfo > | fuseProducerOf (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< TiledLinalgOp > | tileLinalgOp (OpBuilder &b, LinalgOp op, ArrayRef< Value > tileSizes, ArrayRef< unsigned > permutation={}, OperationFolder *folder=nullptr) |
Optional< TiledLinalgOp > | tileLinalgOp (OpBuilder &b, LinalgOp op, ArrayRef< int64_t > tileSizes, ArrayRef< unsigned > permutation={}, OperationFolder *folder=nullptr) |
template<typename... Args> | |
Optional< TiledLinalgOp > | tileLinalgOperation (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) |
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.
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 leaves
inVec = ['c', 'a', 'b']`.
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.
std::unique_ptr< OpPassBase< ModuleOp > > mlir::linalg::createConvertLinalgToLLVMPass | ( | ) |
Create a pass to convert Linalg operations to the LLVMIR dialect.
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.
std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgFusionPass | ( | ) |
std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgPromotionPass | ( | bool | dynamicBuffers | ) |
std::unique_ptr< OpPassBase< FuncOp > > mlir::linalg::createLinalgTilingPass | ( | ArrayRef< int64_t > | tileSizes = {} | ) |
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.
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:
linalg.
prefix, and the <
, >
, ?
symbols from the type. Assumes op
is a LinalgOp.Examples:
linalg_fill_viewf32_f32_impl
linalg_dot_viewxf32_viewxf32_viewf32_impl
linalg_matmul_viewxxf32_viewxxf32_viewxxf32_impl
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
.
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.
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).
bool mlir::linalg::isProducedByOpOfType | ( | Operation * | consumerOp, |
Value | consumedView | ||
) |
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
.
LogicalResult mlir::linalg::linalgOpToAffineLoops | ( | PatternRewriter & | rewriter, |
Operation * | op | ||
) |
Emits a loop nest of affine.for
with the proper body for op
.
LogicalResult mlir::linalg::linalgOpToLoops | ( | PatternRewriter & | rewriter, |
Operation * | op | ||
) |
Emits a loop nest of loop.for
with the proper body for op
.
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:
Only permutation maps are currently supported.
SmallVector< Value, 0 > mlir::linalg::permuteGenericLinalgOp | ( | PatternRewriter & | rewriter, |
Operation * | op, | ||
ArrayRef< unsigned > | permutation, | ||
StringRef | linalgMarker | ||
) |
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
.
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
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:
linalg.fill
it with zeros (use float zero for now).dynamicBuffers
is true.Returns a list of PromotionInfo which hold the promoted buffer and the full and partial views indexing into the buffer.
SmallVector< Value, 0 > mlir::linalg::promoteSubviewsLinalgOp | ( | PatternRewriter & | rewriter, |
Operation * | op | ||
) |
LogicalResult mlir::linalg::promoteSubviewsLinalgOpPrecondition | ( | Operation * | op | ) |
Promote std.subviews feeding linalg operations.
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
.
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.
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.
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.
Optional<TiledLinalgOp> mlir::linalg::tileLinalgOperation | ( | OpBuilder & | b, |
Operation * | op, | ||
Args... | args | ||
) |
SmallVector< Value, 0 > mlir::linalg::vectorizeGenericLinalgOp | ( | PatternRewriter & | rewriter, |
Operation * | op | ||
) |
LogicalResult mlir::linalg::vectorizeGenericLinalgOpPrecondition | ( | Operation * | op | ) |
Rewrite a linalg.generic into a suitable vector.contraction op.