[Mlir-commits] [mlir] [mlir][Canonicalize] Copy ParallelOp Attributes in Single-iteration (PR #145852)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jun 26 13:30:36 PDT 2025


================
@@ -3133,6 +3133,16 @@ struct ParallelOpSingleOrZeroIterationDimsFolder
                                     newSteps, op.getInitVals(), nullptr);
     // Erase the empty block that was inserted by the builder.
     rewriter.eraseBlock(newOp.getBody());
+
+    // The new ParallelOp needs to keep all attributes from the old one, except
+    // for "operandSegmentSizes" which will be outdated.
+    for (const auto &namedAttr : op->getAttrs()) {
+      if (namedAttr.getName() == ParallelOp::getOperandSegmentSizeAttr())
+        continue;
+      rewriter.modifyOpInPlace(newOp, [&]() {
+        newOp->setAttr(namedAttr.getName(), namedAttr.getValue());
+      });
+    }
----------------
MaheshRavishankar wrote:

@mmarjieh  you will not get a resolution of this upstream. It will pull you into a discussion hole. Downstream in IREE we ended up using a listener based approach that adds back attributes that get dropped due to upstream https://github.com/iree-org/iree/blob/57d61720368c1f23bab13463cb52d0d785dd82f0/compiler/src/iree/compiler/Codegen/Common/ConfigTrackingCanonicalizer.cpp#L92 . Thats the best way forward for you 

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


More information about the Mlir-commits mailing list