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

Mehdi Amini llvmlistbot at llvm.org
Thu Jun 26 02:16:18 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());
+      });
+    }
----------------
joker-eph wrote:

I don't have a suggestion for this, because this is a fundamental issue in MLIR that is hard to resolve. I tried to look into this a while back (see https://discourse.llvm.org/t/rfc-implicit-propagation-of-dialect-attributes-best-effort/2657 for example) but we never found a solution.

For now "discardable attributes" are meant to be discarded outside of your own transformation that will understand them and preserve them.

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


More information about the Mlir-commits mailing list