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

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


================
@@ -29,7 +29,25 @@ using namespace mlir::linalg;
 #define DEBUG_TYPE "linalg-fold-into-elementwise"
 
 namespace {
-struct FoldTransposePattern : public OpRewritePattern<ElementwiseOp> {
+template <typename ProducerOpTy>
+struct ElementwiseOpFolder {
+  static bool fold(OpOperand *operand, AffineMap consumerMap,
+                   SmallVector<Value> &newIns,
+                   SmallVector<AffineMap> &newMaps) {
+    auto producerOp = operand->get().getDefiningOp<ProducerOpTy>();
+    if (!producerOp || !consumerMap.isProjectedPermutation())
+      return false;
+    newIns.push_back(producerOp.getInput());
+    // push in composed affine map
----------------
javedabsar1 wrote:

// Push in the new composed affine map.

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


More information about the Mlir-commits mailing list