@@ -210,13 +210,14 @@ void TestInference(const std::string& dirname,
210
210
211
211
// Ignore the profiling results of the first run
212
212
std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx;
213
+ bool CreateLocalScope = CreateVars;
213
214
if (PrepareContext) {
214
215
ctx = executor.Prepare (*inference_program, 0 );
215
216
executor.RunPreparedContext (ctx.get (), scope, &feed_targets,
216
- &fetch_targets, true , CreateVars);
217
+ &fetch_targets, CreateLocalScope , CreateVars);
217
218
} else {
218
219
executor.Run (*inference_program, scope, &feed_targets, &fetch_targets,
219
- true , CreateVars);
220
+ CreateLocalScope , CreateVars);
220
221
}
221
222
222
223
// Enable the profiler
@@ -232,10 +233,11 @@ void TestInference(const std::string& dirname,
232
233
// Note: if you change the inference_program, you need to call
233
234
// executor.Prepare() again to get a new ExecutorPrepareContext.
234
235
executor.RunPreparedContext (ctx.get (), scope, &feed_targets,
235
- &fetch_targets, CreateVars);
236
+ &fetch_targets, CreateLocalScope,
237
+ CreateVars);
236
238
} else {
237
239
executor.Run (*inference_program, scope, &feed_targets, &fetch_targets,
238
- CreateVars);
240
+ CreateLocalScope, CreateVars);
239
241
}
240
242
}
241
243
0 commit comments