Skip to content

Commit 116979a

Browse files
committed
refine api name
test=develop
1 parent e66b4c6 commit 116979a

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

paddle/fluid/inference/api/analysis_config.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ contrib::AnalysisConfig::AnalysisConfig(const contrib::AnalysisConfig &other) {
4646
prog_file = other.prog_file;
4747
param_file = other.param_file;
4848
specify_input_name = other.specify_input_name;
49-
cpu_num_threads_ = other.cpu_num_threads_;
49+
cpu_math_library_num_threads_ = other.cpu_math_library_num_threads_;
5050
// fields from this.
5151
enable_ir_optim = other.enable_ir_optim;
5252
use_feed_fetch_ops = other.use_feed_fetch_ops;
@@ -73,6 +73,7 @@ contrib::AnalysisConfig::AnalysisConfig(contrib::AnalysisConfig &&other) {
7373
prog_file = other.prog_file;
7474
param_file = other.param_file;
7575
specify_input_name = other.specify_input_name;
76+
cpu_math_library_num_threads_ = other.cpu_math_library_num_threads_;
7677
// fields from this.
7778
enable_ir_optim = other.enable_ir_optim;
7879
use_feed_fetch_ops = other.use_feed_fetch_ops;

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ bool AnalysisPredictor::Init(
6666
#endif
6767

6868
// no matter with or without MKLDNN
69-
paddle::platform::SetNumThreads(config_.GetCPUNumThreads());
69+
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
7070

7171
if (!PrepareScope(parent_scope)) {
7272
return false;
@@ -159,7 +159,7 @@ bool AnalysisPredictor::PrepareExecutor() {
159159
return true;
160160
}
161161

162-
void AnalysisPredictor::SetMKLDNNThreadId(int tid) {
162+
void AnalysisPredictor::SetMkldnnThreadID(int tid) {
163163
#ifdef PADDLE_WITH_MKLDNN
164164
platform::set_cur_thread_id(tid);
165165
#else

paddle/fluid/inference/api/analysis_predictor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AnalysisPredictor : public PaddlePredictor {
6969
framework::Scope *scope() { return scope_.get(); }
7070
framework::ProgramDesc &program() { return *inference_program_; }
7171

72-
void SetMKLDNNThreadId(int tid);
72+
void SetMkldnnThreadID(int tid);
7373

7474
protected:
7575
bool PrepareProgram(const std::shared_ptr<framework::ProgramDesc> &program);

paddle/fluid/inference/api/api_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool NativePaddlePredictor::Init(
7575
#endif
7676

7777
// no matter with or without MKLDNN
78-
paddle::platform::SetNumThreads(config_.GetCPUNumThreads());
78+
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
7979

8080
if (config_.use_gpu) {
8181
place_ = paddle::platform::CUDAPlace(config_.device);

paddle/fluid/inference/api/paddle_api.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,18 @@ struct NativeConfig : public PaddlePredictor::Config {
187187
// `feeds` and `fetches` of the phase `save_inference_model`.
188188
bool specify_input_name{false};
189189

190-
// Set and get the number of cpu threads.
191-
void SetCPUNumThreads(int cpu_num_threads) {
192-
cpu_num_threads_ = cpu_num_threads;
190+
// Set and get the number of cpu math library threads.
191+
void SetCpuMathLibraryNumThreads(int cpu_math_library_num_threads) {
192+
cpu_math_library_num_threads_ = cpu_math_library_num_threads;
193+
}
194+
int cpu_math_library_num_threads() const {
195+
return cpu_math_library_num_threads_;
193196
}
194-
int GetCPUNumThreads() const { return cpu_num_threads_; }
195197

196198
protected:
197-
int cpu_num_threads_{1}; // number of cpu threads for each instance.
199+
// number of cpu math library (such as MKL, OpenBlas) threads for each
200+
// instance.
201+
int cpu_math_library_num_threads_{1};
198202
};
199203

200204
// A factory to help create different predictors.

paddle/fluid/inference/tests/api/analyzer_resnet50_tester.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void SetConfig(AnalysisConfig *cfg) {
2727
cfg->device = 0;
2828
cfg->enable_ir_optim = true;
2929
cfg->specify_input_name = true;
30-
cfg->SetCPUNumThreads(FLAGS_paddle_num_threads);
30+
cfg->SetCpuMathLibraryNumThreads(FLAGS_paddle_num_threads);
3131
}
3232

3333
void SetInput(std::vector<std::vector<PaddleTensor>> *inputs) {

paddle/fluid/inference/tests/api/config_printer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ std::ostream &operator<<(std::ostream &os, const NativeConfig &config) {
5454
os << GenSpaces(num_spaces)
5555
<< "specify_input_name: " << config.specify_input_name << "\n";
5656
os << GenSpaces(num_spaces)
57-
<< "cpu_num_threads: " << config.GetCPUNumThreads() << "\n";
57+
<< "cpu_num_threads: " << config.cpu_math_library_num_threads() << "\n";
5858
num_spaces--;
5959
os << GenSpaces(num_spaces) << "}\n";
6060
return os;

paddle/fluid/inference/tests/api/tester_helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void TestMultiThreadPrediction(
221221
#ifdef PADDLE_WITH_MKLDNN
222222
if (use_analysis) {
223223
static_cast<AnalysisPredictor *>(predictor.get())
224-
->SetMKLDNNThreadId(static_cast<int>(tid) + 1);
224+
->SetMkldnnThreadID(static_cast<int>(tid) + 1);
225225
}
226226
#endif
227227

0 commit comments

Comments
 (0)