提交 54636a19 编写于 作者: L Leo Zhao 提交者: Tao Luo

call SetNumThreads everytime to avoid missing omp thread setting (#17224)

* call SetNumThreads everytime to avoid missing omp thread setting

resolve #17153
test=develop

* add paddle_num_threads into config for test_analyzer_pyramid_dnn

resolve #17153
test=develop
上级 6b0f27e8
......@@ -192,9 +192,7 @@ void AnalysisPredictor::SetMkldnnThreadID(int tid) {
bool AnalysisPredictor::Run(const std::vector<PaddleTensor> &inputs,
std::vector<PaddleTensor> *output_data,
int batch_size) {
if (UNLIKELY(config_.cpu_math_library_num_threads() > 1)) {
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
}
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
VLOG(3) << "Predictor::predict";
inference::Timer timer;
timer.tic();
......@@ -569,6 +567,7 @@ std::unique_ptr<ZeroCopyTensor> AnalysisPredictor::GetOutputTensor(
}
bool AnalysisPredictor::ZeroCopyRun() {
paddle::platform::SetNumThreads(config_.cpu_math_library_num_threads());
executor_->Run();
// Fix TensorArray reuse not cleaned bug.
tensor_array_batch_cleaner_.CollectTensorArrays(sub_scope_);
......
......@@ -107,6 +107,7 @@ void SetConfig(AnalysisConfig *cfg) {
cfg->DisableGpu();
cfg->SwitchSpecifyInputNames();
cfg->SwitchIrOptim();
cfg->SetCpuMathLibraryNumThreads(FLAGS_paddle_num_threads);
if (FLAGS_zero_copy) {
cfg->SwitchUseFeedFetchOps(false);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册