[Mlir-commits] [mlir] [mlir][tensor] Fold pack and unpack of empty input tensor (PR #92247)

Matthias Springer llvmlistbot at llvm.org
Wed May 15 05:03:32 PDT 2024


================
@@ -4200,6 +4200,12 @@ LogicalResult PackOp::canonicalize(PackOp packOp, PatternRewriter &rewriter) {
     return success();
   }
 
+  // Fold away packing an empty source tensor.
+  if (auto emptyTensor = packOp.getSource().getDefiningOp<tensor::EmptyOp>()) {
+    rewriter.replaceOp(packOp, packOp.getDest());
----------------
matthias-springer wrote:

I think this could be done in the folder.

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


More information about the Mlir-commits mailing list