[Mlir-commits] [mlir] [mlir][vector] Add patterns to simplify chained reductions (PR #73048)
Lei Zhang
llvmlistbot at llvm.org
Tue Nov 21 15:51:56 PST 2023
================
@@ -147,6 +147,23 @@ void populateVectorTransferCollapseInnerMostContiguousDimsPatterns(
void populateSinkVectorBroadcastPatterns(RewritePatternSet &patterns,
PatternBenefit benefit = 1);
+/// Patterns that fold chained vector reductions. These patterns assume that
+/// vector addition (e.g., `arith.addf` with vector operands) is cheaper than
+/// vector reduction.
+///
+/// Example:
+/// ```
+/// %a = vector.reduction <add> %x, %acc
+/// %b = vector.reduction <add> %y, %a
+/// ```
+/// is transformed into:
+/// ```
+/// %a = arith.addf %x, %y
+/// %b = vector.reduction <add> %a, %acc
+/// ```
----------------
antiagainst wrote:
It might be worth calling out this can change the order of reduction so associtivity can be a concern.
https://github.com/llvm/llvm-project/pull/73048
More information about the Mlir-commits
mailing list