@@ -347,9 +347,7 @@ struct LinalgTilingOptions {
347
347
// / values must not fold away when tiling. Otherwise, use a more robust
348
348
// / `tileSizeComputationFunction`.
349
349
LinalgTilingOptions &setTileSizes (SmallVector<Value, 4 > ts) {
350
- tileSizeComputationFunction = [=](OpBuilder &, Operation *) {
351
- return ts;
352
- };
350
+ tileSizeComputationFunction = [=](OpBuilder &, Operation *) { return ts; };
353
351
return *this ;
354
352
}
355
353
// / Convenience function to set the `tileSizeComputationFunction` to a
@@ -749,6 +747,56 @@ class ConvOpVectorization : public OpRewritePattern<ConvOp> {
749
747
PatternRewriter &rewriter) const override ;
750
748
};
751
749
750
+ // ===----------------------------------------------------------------------===//
751
+ // Patterns to convert a LinalgOp to std.call @external library implementation.
752
+ // ===----------------------------------------------------------------------===//
753
+ // Create a new call to the type-canonicalized `LinalgOp::getLibraryCallName()`
754
+ // function. The implementation of the function can be either in the same module
755
+ // or in an externally linked library.
756
+ // This is a generic entry point for all LinalgOp, except for CopyOp and
757
+ // IndexedGenericOp, for which omre specialized patterns are provided.
758
+ class LinalgOpToLibraryCallRewrite : public RewritePattern {
759
+ public:
760
+ LinalgOpToLibraryCallRewrite ()
761
+ : RewritePattern(/* benefit=*/ 1 , MatchAnyOpTypeTag()) {}
762
+
763
+ LogicalResult matchAndRewrite (Operation *op,
764
+ PatternRewriter &rewriter) const override ;
765
+ };
766
+
767
+ // / Rewrite pattern specialization for CopyOp, kicks in when both input and
768
+ // / output permutations are left unspecified or are the identity.
769
+ class CopyOpToLibraryCallRewrite : public OpRewritePattern <CopyOp> {
770
+ public:
771
+ using OpRewritePattern<CopyOp>::OpRewritePattern;
772
+ LogicalResult matchAndRewrite (CopyOp op,
773
+ PatternRewriter &rewriter) const override ;
774
+ };
775
+
776
+ // / Rewrite CopyOp with permutations into a sequence of TransposeOp and
777
+ // / permutation-free CopyOp. This interplays with TransposeOpConversion and
778
+ // / LinalgConversion<CopyOp> to create a path to the LLVM dialect.
779
+ class CopyTransposeRewrite : public OpRewritePattern <CopyOp> {
780
+ public:
781
+ using OpRewritePattern<CopyOp>::OpRewritePattern;
782
+ LogicalResult matchAndRewrite (CopyOp op,
783
+ PatternRewriter &rewriter) const override ;
784
+ };
785
+
786
+ // / Conversion pattern specialization for IndexedGenericOp, has special handling
787
+ // / for the extra index operands.
788
+ class IndexedGenericOpToLibraryCallRewrite
789
+ : public OpRewritePattern<IndexedGenericOp> {
790
+ public:
791
+ using OpRewritePattern<IndexedGenericOp>::OpRewritePattern;
792
+ LogicalResult matchAndRewrite (IndexedGenericOp op,
793
+ PatternRewriter &rewriter) const override ;
794
+ };
795
+
796
+ // / Populate the given list with patterns that convert from Linalg to Standard.
797
+ void populateLinalgToStandardConversionPatterns (
798
+ OwningRewritePatternList &patterns, MLIRContext *ctx);
799
+
752
800
// ===----------------------------------------------------------------------===//
753
801
// Support for staged pattern application.
754
802
// ===----------------------------------------------------------------------===//
0 commit comments