File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
paddle/fluid/inference/api Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 25
25
#include " paddle/fluid/inference/api/paddle_inference_api.h"
26
26
#include " paddle/fluid/inference/api/paddle_inference_pass.h"
27
27
#include " paddle/fluid/inference/utils/singleton.h"
28
+ #include " paddle/fluid/platform/cpu_helper.h"
28
29
#include " paddle/fluid/platform/profiler.h"
29
30
30
31
DECLARE_bool (profile);
32
+ DECLARE_int32 (paddle_num_threads);
31
33
32
34
namespace paddle {
33
35
@@ -47,6 +49,9 @@ bool AnalysisPredictor::Init(
47
49
}
48
50
#endif
49
51
52
+ // no matter with or without MKLDNN
53
+ paddle::platform::SetNumThreads (FLAGS_paddle_num_threads);
54
+
50
55
if (config_.use_gpu ) {
51
56
place_ = paddle::platform::CUDAPlace (config_.device );
52
57
LOG (WARNING) << " ir optimize only supports CPU currently, enable_ir_optim "
Original file line number Diff line number Diff line change @@ -23,9 +23,11 @@ limitations under the License. */
23
23
#include " paddle/fluid/framework/feed_fetch_method.h"
24
24
#include " paddle/fluid/inference/api/api_impl.h"
25
25
#include " paddle/fluid/inference/api/helper.h"
26
+ #include " paddle/fluid/platform/cpu_helper.h"
26
27
#include " paddle/fluid/platform/profiler.h"
27
28
28
29
DEFINE_bool (profile, false , " Turn on profiler for fluid" );
30
+ DECLARE_int32 (paddle_num_threads);
29
31
30
32
namespace paddle {
31
33
namespace {
@@ -72,6 +74,9 @@ bool NativePaddlePredictor::Init(
72
74
}
73
75
#endif
74
76
77
+ // no matter with or without MKLDNN
78
+ paddle::platform::SetNumThreads (FLAGS_paddle_num_threads);
79
+
75
80
if (config_.use_gpu ) {
76
81
place_ = paddle::platform::CUDAPlace (config_.device );
77
82
} else {
You can’t perform that action at this time.
0 commit comments