Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
099bb53b
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
099bb53b
编写于
7月 27, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/backward' of github.com:reyoung/Paddle into feature/backward
上级
28c0281d
04db4183
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
14 deletion
+21
-14
paddle/framework/backward_test.cc
paddle/framework/backward_test.cc
+14
-8
paddle/operators/CMakeLists.txt
paddle/operators/CMakeLists.txt
+1
-0
paddle/operators/fill_zeros_like_op.cc
paddle/operators/fill_zeros_like_op.cc
+6
-6
未找到文件。
paddle/framework/backward_test.cc
浏览文件 @
099bb53b
...
@@ -249,14 +249,20 @@ TEST(Backward, part_of_output_are_not_need) {
...
@@ -249,14 +249,20 @@ TEST(Backward, part_of_output_are_not_need) {
}
}
TEST
(
Backward
,
part_of_input_are_not_need
)
{
TEST
(
Backward
,
part_of_input_are_not_need
)
{
auto
fwd
=
f
::
OpRegistry
::
CreateOp
(
"
rowwise_add"
,
{
"X"
,
"b"
},
{
"O
ut"
},
{});
auto
fwd
=
f
::
OpRegistry
::
CreateOp
(
"
mul"
,
{
"a"
,
"b"
},
{
"o
ut"
},
{});
auto
backward
=
f
::
Backward
(
*
fwd
,
{
"
X
"
});
auto
backward
=
f
::
Backward
(
*
fwd
,
{
"
a
"
});
ASSERT_TRUE
(
backward
->
IsNetOp
());
ASSERT_TRUE
(
backward
->
IsNetOp
());
auto
net
=
static_cast
<
f
::
NetOp
*>
(
backward
.
get
());
auto
net
=
static_cast
<
f
::
NetOp
*>
(
backward
.
get
());
ASSERT_EQ
(
1UL
,
net
->
ops_
.
size
());
ASSERT_EQ
(
net
->
ops_
.
size
(),
1UL
);
auto
&
d_add
=
*
net
->
ops_
[
0
];
auto
&
grad_mul
=
*
net
->
ops_
[
0
];
ASSERT_EQ
(
"rowwise_add_grad"
,
d_add
.
type_
);
ASSERT_EQ
(
grad_mul
.
type_
,
"mul_grad"
);
ASSERT_EQ
(
f
::
OperatorBase
::
EMPTY_VAR_NAME
(),
ASSERT_EQ
(
grad_mul
.
inputs_
.
size
(),
2UL
+
1UL
+
1UL
);
d_add
.
Output
(
"X"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
()));
ASSERT_EQ
(
grad_mul
.
outputs_
.
size
(),
2UL
);
ASSERT_EQ
(
grad_mul
.
Output
(
"A"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
()),
f
::
OperatorBase
::
EMPTY_VAR_NAME
());
ASSERT_EQ
(
grad_mul
.
Output
(
"B"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
()),
"b"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
());
ASSERT_EQ
(
grad_mul
.
Input
(
"Out"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
()),
"out"
+
f
::
OperatorBase
::
GRAD_VAR_SUFFIX
());
}
}
\ No newline at end of file
paddle/operators/CMakeLists.txt
浏览文件 @
099bb53b
...
@@ -49,6 +49,7 @@ op_library(rowwise_add_op SRCS rowwise_add_op.cu rowwise_add_op.cc)
...
@@ -49,6 +49,7 @@ op_library(rowwise_add_op SRCS rowwise_add_op.cu rowwise_add_op.cc)
op_library
(
sigmoid_op SRCS sigmoid_op.cu sigmoid_op.cc
)
op_library
(
sigmoid_op SRCS sigmoid_op.cu sigmoid_op.cc
)
op_library
(
softmax_op SRCS softmax_op.cc softmax_op.cu
)
op_library
(
softmax_op SRCS softmax_op.cc softmax_op.cu
)
op_library
(
cross_entropy_op SRCS cross_entropy_op.cc cross_entropy_op.cu
)
op_library
(
cross_entropy_op SRCS cross_entropy_op.cc cross_entropy_op.cu
)
op_library
(
fill_zeros_like_op SRCS fill_zeros_like_op.cc fill_zeros_like_op.cu
)
op_library
(
fc_op SRCS fc_op.cc DEPS mul_op rowwise_add_op sigmoid_op
op_library
(
fc_op SRCS fc_op.cc DEPS mul_op rowwise_add_op sigmoid_op
softmax_op net
)
softmax_op net
)
...
...
paddle/operators/fill_zeros_like_op.cc
浏览文件 @
099bb53b
...
@@ -19,16 +19,16 @@ limitations under the License. */
...
@@ -19,16 +19,16 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
class
FillZerosLike
:
public
framework
::
OperatorWithKernel
{
class
FillZerosLike
Op
:
public
framework
::
OperatorWithKernel
{
protected:
protected:
void
InferShape
(
void
InferShape
(
const
std
::
vector
<
const
framework
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
const
framework
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
framework
::
Tensor
*>
&
outputs
)
const
override
{
const
std
::
vector
<
framework
::
Tensor
*>
&
outputs
)
const
override
{
PADDLE_ENFORCE
(
inputs
.
size
()
==
1
,
PADDLE_ENFORCE
(
inputs
.
size
()
==
1
,
"Input size of FillZerosLike must be one."
);
"Input size of FillZerosLike
Op
must be one."
);
PADDLE_ENFORCE
(
outputs
.
size
()
==
1
,
"Output size of AddOp must be one."
);
PADDLE_ENFORCE
(
outputs
.
size
()
==
1
,
"Output size of AddOp must be one."
);
PADDLE_ENFORCE
(
inputs
[
0
]
!=
nullptr
&&
outputs
[
0
]
!=
nullptr
,
PADDLE_ENFORCE
(
inputs
[
0
]
!=
nullptr
&&
outputs
[
0
]
!=
nullptr
,
"Outputs of FillZerosLike must all be set."
);
"Outputs of FillZerosLike
Op
must all be set."
);
outputs
[
0
]
->
Resize
(
inputs
[
0
]
->
dims
());
outputs
[
0
]
->
Resize
(
inputs
[
0
]
->
dims
());
}
}
};
};
...
@@ -44,7 +44,7 @@ public:
...
@@ -44,7 +44,7 @@ public:
Fill up a vriable with zeros.
Fill up a vriable with zeros.
The output will have the same size with input.
The output will have the same size with input.
)DOC"
)
)DOC"
)
;
}
}
};
};
}
// namespace operators
}
// namespace operators
...
@@ -53,6 +53,6 @@ The output will have the same size with input.
...
@@ -53,6 +53,6 @@ The output will have the same size with input.
REGISTER_OP
(
fill_zeros_like
,
REGISTER_OP
(
fill_zeros_like
,
paddle
::
operators
::
FillZerosLikeOp
,
paddle
::
operators
::
FillZerosLikeOp
,
paddle
::
operators
::
FillZerosLikeOpMaker
);
paddle
::
operators
::
FillZerosLikeOpMaker
);
EGISTER_OP_CPU_KERNEL
(
R
EGISTER_OP_CPU_KERNEL
(
fill_zeros_like
,
fill_zeros_like
,
paddle
::
operators
::
FillZerosLikeKernal
<
paddle
::
platform
::
CPUPlace
,
float
>
);
paddle
::
operators
::
FillZerosLikeKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录