Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8ff3590e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
8ff3590e
编写于
8月 04, 2017
作者:
D
dongzhihong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix op name
上级
264b6447
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
14 deletion
+14
-14
paddle/operators/rowwise_add_op.cc
paddle/operators/rowwise_add_op.cc
+10
-10
paddle/operators/rowwise_add_op.cu
paddle/operators/rowwise_add_op.cu
+1
-1
paddle/operators/rowwise_add_op.h
paddle/operators/rowwise_add_op.h
+3
-3
未找到文件。
paddle/operators/rowwise_add_op.cc
浏览文件 @
8ff3590e
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
class
Row
W
iseAddOp
:
public
OperatorWithKernel
{
class
Row
w
iseAddOp
:
public
OperatorWithKernel
{
protected:
protected:
void
InferShape
(
const
InferShapeContext
&
ctx
)
const
override
{
void
InferShape
(
const
InferShapeContext
&
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
.
InputSize
()
==
2UL
,
PADDLE_ENFORCE
(
ctx
.
InputSize
()
==
2UL
,
...
@@ -32,9 +32,9 @@ protected:
...
@@ -32,9 +32,9 @@ protected:
}
}
};
};
class
Row
W
iseAddOpMaker
:
public
OpProtoAndCheckerMaker
{
class
Row
w
iseAddOpMaker
:
public
OpProtoAndCheckerMaker
{
public:
public:
Row
W
iseAddOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
Row
w
iseAddOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"The left input of row-wise add op, must be matrix"
);
AddInput
(
"X"
,
"The left input of row-wise add op, must be matrix"
);
AddInput
(
"b"
,
"The right input of row-wise add op, must be vector"
);
AddInput
(
"b"
,
"The right input of row-wise add op, must be vector"
);
...
@@ -46,13 +46,13 @@ for i in xrange(X.shape[0]):
...
@@ -46,13 +46,13 @@ for i in xrange(X.shape[0]):
)DOC"
);
)DOC"
);
}
}
};
};
class
Row
W
iseAddGradOp
:
public
OperatorWithKernel
{
class
Row
w
iseAddGradOp
:
public
OperatorWithKernel
{
protected:
protected:
void
InferShape
(
const
InferShapeContext
&
ctx
)
const
override
{
void
InferShape
(
const
InferShapeContext
&
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
.
InputSize
()
==
4UL
,
PADDLE_ENFORCE
(
ctx
.
InputSize
()
==
4UL
,
"Row
W
iseAddGrad inputs is I, O, OG, size must be 4"
);
"Row
w
iseAddGrad inputs is I, O, OG, size must be 4"
);
PADDLE_ENFORCE
(
ctx
.
OutputSize
()
==
2
,
PADDLE_ENFORCE
(
ctx
.
OutputSize
()
==
2
,
"Row
W
iseAddGrad output is IG, size must be 2"
);
"Row
w
iseAddGrad output is IG, size must be 2"
);
ctx
.
Output
<
Tensor
>
(
0
)
->
Resize
(
ctx
.
Input
<
Tensor
>
(
0
)
->
dims
());
ctx
.
Output
<
Tensor
>
(
0
)
->
Resize
(
ctx
.
Input
<
Tensor
>
(
0
)
->
dims
());
ctx
.
Output
<
Tensor
>
(
1
)
->
Resize
(
ctx
.
Input
<
Tensor
>
(
1
)
->
dims
());
ctx
.
Output
<
Tensor
>
(
1
)
->
Resize
(
ctx
.
Input
<
Tensor
>
(
1
)
->
dims
());
}
}
...
@@ -61,10 +61,10 @@ protected:
...
@@ -61,10 +61,10 @@ protected:
}
// namespace operators
}
// namespace operators
}
// namespace paddle
}
// namespace paddle
REGISTER_OP
(
rowwise_add
,
ops
::
Row
WiseAddOp
,
ops
::
RowW
iseAddOpMaker
);
REGISTER_OP
(
rowwise_add
,
ops
::
Row
wiseAddOp
,
ops
::
Roww
iseAddOpMaker
);
REGISTER_OP_CPU_KERNEL
(
rowwise_add
,
REGISTER_OP_CPU_KERNEL
(
rowwise_add
,
ops
::
Row
W
iseAddKernel
<
ops
::
CPUPlace
,
float
>
);
ops
::
Row
w
iseAddKernel
<
ops
::
CPUPlace
,
float
>
);
REGISTER_GRADIENT_OP
(
rowwise_add
,
rowwise_add_grad
,
ops
::
Row
W
iseAddGradOp
);
REGISTER_GRADIENT_OP
(
rowwise_add
,
rowwise_add_grad
,
ops
::
Row
w
iseAddGradOp
);
REGISTER_OP_CPU_KERNEL
(
rowwise_add_grad
,
REGISTER_OP_CPU_KERNEL
(
rowwise_add_grad
,
ops
::
Row
W
iseAddGradKernel
<
ops
::
CPUPlace
,
float
>
);
ops
::
Row
w
iseAddGradKernel
<
ops
::
CPUPlace
,
float
>
);
paddle/operators/rowwise_add_op.cu
浏览文件 @
8ff3590e
#include "paddle/operators/rowwise_add_op.h"
#include "paddle/operators/rowwise_add_op.h"
REGISTER_OP_GPU_KERNEL
(
rowwise_add
,
REGISTER_OP_GPU_KERNEL
(
rowwise_add
,
ops
::
Row
W
iseAddKernel
<
ops
::
GPUPlace
,
float
>
);
ops
::
Row
w
iseAddKernel
<
ops
::
GPUPlace
,
float
>
);
paddle/operators/rowwise_add_op.h
浏览文件 @
8ff3590e
...
@@ -19,7 +19,7 @@ namespace paddle {
...
@@ -19,7 +19,7 @@ namespace paddle {
namespace
operators
{
namespace
operators
{
template
<
typename
Place
,
typename
T
>
template
<
typename
Place
,
typename
T
>
class
Row
W
iseAddKernel
:
public
OpKernel
{
class
Row
w
iseAddKernel
:
public
OpKernel
{
public:
public:
void
Compute
(
const
ExecutionContext
&
context
)
const
override
{
void
Compute
(
const
ExecutionContext
&
context
)
const
override
{
auto
out
=
context
.
Output
<
Tensor
>
(
0
);
auto
out
=
context
.
Output
<
Tensor
>
(
0
);
...
@@ -39,7 +39,7 @@ public:
...
@@ -39,7 +39,7 @@ public:
};
};
template
<
typename
Place
,
typename
T
>
template
<
typename
Place
,
typename
T
>
class
Row
W
iseAddGradKernel
:
public
OpKernel
{
class
Row
w
iseAddGradKernel
:
public
OpKernel
{
public:
public:
void
Compute
(
const
ExecutionContext
&
context
)
const
override
{
void
Compute
(
const
ExecutionContext
&
context
)
const
override
{
auto
XGrad
=
context
.
Output
<
Tensor
>
(
0
);
auto
XGrad
=
context
.
Output
<
Tensor
>
(
0
);
...
@@ -51,7 +51,7 @@ public:
...
@@ -51,7 +51,7 @@ public:
auto
OutGrad
=
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
3
));
auto
OutGrad
=
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
3
));
EigenMatrix
<
T
>::
From
(
*
XGrad
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenMatrix
<
T
>::
From
(
*
XGrad
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
OutGrad
;
OutGrad
;
// const int dimension = bGrad.dimension(0);
// https://eigen.tuxfamily.org/dox/unsupported/TensorBase_8h_source.html
// https://eigen.tuxfamily.org/dox/unsupported/TensorBase_8h_source.html
EigenVector
<
T
>::
Flatten
(
*
bGrad
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenVector
<
T
>::
Flatten
(
*
bGrad
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
OutGrad
.
cumsum
(
1
);
// colwise add
OutGrad
.
cumsum
(
1
);
// colwise add
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录