[Mlir-commits] [mlir] [mlir][linalg][elementwise] Fold broadcast into new elementwise (PR #167626)

Javed Absar llvmlistbot at llvm.org
Mon Jan 26 04:11:07 PST 2026


================
@@ -167,14 +167,15 @@ def LinalgInlineScalarOperandsPass : Pass<"linalg-inline-scalar-operands"> {
 }
 
 def LinalgFoldIntoElementwisePass : Pass<"linalg-fold-into-elementwise"> {
-  let summary = "Fold transpose ops into elementwise";
+  let summary = "Fold transpose and broadcast ops into elementwise";
   let dependentDialects = ["linalg::LinalgDialect"];
 
   let description = [{
-    Fold transpose ops that feed `linalg.elementwise` into the elementwise op
-    by updating its indexing maps. `linalg.transpose` producers whose consumer
-    indexing map is the identity are absorbed, turning the permutation into
-    the elementwise map itself. Other operands remain untouched.
+    Fold transpose and broadcast ops that feed `linalg.elementwise` into the
+    elementwise op by updating its indexing maps. `linalg.transpose` and
+    `linalg.broadcast` producers whose consumer indexing map is a projected
+    permutation are absorbed, composing the producer's map into the elementwise
+    op's indexing map. Other operands remain untouched.
----------------
javedabsar1 wrote:

Firstly thanks for extending the reach of fold by composing the map.
The above phrasing can be confusing. How about something like this?
Fold transpose or broadcast op that feeds a  `linalg.elementwise` into the
  elementwise op.  linalg.transpose` and `linalg.broadcast` producers whose
 consumer indexing map is a projected permutation can be absorbed into
 the indexing map of the `linalg.elementwise`  by composing the producer's
 map into the elementwise  op's indexing map.
 Other operands remain untouched.

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


More information about the Mlir-commits mailing list