[Mlir-commits] [mlir] [mlir][vector] Add patterns to simplify chained reductions (PR #73048)

Jakub Kuderski llvmlistbot at llvm.org
Tue Nov 21 18:43:19 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
+/// ```
----------------
kuhar wrote:

Good point, clarified

https://github.com/llvm/llvm-project/pull/73048


More information about the Mlir-commits mailing list