Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
81337368
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
81337368
编写于
7月 05, 2018
作者:
T
tensor-tang
提交者:
GitHub
7月 05, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11762 from tensor-tang/refine/set_num_threads
move SetNumThreads to platform
上级
4ed0b624
2e418a52
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
100 addition
and
19 deletion
+100
-19
paddle/fluid/inference/io.cc
paddle/fluid/inference/io.cc
+2
-2
paddle/fluid/inference/tests/book/test_inference_nlp.cc
paddle/fluid/inference/tests/book/test_inference_nlp.cc
+2
-2
paddle/fluid/operators/math/blas.h
paddle/fluid/operators/math/blas.h
+0
-12
paddle/fluid/platform/CMakeLists.txt
paddle/fluid/platform/CMakeLists.txt
+4
-1
paddle/fluid/platform/cpu_helper.cc
paddle/fluid/platform/cpu_helper.cc
+42
-0
paddle/fluid/platform/cpu_helper.h
paddle/fluid/platform/cpu_helper.h
+26
-0
paddle/fluid/platform/cpu_helper_test.cc
paddle/fluid/platform/cpu_helper_test.cc
+22
-0
paddle/fluid/platform/init.cc
paddle/fluid/platform/init.cc
+2
-2
未找到文件。
paddle/fluid/inference/io.cc
浏览文件 @
81337368
...
@@ -20,7 +20,7 @@ limitations under the License. */
...
@@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/block_desc.h"
#include "paddle/fluid/framework/block_desc.h"
#include "paddle/fluid/framework/feed_fetch_type.h"
#include "paddle/fluid/framework/feed_fetch_type.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/
operators/math/blas
.h"
#include "paddle/fluid/
platform/cpu_helper
.h"
#include "paddle/fluid/pybind/pybind.h"
#include "paddle/fluid/pybind/pybind.h"
DEFINE_string
(
devices
,
""
,
"The devices to be used which is joined by comma."
);
DEFINE_string
(
devices
,
""
,
"The devices to be used which is joined by comma."
);
...
@@ -33,7 +33,7 @@ namespace inference {
...
@@ -33,7 +33,7 @@ namespace inference {
void
Init
(
const
std
::
vector
<
std
::
string
>
argv
)
{
void
Init
(
const
std
::
vector
<
std
::
string
>
argv
)
{
framework
::
InitGflags
(
argv
);
framework
::
InitGflags
(
argv
);
operators
::
math
::
SetNumThreads
(
FLAGS_math_num_threads
);
platform
::
SetNumThreads
(
FLAGS_math_num_threads
);
// init devices
// init devices
std
::
vector
<
int
>
devices
;
std
::
vector
<
int
>
devices
;
std
::
string
token
;
std
::
string
token
;
...
...
paddle/fluid/inference/tests/book/test_inference_nlp.cc
浏览文件 @
81337368
...
@@ -19,7 +19,7 @@ limitations under the License. */
...
@@ -19,7 +19,7 @@ limitations under the License. */
#include "gflags/gflags.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/fluid/inference/tests/test_helper.h"
#include "paddle/fluid/inference/tests/test_helper.h"
#include "paddle/fluid/
operators/math/blas
.h"
#include "paddle/fluid/
platform/cpu_helper
.h"
#ifdef PADDLE_WITH_MKLML
#ifdef PADDLE_WITH_MKLML
#include <omp.h>
#include <omp.h>
#endif
#endif
...
@@ -164,7 +164,7 @@ TEST(inference, nlp) {
...
@@ -164,7 +164,7 @@ TEST(inference, nlp) {
// only use 1 thread number per std::thread
// only use 1 thread number per std::thread
omp_set_dynamic
(
0
);
omp_set_dynamic
(
0
);
omp_set_num_threads
(
1
);
omp_set_num_threads
(
1
);
paddle
::
operators
::
math
::
SetNumThreads
(
1
);
paddle
::
platform
::
SetNumThreads
(
1
);
#endif
#endif
double
start_ms
=
0
,
stop_ms
=
0
;
double
start_ms
=
0
,
stop_ms
=
0
;
...
...
paddle/fluid/operators/math/blas.h
浏览文件 @
81337368
...
@@ -29,18 +29,6 @@ namespace paddle {
...
@@ -29,18 +29,6 @@ namespace paddle {
namespace
operators
{
namespace
operators
{
namespace
math
{
namespace
math
{
static
void
SetNumThreads
(
int
num_threads
)
{
#ifdef PADDLE_USE_OPENBLAS
int
real_num_threads
=
num_threads
>
1
?
num_threads
:
1
;
openblas_set_num_threads
(
real_num_threads
);
#elif defined(PADDLE_WITH_MKLML)
int
real_num_threads
=
num_threads
>
1
?
num_threads
:
1
;
platform
::
dynload
::
MKL_Set_Num_Threads
(
real_num_threads
);
#else
PADDLE_ENFORCE
(
false
,
"To be implemented."
);
#endif
}
/**
/**
* Matrix Descriptor of a memory buffer.
* Matrix Descriptor of a memory buffer.
*
*
...
...
paddle/fluid/platform/CMakeLists.txt
浏览文件 @
81337368
...
@@ -28,6 +28,9 @@ cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
...
@@ -28,6 +28,9 @@ cc_test(place_test SRCS place_test.cc DEPS place glog gflags)
add_subdirectory
(
dynload
)
add_subdirectory
(
dynload
)
cc_library
(
cpu_helper SRCS cpu_helper.cc DEPS cblas enforce
)
cc_test
(
cpu_helper_test SRCS cpu_helper_test.cc DEPS cpu_helper
)
IF
(
WITH_GPU
)
IF
(
WITH_GPU
)
set
(
GPU_CTX_DEPS dynload_cuda dynamic_loader
)
set
(
GPU_CTX_DEPS dynload_cuda dynamic_loader
)
ELSE
()
ELSE
()
...
@@ -43,7 +46,7 @@ ENDIF()
...
@@ -43,7 +46,7 @@ ENDIF()
# memcpy depends on device_context, here add deps individually for
# memcpy depends on device_context, here add deps individually for
# avoiding cycle dependencies
# avoiding cycle dependencies
cc_library
(
device_context SRCS device_context.cc init.cc DEPS malloc
cc_library
(
device_context SRCS device_context.cc init.cc DEPS malloc
place eigen3 stringpiece
${
GPU_CTX_DEPS
}
${
MKLDNN_CTX_DEPS
}
)
place eigen3 stringpiece
cpu_helper
${
GPU_CTX_DEPS
}
${
MKLDNN_CTX_DEPS
}
)
nv_test
(
device_context_test SRCS device_context_test.cu DEPS device_context gpu_info
)
nv_test
(
device_context_test SRCS device_context_test.cu DEPS device_context gpu_info
)
cc_test
(
init_test SRCS init_test.cc DEPS device_context
)
cc_test
(
init_test SRCS init_test.cc DEPS device_context
)
...
...
paddle/fluid/platform/cpu_helper.cc
0 → 100644
浏览文件 @
81337368
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/enforce.h"
#ifdef PADDLE_WITH_MKLML
#include "paddle/fluid/platform/dynload/mklml.h"
#endif
#ifdef PADDLE_USE_OPENBLAS
#include <cblas.h>
#endif
namespace
paddle
{
namespace
platform
{
void
SetNumThreads
(
int
num_threads
)
{
#ifdef PADDLE_USE_OPENBLAS
int
real_num_threads
=
num_threads
>
1
?
num_threads
:
1
;
openblas_set_num_threads
(
real_num_threads
);
#elif defined(PADDLE_WITH_MKLML)
int
real_num_threads
=
num_threads
>
1
?
num_threads
:
1
;
platform
::
dynload
::
MKL_Set_Num_Threads
(
real_num_threads
);
#else
PADDLE_ENFORCE
(
false
,
"To be implemented."
);
#endif
}
}
// namespace platform
}
// namespace paddle
paddle/fluid/platform/cpu_helper.h
0 → 100644
浏览文件 @
81337368
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <stddef.h>
namespace
paddle
{
namespace
platform
{
//! Set the number of threads in use.
void
SetNumThreads
(
int
num_threads
);
}
// namespace platform
}
// namespace paddle
paddle/fluid/platform/cpu_helper_test.cc
0 → 100644
浏览文件 @
81337368
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/platform/cpu_helper.h"
#include "gtest/gtest.h"
TEST
(
CpuHelper
,
SetNumThread
)
{
paddle
::
platform
::
SetNumThreads
(
1
);
paddle
::
platform
::
SetNumThreads
(
4
);
}
paddle/fluid/platform/init.cc
浏览文件 @
81337368
...
@@ -17,7 +17,7 @@ limitations under the License. */
...
@@ -17,7 +17,7 @@ limitations under the License. */
#include <string>
#include <string>
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/
operators/math/blas
.h"
#include "paddle/fluid/
platform/cpu_helper
.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
...
@@ -115,7 +115,7 @@ void InitDevices(bool init_p2p, const std::vector<int> devices) {
...
@@ -115,7 +115,7 @@ void InitDevices(bool init_p2p, const std::vector<int> devices) {
places
.
emplace_back
(
platform
::
CPUPlace
());
places
.
emplace_back
(
platform
::
CPUPlace
());
platform
::
DeviceContextPool
::
Init
(
places
);
platform
::
DeviceContextPool
::
Init
(
places
);
#ifndef PADDLE_WITH_MKLDNN
#ifndef PADDLE_WITH_MKLDNN
operators
::
math
::
SetNumThreads
(
1
);
platform
::
SetNumThreads
(
1
);
#endif
#endif
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录