File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class ParallelExecutorPrivate {
44
44
#endif
45
45
46
46
std::vector<std::tuple<std::string, proto::VarType::Type, bool >> var_types_;
47
+ bool own_local_scope;
47
48
};
48
49
49
50
std::vector<Scope *> &ParallelExecutor::GetLocalScopes () {
@@ -63,11 +64,13 @@ ParallelExecutor::ParallelExecutor(
63
64
// Step 1. Bcast the params to devs.
64
65
// Create local scopes
65
66
if (local_scopes.empty ()) {
67
+ member_->own_local_scope = true ;
66
68
member_->local_scopes_ .emplace_back (member_->global_scope_ );
67
69
for (size_t i = 1 ; i < member_->places_ .size (); ++i) {
68
70
member_->local_scopes_ .emplace_back (&scope->NewScope ());
69
71
}
70
72
} else {
73
+ member_->own_local_scope = false ;
71
74
PADDLE_ENFORCE_EQ (member_->places_ .size (), local_scopes.size ());
72
75
for (size_t i = 0 ; i < member_->places_ .size (); ++i) {
73
76
member_->local_scopes_ .emplace_back (local_scopes[i]);
@@ -231,5 +234,13 @@ void ParallelExecutor::FeedAndSplitTensorIntoLocalScopes(
231
234
}
232
235
}
233
236
237
+ ParallelExecutor::~ParallelExecutor () {
238
+ if (member_->own_local_scope ) {
239
+ for (size_t i = 1 ; i < member_->local_scopes_ .size (); ++i) {
240
+ member_->global_scope_ ->DeleteScope (member_->local_scopes_ [i]);
241
+ }
242
+ }
243
+ }
244
+
234
245
} // namespace framework
235
246
} // namespace paddle
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class ParallelExecutor {
42
42
const std::vector<Scope*>& local_scopes,
43
43
bool allow_op_delay);
44
44
45
+ ~ParallelExecutor ();
46
+
45
47
std::vector<Scope*>& GetLocalScopes ();
46
48
47
49
/* *
You can’t perform that action at this time.
0 commit comments