Skip to content

Commit 42c38b1

Browse files
authored
[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.
1 parent 2e6b18b commit 42c38b1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,12 @@ struct GenericOpScheduler : public OpRewritePattern<linalg::GenericOp> {
573573
rewriter.modifyOpInPlace(linalgOp, [&]() {
574574
linalgOp->setOperand(t->getOperandNumber(), dst);
575575
});
576+
577+
// Release the transposed form afterwards.
578+
// TODO: CSE when used in more than one following op?
579+
rewriter.setInsertionPointAfter(linalgOp);
580+
rewriter.create<bufferization::DeallocTensorOp>(dst.getLoc(), dst);
581+
576582
return success();
577583
}
578584
// Cannot be resolved with a single conversion.

0 commit comments

Comments
 (0)