Skip to content

Commit e3febd9

Browse files
committed
fix(kernel): 没有引用的输出张量也要分配,但计算完后立即释放
Signed-off-by: YdrMaster <ydrml@hotmail.com>
1 parent d076c20 commit e3febd9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/04kernel/src/allocators/reusable_allocator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace refactor::kernel {
2323
std::vector<runtime::Edge> edges_(edges.size(), {nullptr, SIZE_MAX});
2424
for (auto [nodeIdx, inputs, outputs] : topology) {
2525
for (auto outputIdx : outputs) {
26-
if (!edgeRc[outputIdx]) { continue; }
2726
if (globalOutputs.contains(outputIdx)) {
2827
edges_[outputIdx].stackOffset--;
2928
} else {
@@ -34,6 +33,11 @@ namespace refactor::kernel {
3433
auto wsSize = node.workspaceOffset;
3534
calculator.free(node.workspaceOffset = calculator.alloc(wsSize), wsSize);
3635
}
36+
for (auto outputIdx : outputs) {
37+
if (!edgeRc[outputIdx]) {
38+
calculator.free(edges_[outputIdx].stackOffset, edges[outputIdx].size);
39+
}
40+
}
3741
for (auto inputIdx : inputs) {
3842
ASSERT(edgeRc[inputIdx], "double free");
3943
if (!--edgeRc[inputIdx]) {

0 commit comments

Comments
 (0)