[Mlir-commits] [mlir] 8d78507 - [mlir][linalg] Add returning rewrite method to fusion pattern (NFC).
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Mar 8 07:53:34 PST 2022
Author: gysit
Date: 2022-03-08T15:50:28Z
New Revision: 8d7850705c2941e7567dc6eedaba30dfa882ee88
URL: https://github.com/llvm/llvm-project/commit/8d7850705c2941e7567dc6eedaba30dfa882ee88
DIFF: https://github.com/llvm/llvm-project/commit/8d7850705c2941e7567dc6eedaba30dfa882ee88.diff
LOG: [mlir][linalg] Add returning rewrite method to fusion pattern (NFC).
Enhance `LinalgTileAndFuseTensorOpsPattern` with an additional rewrite signature that returns the result of the rewrite.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D121212
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index d4cd9a550b3a9..8059ec1320968 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -865,8 +865,16 @@ struct LinalgTileAndFuseTensorOpsPattern : public RewritePattern {
LinalgTilingAndFusionOptions options,
LinalgTransformationFilter f = LinalgTransformationFilter(),
PatternBenefit benefit = 1);
+
+ /// `matchAndRewrite` implementation that returns the significant transformed
+ /// pieces of IR.
+ FailureOr<TileLoopNest>
+ returningMatchAndRewrite(Operation *op, PatternRewriter &rewriter) const;
+
LogicalResult matchAndRewrite(Operation *op,
- PatternRewriter &rewriter) const override;
+ PatternRewriter &rewriter) const override {
+ return returningMatchAndRewrite(op, rewriter);
+ }
private:
/// LinalgTransformMarker handles special attribute manipulations.
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index f6a5304e1cff9..c031c0f57b988 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -549,7 +549,8 @@ mlir::linalg::LinalgTileAndFuseTensorOpsPattern::
: RewritePattern(opName, benefit, context), filter(std::move(f)),
options(std::move(options)) {}
-LogicalResult mlir::linalg::LinalgTileAndFuseTensorOpsPattern::matchAndRewrite(
+FailureOr<mlir::linalg::TileLoopNest>
+mlir::linalg::LinalgTileAndFuseTensorOpsPattern::returningMatchAndRewrite(
Operation *op, PatternRewriter &rewriter) const {
LinalgOp rootOp = dyn_cast<LinalgOp>(op);
if (!rootOp)
@@ -604,7 +605,7 @@ LogicalResult mlir::linalg::LinalgTileAndFuseTensorOpsPattern::matchAndRewrite(
// Apply the filter if specified.
for (LinalgOp linalgOp : tileLoopNest->getAllTiledAndFusedOps())
filter.replaceLinalgTransformationFilter(rewriter, linalgOp);
- return success();
+ return tileLoopNest;
}
/// Linalg generic interchange pattern.
More information about the Mlir-commits
mailing list