[Mlir-commits] [mlir] [mlir][Tensor] Retain discardable attrs in pack(cast) folder (PR #115772)

Mehdi Amini llvmlistbot at llvm.org
Tue Nov 12 03:29:44 PST 2024


================
@@ -4798,6 +4798,7 @@ struct FoldTensorCastPackOp : public OpRewritePattern<PackOp> {
     PackOp newOp = rewriter.create<PackOp>(
         op.getLoc(), newOperands[0], newOperands[1], op.getInnerDimsPos(),
         newMixedTileSizes, op.getPaddingValue(), op.getOuterDimsPerm());
+    newOp->setDiscardableAttrs(op->getDiscardableAttrDictionary());
----------------
joker-eph wrote:

> I dont know if it can be inplace. The result type is changing I think.

That's not a problem: result types can be changed in place. The `operand_segment_sizes` that @qedawkins mentioned is however more tricky to manipulate: I don't know what kind of helpers we have to mutate operand groups?

> But in cases like this when the op is being replaced by an op of the same type, its also safe to carry it over.

I don't quite follow why the op being the same type is enough. Since @qedawkins mentioned the `operand_segment_size`, the trivial example is an attribute that refers to a particular operand, for example `my.important_info = #some.property<operand #2, ....>`.
After resizing the operand groups, this annotation would refer to the wrong operand.

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


More information about the Mlir-commits mailing list