[Mlir-commits] [mlir] [mlir][linalg] Restrict linalg.pack to not have artificial padding. (PR #149624)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jul 22 07:38:01 PDT 2025
================
@@ -220,6 +243,29 @@ struct FoldPadWithPackOp : public OpRewritePattern<PackOp> {
if (!isEqualConstantIntOrValue(paddingValue, constantPaddingValue))
return failure();
+ // Folding is not allowed if it introduces artificial padding.
+ RankedTensorType unpackedType = packOp.getSourceType();
+ SmallVector<int64_t> outerShapeWithoutTranspose =
+ getPackedOuterShapeWithoutTransposition(packOp);
+ for (auto [pos, tileSize, high] :
+ llvm::zip_equal(packOp.getInnerDimsPos(), packOp.getStaticInnerTiles(),
+ padOp.getMixedHighPad())) {
+ if (unpackedType.isDynamicDim(pos))
+ return failure();
+ if (ShapedType::isDynamic(outerShapeWithoutTranspose[pos]))
+ return failure();
+ if (ShapedType::isDynamic(tileSize))
----------------
Max191 wrote:
I think it could be legal to have a dynamic inner_tile size here. For example:
```
%pack = linalg.pack ... inner_tiles = [%tile] : tensor<7xf32> into tensor<2x?xf32>
```
`%tile` can still be dynamically anything in `[4, 7)`.
https://github.com/llvm/llvm-project/pull/149624
More information about the Mlir-commits
mailing list