Skip to content

Commit 7b63b85

Browse files
tensor-tangSuperjomn
authored andcommitted
fix mismatch of infer api (#12342)
1 parent 6133efd commit 7b63b85

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

paddle/fluid/inference/api/api_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ bool NativePaddlePredictor::Run(const std::vector<PaddleTensor> &inputs,
137137
executor_->RunPreparedContext(
138138
ctx_.get(), sub_scope_ != nullptr ? sub_scope_ : scope_.get(),
139139
&feed_targets, &fetch_targets,
140+
false, /* don't create local scope each time*/
140141
false /* don't create variable eatch time */);
141142
VLOG(4) << "Finish prepared context";
142143
if (!GetFetch(fetchs, output_data)) {

paddle/fluid/inference/tests/test_helper.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,14 @@ void TestInference(const std::string& dirname,
210210

211211
// Ignore the profiling results of the first run
212212
std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx;
213+
bool CreateLocalScope = CreateVars;
213214
if (PrepareContext) {
214215
ctx = executor.Prepare(*inference_program, 0);
215216
executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
216-
&fetch_targets, true, CreateVars);
217+
&fetch_targets, CreateLocalScope, CreateVars);
217218
} else {
218219
executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
219-
true, CreateVars);
220+
CreateLocalScope, CreateVars);
220221
}
221222

222223
// Enable the profiler
@@ -232,10 +233,11 @@ void TestInference(const std::string& dirname,
232233
// Note: if you change the inference_program, you need to call
233234
// executor.Prepare() again to get a new ExecutorPrepareContext.
234235
executor.RunPreparedContext(ctx.get(), scope, &feed_targets,
235-
&fetch_targets, CreateVars);
236+
&fetch_targets, CreateLocalScope,
237+
CreateVars);
236238
} else {
237239
executor.Run(*inference_program, scope, &feed_targets, &fetch_targets,
238-
CreateVars);
240+
CreateLocalScope, CreateVars);
239241
}
240242
}
241243

0 commit comments

Comments
 (0)