Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
d9585f9a
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d9585f9a
编写于
10月 09, 2017
作者:
T
Tao Luo
提交者:
GitHub
10月 09, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4632 from luotao1/reduce
Unify Reduce functions and simplify register code
上级
3a68955f
59729907
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
63 deletion
+35
-63
paddle/operators/activation_op.cc
paddle/operators/activation_op.cc
+3
-5
paddle/operators/activation_op.cu
paddle/operators/activation_op.cu
+5
-5
paddle/operators/reduce_op.cc
paddle/operators/reduce_op.cc
+12
-26
paddle/operators/reduce_op.cu
paddle/operators/reduce_op.cu
+9
-27
paddle/operators/reduce_op.h
paddle/operators/reduce_op.h
+6
-0
未找到文件。
paddle/operators/activation_op.cc
浏览文件 @
d9585f9a
...
...
@@ -285,11 +285,9 @@ REGISTER_OP(stanh, ops::ActivationOp, ops::STanhOpMaker<float>, stanh_grad,
#define REGISTER_ACTIVATION_CPU_KERNEL(act_type, functor, grad_functor) \
REGISTER_OP_CPU_KERNEL( \
act_type, \
paddle::operators::ActivationKernel<paddle::platform::CPUPlace, \
paddle::operators::functor<float>>); \
ops::ActivationKernel<paddle::platform::CPUPlace, ops::functor<float>>); \
REGISTER_OP_CPU_KERNEL(act_type##_grad, \
paddle::operators::ActivationGradKernel< \
paddle::platform::CPUPlace, \
paddle::operators::grad_functor<float>>);
ops::ActivationGradKernel<paddle::platform::CPUPlace, \
ops::grad_functor<float>>);
FOR_EACH_KERNEL_FUNCTOR
(
REGISTER_ACTIVATION_CPU_KERNEL
);
paddle/operators/activation_op.cu
浏览文件 @
d9585f9a
...
...
@@ -15,14 +15,14 @@
#define EIGEN_USE_GPU
#include "paddle/operators/activation_op.h"
namespace
ops
=
paddle
::
operators
;
#define REGISTER_ACTIVATION_GPU_KERNEL(act_type, functor, grad_functor) \
REGISTER_OP_GPU_KERNEL( \
act_type, \
paddle::operators::ActivationKernel<paddle::platform::GPUPlace, \
paddle::operators::functor<float>>); \
ops::ActivationKernel<paddle::platform::GPUPlace, ops::functor<float>>); \
REGISTER_OP_GPU_KERNEL(act_type##_grad, \
paddle::operators::ActivationGradKernel< \
paddle::platform::GPUPlace, \
paddle::operators::grad_functor<float>>);
ops::ActivationGradKernel<paddle::platform::GPUPlace, \
ops::grad_functor<float>>);
FOR_EACH_KERNEL_FUNCTOR
(
REGISTER_ACTIVATION_GPU_KERNEL
);
paddle/operators/reduce_op.cc
浏览文件 @
d9585f9a
...
...
@@ -168,36 +168,22 @@ namespace ops = paddle::operators;
REGISTER_OP
(
reduce_sum
,
ops
::
ReduceOp
,
ops
::
ReduceSumOpMaker
,
reduce_sum_grad
,
ops
::
ReduceGradOp
);
REGISTER_OP_CPU_KERNEL
(
reduce_sum
,
ops
::
ReduceKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
SumFunctor
>
);
REGISTER_OP_CPU_KERNEL
(
reduce_sum_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
SumGradFunctor
>
);
REGISTER_OP
(
reduce_mean
,
ops
::
ReduceOp
,
ops
::
ReduceMeanOpMaker
,
reduce_mean_grad
,
ops
::
ReduceGradOp
);
REGISTER_OP_CPU_KERNEL
(
reduce_mean
,
ops
::
ReduceKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MeanFunctor
>
);
REGISTER_OP_CPU_KERNEL
(
reduce_mean_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MeanGradFunctor
>
);
REGISTER_OP
(
reduce_max
,
ops
::
ReduceOp
,
ops
::
ReduceMaxOpMaker
,
reduce_max_grad
,
ops
::
ReduceGradOp
);
REGISTER_OP_CPU_KERNEL
(
reduce_max
,
ops
::
ReduceKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MaxFunctor
>
);
REGISTER_OP_CPU_KERNEL
(
reduce_max_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MaxOrMinGradFunctor
>
);
REGISTER_OP
(
reduce_min
,
ops
::
ReduceOp
,
ops
::
ReduceMaxOpMaker
,
reduce_min_grad
,
REGISTER_OP
(
reduce_min
,
ops
::
ReduceOp
,
ops
::
ReduceMinOpMaker
,
reduce_min_grad
,
ops
::
ReduceGradOp
);
REGISTER_OP_CPU_KERNEL
(
reduce_min
,
ops
::
ReduceKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MinFunctor
>
);
REGISTER_OP_CPU_KERNEL
(
reduce_min_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
,
ops
::
MaxOrMinGradFunctor
>
);
#define REGISTER_REDUCE_CPU_KERNEL(reduce_type, functor, grad_functor) \
REGISTER_OP_CPU_KERNEL( \
reduce_type, \
ops::ReduceKernel<paddle::platform::CPUPlace, float, ops::functor>); \
REGISTER_OP_CPU_KERNEL(reduce_type##_grad, \
ops::ReduceGradKernel<paddle::platform::CPUPlace, \
float, ops::grad_functor>);
FOR_EACH_KERNEL_FUNCTOR
(
REGISTER_REDUCE_CPU_KERNEL
);
paddle/operators/reduce_op.cu
浏览文件 @
d9585f9a
...
...
@@ -17,30 +17,12 @@
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_GPU_KERNEL
(
reduce_sum
,
ops
::
ReduceKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
SumFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_sum_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
SumGradFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_mean
,
ops
::
ReduceKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MeanFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_mean_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MeanGradFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_max
,
ops
::
ReduceKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MaxFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_max_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MaxOrMinGradFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_min
,
ops
::
ReduceKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MinFunctor
>
);
REGISTER_OP_GPU_KERNEL
(
reduce_min_grad
,
ops
::
ReduceGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
,
ops
::
MaxOrMinGradFunctor
>
);
#define REGISTER_REDUCE_GPU_KERNEL(reduce_type, functor, grad_functor) \
REGISTER_OP_GPU_KERNEL( \
reduce_type, \
ops::ReduceKernel<paddle::platform::GPUPlace, float, ops::functor>); \
REGISTER_OP_GPU_KERNEL(reduce_type##_grad, \
ops::ReduceGradKernel<paddle::platform::GPUPlace, \
float, ops::grad_functor>);
FOR_EACH_KERNEL_FUNCTOR
(
REGISTER_REDUCE_GPU_KERNEL
);
paddle/operators/reduce_op.h
浏览文件 @
d9585f9a
...
...
@@ -198,3 +198,9 @@ class ReduceGradKernel : public framework::OpKernel<T> {
}
// namespace operators
}
// namespace paddle
#define FOR_EACH_KERNEL_FUNCTOR(__macro) \
__macro(reduce_sum, SumFunctor, SumGradFunctor); \
__macro(reduce_mean, MeanFunctor, MeanGradFunctor); \
__macro(reduce_max, MaxFunctor, MaxOrMinGradFunctor); \
__macro(reduce_min, MinFunctor, MaxOrMinGradFunctor);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录