[Mlir-commits] [mlir] [mlir][Canonicalize] Copy ParallelOp Attributes in Single-iteration (PR #145852)
Michael Marjieh
llvmlistbot at llvm.org
Tue Jul 1 06:46:31 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());
+ });
+ }
----------------
mmarjieh wrote:
@joker-eph @Hardcode84 @matthias-springer @MaheshRavishankar
Thanks everyone that replied. Bottom line, I can't rely on attributes to transfer data between different passes since every target has their own attributes and we can't simply propagate them without understanding if the semantics stays the same after the transformation,
I also went for a solution that doesn't rely on attributes.
https://github.com/llvm/llvm-project/pull/145852
More information about the Mlir-commits
mailing list