@@ -160,7 +160,7 @@ void prefetch(const std::string& id_name, const std::string& out_name,
160160 const std::vector<int64_t >& height_sections,
161161 const framework::ExecutionContext& context,
162162 const framework::Scope& scope) {
163- framework::Scope* local_scope = scope.NewTmpScope ();
163+ std::unique_ptr< framework::Scope> local_scope = scope.NewTmpScope ();
164164
165165 platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance ();
166166 auto & cpu_ctx = *pool.Get (platform::CPUPlace ());
@@ -206,7 +206,7 @@ void prefetch(const std::string& id_name, const std::string& out_name,
206206
207207 auto splited_ids = SplitIds (ids_vector, height_sections);
208208 SplitIdsIntoMultipleVarsBySection (in_var_names, height_sections, splited_ids,
209- local_scope);
209+ local_scope. get () );
210210
211211 // create output var in local scope
212212 for (auto & name : out_var_names) {
@@ -215,12 +215,12 @@ void prefetch(const std::string& id_name, const std::string& out_name,
215215
216216 std::vector<distributed::VarHandlePtr> rets;
217217 for (size_t i = 0 ; i < in_var_names.size (); i++) {
218- if (NeedSend (*local_scope, in_var_names[i])) {
218+ if (NeedSend (*local_scope. get () , in_var_names[i])) {
219219 VLOG (3 ) << " sending " << in_var_names[i] << " to " << epmap[i]
220220 << " to get " << out_var_names[i] << " back" ;
221221 rets.push_back (rpc_client->AsyncPrefetchVar (
222- epmap[i], cpu_ctx, *local_scope, in_var_names[i], out_var_names [i],
223- table_names[i]));
222+ epmap[i], cpu_ctx, *local_scope. get () , in_var_names[i],
223+ out_var_names[i], table_names[i]));
224224 } else {
225225 VLOG (3 ) << " don't send no-initialied variable: " << out_var_names[i];
226226 }
@@ -232,8 +232,7 @@ void prefetch(const std::string& id_name, const std::string& out_name,
232232
233233 MergeMultipleVarsIntoOneBySection (id_name, ids_vector, out_name,
234234 out_var_names, height_sections, splited_ids,
235- context, local_scope, &actual_ctx);
236- delete local_scope;
235+ context, local_scope.get (), &actual_ctx);
237236}
238237
239238}; // namespace distributed
0 commit comments