未验证 提交 7618cbdc 编写于 作者: W WangZhen 提交者: GitHub

[Dy2St]Fix abnormal growth of memory in train mode and no_grad for Dy2St (#47398) (#47414)

* [Dy2St]Fix abnormal growth of memory in train mode and no_grad for Dy2St 
上级 c42929c5
...@@ -394,7 +394,7 @@ inline void RunProgramAPI( ...@@ -394,7 +394,7 @@ inline void RunProgramAPI(
} }
VLOG(3) << paddle::framework::GenScopeTreeDebugInfo(out_scope_vec->front()); VLOG(3) << paddle::framework::GenScopeTreeDebugInfo(out_scope_vec->front());
if (is_test) { if (is_test || !egr::Controller::Instance().HasGrad()) {
VLOG(4) << "is test, set this scope can reused"; VLOG(4) << "is test, set this scope can reused";
global_inner_scope->SetCanReuesd(true); global_inner_scope->SetCanReuesd(true);
details::GcScope(global_inner_scope); details::GcScope(global_inner_scope);
...@@ -470,7 +470,7 @@ inline void RunProgramAPI( ...@@ -470,7 +470,7 @@ inline void RunProgramAPI(
// Debug info: scope info when run end // Debug info: scope info when run end
VLOG(3) << paddle::framework::GenScopeTreeDebugInfo(out_scope_vec->front()); VLOG(3) << paddle::framework::GenScopeTreeDebugInfo(out_scope_vec->front());
// Step 5. Drop all children scopes while testing. // Step 5. Drop all children scopes while testing.
if (is_test) { if (is_test || !egr::Controller::Instance().HasGrad()) {
out_scope_vec->front()->DropKids(); out_scope_vec->front()->DropKids();
} }
VLOG(2) << "The number of sub scopes after forward: " VLOG(2) << "The number of sub scopes after forward: "
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册