[Mlir-commits] [mlir] 2848f69 - [mlir] Set top-down traversal for LinalgElementwiseOpFusion
Tres Popp
llvmlistbot at llvm.org
Mon Aug 16 00:27:03 PDT 2021
Author: Tres Popp
Date: 2021-08-16T09:26:49+02:00
New Revision: 2848f6966ea35a1e8bdf1668ee4ae8fb0170235c
URL: https://github.com/llvm/llvm-project/commit/2848f6966ea35a1e8bdf1668ee4ae8fb0170235c
DIFF: https://github.com/llvm/llvm-project/commit/2848f6966ea35a1e8bdf1668ee4ae8fb0170235c.diff
LOG: [mlir] Set top-down traversal for LinalgElementwiseOpFusion
The primary pattern for this pass clones many operations from producers
to consumers. Doing this top down prevents duplicated work when a
producer has multiple consumers, if it also is consuming another
linalg.generic.
As an example, a chain of ~2600 generics that are fused into ~70
generics was resulting in 16255 pattern invocations. This took 14
seconds on one machine but takes only 0.3 seconds with top-down
traversal.
Differential Revision: https://reviews.llvm.org/D107818
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
index fdca523b38544..43a4105e4c3f8 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
@@ -1294,7 +1294,12 @@ struct LinalgElementwiseOpFusionPass
patterns,
LinalgElementwiseFusionOptions().setControlFoldingReshapes(
allowFoldingUnitDimReshapes ? allowFoldingFn : skipUnitDimReshape));
- (void)applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns));
+
+ // Use TopDownTraversal for compile time reasons
+ GreedyRewriteConfig grc;
+ grc.useTopDownTraversal = true;
+ (void)applyPatternsAndFoldGreedily(op->getRegions(), std::move(patterns),
+ grc);
}
};
More information about the Mlir-commits
mailing list