Skip to content

Commit 3659401

Browse files
committed
make infer init explicit
1 parent 211b707 commit 3659401

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

paddle/contrib/inference/paddle_inference_api_impl.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,18 @@ std::string num2str(T a) {
5454
}
5555
} // namespace
5656

57-
bool NativePaddlePredictor::Init(std::shared_ptr<framework::Scope> scope) {
57+
bool NativePaddlePredictor::Init(
58+
std::shared_ptr<framework::Scope> parent_scope) {
5859
VLOG(3) << "Predictor::init()";
5960

6061
if (config_.use_gpu) {
6162
place_ = paddle::platform::CUDAPlace(config_.device);
6263
} else {
6364
place_ = paddle::platform::CPUPlace();
6465
}
65-
if (scope) {
66-
scope_ = scope;
67-
sub_scope_ = &(scope->NewScope());
66+
if (parent_scope) {
67+
scope_ = parent_scope;
68+
sub_scope_ = &(parent_scope->NewScope());
6869
} else {
6970
paddle::framework::InitDevices(false);
7071
scope_.reset(new paddle::framework::Scope());
@@ -275,7 +276,7 @@ CreatePaddlePredictor<NativeConfig, PaddleEngineKind::kNative>(
275276
}
276277

277278
std::unique_ptr<PaddlePredictor> predictor(new NativePaddlePredictor(config));
278-
if (!dynamic_cast<NativePaddlePredictor *>(predictor.get())->Init()) {
279+
if (!dynamic_cast<NativePaddlePredictor *>(predictor.get())->Init(nullptr)) {
279280
return nullptr;
280281
}
281282
return std::move(predictor);

paddle/contrib/inference/paddle_inference_api_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class NativePaddlePredictor : public PaddlePredictor {
3535
: config_(config) {}
3636

3737
// will only create sub scope if have global scope
38-
bool Init(std::shared_ptr<framework::Scope> scope = nullptr);
38+
bool Init(std::shared_ptr<framework::Scope> parent_scope);
3939

4040
bool Run(const std::vector<PaddleTensor> &inputs,
4141
std::vector<PaddleTensor> *output_data) override;

0 commit comments

Comments
 (0)