|
|
|
@ -210,13 +210,14 @@ void TestInference(const std::string& dirname,
|
|
|
|
|
|
|
|
|
|
// Ignore the profiling results of the first run
|
|
|
|
|
std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx;
|
|
|
|
|
bool CreateLocalScope = CreateVars;
|
|
|
|
|
if (PrepareContext) {
|
|
|
|
|
ctx = executor.Prepare(*inference_program, 0);
|
|
|
|
|
executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
|
|
|
|
|
&fetch_targets, true, CreateVars);
|
|
|
|
|
&fetch_targets, CreateLocalScope, CreateVars);
|
|
|
|
|
} else {
|
|
|
|
|
executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
|
|
|
|
|
true, CreateVars);
|
|
|
|
|
CreateLocalScope, CreateVars);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enable the profiler
|
|
|
|
@ -232,10 +233,11 @@ void TestInference(const std::string& dirname,
|
|
|
|
|
// Note: if you change the inference_program, you need to call
|
|
|
|
|
// executor.Prepare() again to get a new ExecutorPrepareContext.
|
|
|
|
|
executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
|
|
|
|
|
&fetch_targets, CreateVars);
|
|
|
|
|
&fetch_targets, CreateLocalScope,
|
|
|
|
|
CreateVars);
|
|
|
|
|
} else {
|
|
|
|
|
executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
|
|
|
|
|
CreateVars);
|
|
|
|
|
CreateLocalScope, CreateVars);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|