[Mlir-commits] [mlir] [MLIR][Linalg] pack, unpack to take memref inputs (PR #129036)

Hyunsung Lee llvmlistbot at llvm.org
Fri Mar 28 21:04:27 PDT 2025


================
@@ -573,7 +573,7 @@ PackingMetadata computePackingMetadata(int64_t packedRank,
 /// Removes the op and replaces the constant with a new constant of the result
 /// shape. When an optional cst attribute is passed, it is reshaped only if the
 /// splat value matches the value in the attribute.
-OpFoldResult reshapeConstantSource(DenseElementsAttr source, TensorType result,
+OpFoldResult reshapeConstantSource(DenseElementsAttr source, ShapedType result,
----------------
ita9naiwa wrote:

Can we modify like this?
```
OpFoldResult PackOp::fold(FoldAdaptor adaptor) {
  if (!hasPureTensorSemantics())
    return {};

  std::optional<Attribute> paddingValue;
  if (auto pad = adaptor.getPaddingValue())
    paddingValue = pad;
  if (OpFoldResult reshapedSource = reshapeConstantSource(
          llvm::dyn_cast_if_present<DenseElementsAttr>(adaptor.getSource()),
          cast<TensorType>(getDestType()), paddingValue))
    return reshapedSource;
  return {};
}
```

Not sure if I understand your comment correctly.

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


More information about the Mlir-commits mailing list