[Mlir-commits] [mlir] [mlir][linalg] Use ub.poison in data layout propagation if a packed operand requires padding. (PR #159467)
Han-Chung Wang
llvmlistbot at llvm.org
Fri Sep 19 14:17:55 PDT 2025
================
@@ -287,12 +288,24 @@ getOrCreatePackedViewOfOperand(OpBuilder &b, Location loc, PackInfo packInfo,
// The operand does not have dimensions that relates to pack op.
if (innerDimsPos.empty() && outerDimsPerm.empty())
return std::make_tuple(opOperand->get(), indexingMap);
-
+ auto inputType = cast<RankedTensorType>(opOperand->get().getType());
+ auto maybeIntInnerTileSizes = getConstantIntValues(innerTileSizes);
+ if (!maybeIntInnerTileSizes.has_value()) {
+ return failure();
+ }
+ if (!poisonPaddingOk &&
+ linalg::PackOp::requirePaddingValueStrict(
+ inputType.getShape(), innerDimsPos,
+ linalg::PackOp::inferPackedType(inputType, *maybeIntInnerTileSizes,
+ innerDimsPos, outerDimsPerm)
+ .getShape(),
+ outerDimsPerm, innerTileSizes))
+ return failure();
----------------
hanhanW wrote:
I think it is better to move the check outside `getOrCreatePackedViewOfOperand` function. Reason:
- We should not create operations if the pattern returns failure at the end.
- In this context, the order matters. You could create a pack op for the first operand, then get a failure from packing the second operand. We should not generate the pack op for the first operand in this case.
https://github.com/llvm/llvm-project/pull/159467
More information about the Mlir-commits
mailing list