Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b2c8a007
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b2c8a007
编写于
11月 25, 2020
作者:
W
wawltor
提交者:
GitHub
11月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove eigen threadpool for the speed up
remove eigen threadpool for the speed up
上级
7b5a8e46
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
32 deletion
+1
-32
paddle/fluid/operators/math/math_function.cc
paddle/fluid/operators/math/math_function.cc
+1
-7
paddle/fluid/platform/device_context.cc
paddle/fluid/platform/device_context.cc
+0
-18
paddle/fluid/platform/device_context.h
paddle/fluid/platform/device_context.h
+0
-7
未找到文件。
paddle/fluid/operators/math/math_function.cc
浏览文件 @
b2c8a007
...
...
@@ -99,13 +99,7 @@ struct TransposeNormal<platform::CPUDeviceContext, T> {
out_ptr
[
out_idx
]
=
in_ptr
[
in_idx
];
}
};
double
cost_per_iteration
=
rank
*
(
Eigen
::
TensorOpCost
::
DivCost
<
int64_t
>
()
+
2
*
Eigen
::
TensorOpCost
::
MulCost
<
int64_t
>
()
+
2
*
Eigen
::
TensorOpCost
::
AddCost
<
int64_t
>
());
Eigen
::
TensorOpCost
cost
(
sizeof
(
T
),
sizeof
(
T
),
cost_per_iteration
);
auto
*
cpu_device
=
context
.
eigen_pool_device
();
cpu_device
->
parallelFor
(
out
->
numel
(),
cost
,
std
::
move
(
transpose_helper
));
transpose_helper
(
0
,
out
->
numel
());
}
};
...
...
paddle/fluid/platform/device_context.cc
浏览文件 @
b2c8a007
...
...
@@ -12,7 +12,6 @@ limitations under the License. */
#include "paddle/fluid/platform/device_context.h"
#include <set>
#include <string>
#include <thread> //NOLINT
#include <unordered_set>
#include <vector>
...
...
@@ -24,7 +23,6 @@ limitations under the License. */
#endif
#include "glog/logging.h"
#include "unsupported/Eigen/CXX11/ThreadPool"
namespace
paddle
{
namespace
memory
{
...
...
@@ -133,32 +131,16 @@ DeviceContextPool::DeviceContextPool(
CPUDeviceContext
::
CPUDeviceContext
()
{
eigen_device_
.
reset
(
new
Eigen
::
DefaultDevice
());
InitPoolDevice
();
}
CPUDeviceContext
::
CPUDeviceContext
(
CPUPlace
place
)
:
place_
(
place
)
{
eigen_device_
.
reset
(
new
Eigen
::
DefaultDevice
());
InitPoolDevice
();
}
void
CPUDeviceContext
::
InitPoolDevice
()
{
using
EigenEnv
=
Eigen
::
StlThreadEnvironment
;
using
EigenThreadPool
=
Eigen
::
ThreadPoolTempl
<
EigenEnv
>
;
// int num_threads = std::thread::hardware_concurrency();
int
num_threads
=
1
;
eigen_threadpool_
.
reset
(
new
EigenThreadPool
(
num_threads
));
eigen_pool_device_
.
reset
(
new
Eigen
::
ThreadPoolDevice
(
eigen_threadpool_
.
get
(),
num_threads
));
}
Eigen
::
DefaultDevice
*
CPUDeviceContext
::
eigen_device
()
const
{
return
eigen_device_
.
get
();
}
Eigen
::
ThreadPoolDevice
*
CPUDeviceContext
::
eigen_pool_device
()
const
{
return
eigen_pool_device_
.
get
();
}
Place
CPUDeviceContext
::
GetPlace
()
const
{
return
place_
;
}
#ifdef PADDLE_WITH_XPU
...
...
paddle/fluid/platform/device_context.h
浏览文件 @
b2c8a007
...
...
@@ -43,7 +43,6 @@ limitations under the License. */
#ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/platform/stream/cuda_stream.h"
#endif
#define EIGEN_USE_THREADS
#include "unsupported/Eigen/CXX11/Tensor"
namespace
Eigen
{
...
...
@@ -73,17 +72,11 @@ class CPUDeviceContext : public DeviceContext {
Eigen
::
DefaultDevice
*
eigen_device
()
const
;
Eigen
::
ThreadPoolDevice
*
eigen_pool_device
()
const
;
Place
GetPlace
()
const
override
;
inline
void
InitPoolDevice
();
private:
CPUPlace
place_
;
std
::
unique_ptr
<
Eigen
::
DefaultDevice
>
eigen_device_
;
std
::
unique_ptr
<
Eigen
::
ThreadPoolDevice
>
eigen_pool_device_
;
std
::
unique_ptr
<
Eigen
::
ThreadPool
>
eigen_threadpool_
;
};
template
<
typename
Place
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录