[Mlir-commits] [mlir] [mlir][linalg] Take artificial padding into account for pack/unpack folding. (PR #150272)

Andrzej WarzyƄski llvmlistbot at llvm.org
Thu Jul 24 05:15:28 PDT 2025


================
@@ -5494,6 +5513,32 @@ LogicalResult UnPackOp::canonicalize(UnPackOp unPackOp,
   return failure();
 }
 
+bool UnPackOp::canFoldSliceOp(tensor::ExtractSliceOp sliceOp) {
+  // Rank-reduced folding is not supported.
+  if (sliceOp.getResultType().getRank() != this->getDestType().getRank())
+    return false;
+  if (!areAllConstantIntValue(sliceOp.getMixedOffsets(), 0) ||
+      !areAllConstantIntValue(sliceOp.getMixedStrides(), 1))
+    return false;
+  RankedTensorType unpackedType = sliceOp.getResultType();
----------------
banach-space wrote:

[nit] It would be good to differentiate between "unpacked" and "unpacked after folding".
```suggestion
  RankedTensorType unpackedTypeAfterFold = sliceOp.getResultType();
```

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


More information about the Mlir-commits mailing list