[Mlir-commits] [mlir] [mlir][linalg] Restrict linalg.pack to not have artificial padding. (PR #149624)
Han-Chung Wang
llvmlistbot at llvm.org
Tue Jul 22 10:26:32 PDT 2025
================
@@ -263,6 +309,24 @@ struct FoldUnpackWithExtractSliceOp
sliceOp, "expects offsets to be 0s and strides to be 1s");
}
+ // Folding is not allowed if any tile is dropped.
+ RankedTensorType unpackedType = sliceOp.getResultType();
+ SmallVector<int64_t> outerShapeWithoutTranspose =
+ getPackedOuterShapeWithoutTransposition(unpackOp);
+ for (auto [pos, tileSize] : llvm::zip_equal(
+ unpackOp.getInnerDimsPos(), unpackOp.getStaticInnerTiles())) {
+ if (unpackedType.isDynamicDim(pos))
+ return failure();
+ if (ShapedType::isDynamic(outerShapeWithoutTranspose[pos]))
+ return failure();
+ if (ShapedType::isDynamic(tileSize))
+ return failure();
+ int64_t paddingSize = outerShapeWithoutTranspose[pos] * tileSize -
+ unpackedType.getDimSize(pos);
+ if (paddingSize >= tileSize)
+ return failure();
+ }
----------------
hanhanW wrote:
I just found that they are quite different. One looks at the result of the unpack op and the other looks at the dest tensor of the unpack op. So my question becomes -- do we move the canonicalization pattern to here or we update the checks in the canonicalization pattern as well?
https://github.com/llvm/llvm-project/pull/149624
More information about the Mlir-commits
mailing list