[Mlir-commits] [mlir] 42c38b1 - [mlir][sparse] deallocate temporary transposed tensor (#85720)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Mar 18 17:10:26 PDT 2024


Author: Aart Bik
Date: 2024-03-18T17:10:23-07:00
New Revision: 42c38b1cc5c1b216f4bd18c39b82fcd64ca20b90

URL: https://github.com/llvm/llvm-project/commit/42c38b1cc5c1b216f4bd18c39b82fcd64ca20b90
DIFF: https://github.com/llvm/llvm-project/commit/42c38b1cc5c1b216f4bd18c39b82fcd64ca20b90.diff

LOG: [mlir][sparse] deallocate temporary transposed tensor (#85720)

Last resort resolution of cycles introduced a sparse conversion without
explicit sparse deallocation (which is not inserted by any automatic
means). This fixes 2 out of 5 remaining asan detected leaks in sparse
integration tests.

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp
index f93b59de29e57b..14ea07f0b54b82 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp
@@ -573,6 +573,12 @@ struct GenericOpScheduler : public OpRewritePattern<linalg::GenericOp> {
       rewriter.modifyOpInPlace(linalgOp, [&]() {
         linalgOp->setOperand(t->getOperandNumber(), dst);
       });
+
+      // Release the transposed form afterwards.
+      // TODO: CSE when used in more than one following op?
+      rewriter.setInsertionPointAfter(linalgOp);
+      rewriter.create<bufferization::DeallocTensorOp>(dst.getLoc(), dst);
+
       return success();
     }
     // Cannot be resolved with a single conversion.


        


More information about the Mlir-commits mailing list