[Mlir-commits] [mlir] [mlir][Tensor] Retain discardable attrs back in cast(pack) folder (PR #115772)
Quinn Dawkins
llvmlistbot at llvm.org
Mon Nov 11 14:14:09 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());
----------------
qedawkins wrote:
I'm not sure how easy it would be to make it operate in place because it is potentially updating a list of mixed operands (`newMixedTileSizes`) meaning operand segment lengths need to be updated as well and I've had a bad experience trying to do that in the past.
> Why is this sounds? How do you guarantee that the pattern can't invalidate anything encoded in there?
There is no guarantee this is sound in the same way any pattern that operates on generic tensor encodings isn't sound. As I see it there are hardly any "globally sound" decisions we can make about arbitrary unstructured attributes so instead it seems as though people have been going for a practical middle ground. This is also consistent with every other cast folder I've seen (not saying there aren't counter examples).
https://github.com/llvm/llvm-project/pull/115772
More information about the Mlir-commits
mailing list