未验证 提交 f74237cd 编写于 作者: K kangguangli 提交者: GitHub

fix: newExe didnot gc transferred variable (#53545)

上级 b6c0407e
......@@ -844,6 +844,22 @@ void BuildOpFuncList(const platform::Place& place,
interpreter::LogDeviceMemoryStats(place);
}
}
// in the unused_var_map, we did not record the variable who are created in
// ApplyDataTransform. So we erase these variables here.
std::deque<std::shared_ptr<memory::Allocation>>* garbages =
new std::deque<std::shared_ptr<memory::Allocation>>();
for (const auto& transferred_var : var_scope->DataTransferAddedVars()) {
const auto& var_name = transferred_var.first;
auto* var = local_scope->FindVar(var_name);
if (var == nullptr) continue;
VLOG(6) << "Erase variable " << var_name;
if (var->IsType<phi::DenseTensor>()) {
garbages->emplace_back(
var->GetMutable<phi::DenseTensor>()->MoveMemoryHolder());
}
}
delete garbages;
}
void BuildVariableScope(const framework::BlockDesc& block,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册