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

Han-Chung Wang llvmlistbot at llvm.org
Thu Apr 3 11:26:19 PDT 2025


================
@@ -355,11 +359,19 @@ FailureOr<LowerPackResult> linalg::lowerPack(RewriterBase &rewriter,
 FailureOr<LowerUnPackOpResult>
 linalg::lowerUnPack(RewriterBase &rewriter, linalg::UnPackOp unPackOp,
                     bool lowerUnpadLikeWithExtractSlice) {
+  // TODO: Support Memref PackOp. Temporarily return failure.
+  if (!unPackOp.hasPureTensorSemantics()) {
+    return failure();
+  }
+
   Location loc = unPackOp->getLoc();
   OpBuilder::InsertionGuard g(rewriter);
   rewriter.setInsertionPoint(unPackOp);
 
-  RankedTensorType packedTensorType = unPackOp.getSourceType();
+  auto packedTensorType = dyn_cast<RankedTensorType>(unPackOp.getSourceType());
+  if (!packedTensorType)
+    return failure();
+
----------------
hanhanW wrote:

We can use `cast` like the other `lowerPack` function. You already check that it has pure tensor semantic, so this is a redundant check to me, given the op semantic.

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


More information about the Mlir-commits mailing list