Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
24f77700
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
24f77700
编写于
12月 21, 2017
作者:
F
fengjiayi
提交者:
GitHub
12月 21, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6825 from JiayiFeng/rename_fill_zero_op_output
Rename fill_zeros_like_op's output
上级
7e214b49
f3cc75d8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
13 deletion
+13
-13
paddle/framework/backward.cc
paddle/framework/backward.cc
+2
-2
paddle/framework/backward_test.cc
paddle/framework/backward_test.cc
+4
-4
paddle/operators/fill_zeros_like_op.cc
paddle/operators/fill_zeros_like_op.cc
+5
-5
paddle/operators/fill_zeros_like_op.h
paddle/operators/fill_zeros_like_op.h
+1
-1
python/paddle/v2/fluid/tests/test_fill_zeros_like_op.py
python/paddle/v2/fluid/tests/test_fill_zeros_like_op.py
+1
-1
未找到文件。
paddle/framework/backward.cc
浏览文件 @
24f77700
...
...
@@ -217,7 +217,7 @@ static std::unique_ptr<OperatorBase> BackwardRecursive(
// If part of input gradient of that operator is not calculated, fill
// zero variables to that input gradient.
net
->
AppendOp
(
OpRegistry
::
CreateOp
(
"fill_zeros_like"
,
{{
"X"
,
{
prefix
}}},
{{
"
Y
"
,
{
grad_input
}}},
{{
"
Out
"
,
{
grad_input
}}},
AttributeMap
{}));
}
return
false
;
...
...
@@ -395,7 +395,7 @@ std::vector<std::unique_ptr<OpDesc>> MakeOpGrad(
desc
->
Rename
(
in_name
,
new_name
);
std
::
unique_ptr
<
OpDesc
>
fill_zeros_op
(
new
OpDesc
(
"fill_zeros_like"
,
{{
"X"
,
{
prefix
}}},
{{
"
Y
"
,
{
new_name
}}},
AttributeMap
{}));
{{
"
Out
"
,
{
new_name
}}},
AttributeMap
{}));
pending_fill_zeros_ops
.
push_back
(
std
::
move
(
fill_zeros_op
));
}
}
...
...
paddle/framework/backward_test.cc
浏览文件 @
24f77700
...
...
@@ -159,7 +159,7 @@ class FillZeroOpMaker : public OpProtoAndCheckerMaker {
FillZeroOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"x"
);
AddOutput
(
"
Y
"
,
"out"
);
AddOutput
(
"
Out
"
,
"out"
);
AddComment
(
""
);
}
};
...
...
@@ -430,8 +430,8 @@ TEST(Backward, op_part_of_output_are_not_need) {
ASSERT_EQ
(
"fill_zeros_like"
,
fill_zero
.
Type
());
ASSERT_EQ
(
1UL
,
fill_zero
.
Inputs
(
"X"
).
size
());
ASSERT_EQ
(
"Z"
,
fill_zero
.
Input
(
"X"
));
ASSERT_EQ
(
1UL
,
fill_zero
.
Outputs
(
"
Y
"
).
size
());
ASSERT_EQ
(
std
::
string
(
"Z"
)
+
f
::
kZeroVarSuffix
,
fill_zero
.
Output
(
"
Y
"
));
ASSERT_EQ
(
1UL
,
fill_zero
.
Outputs
(
"
Out
"
).
size
());
ASSERT_EQ
(
std
::
string
(
"Z"
)
+
f
::
kZeroVarSuffix
,
fill_zero
.
Output
(
"
Out
"
));
auto
&
d_many_out
=
*
net
->
ops_
[
1
];
ASSERT_EQ
(
"many_output_op_grad"
,
d_many_out
.
Type
());
...
...
@@ -772,7 +772,7 @@ TEST(Backward, var_no_grad) {
ASSERT_EQ
(
fill_zero_op
->
InputNames
().
size
(),
1UL
);
ASSERT_EQ
(
fill_zero_op
->
OutputNames
().
size
(),
1UL
);
EXPECT_EQ
(
fill_zero_op
->
Input
(
"X"
),
std
::
vector
<
std
::
string
>
({
"z1"
}));
EXPECT_EQ
(
fill_zero_op
->
Output
(
"
Y
"
),
EXPECT_EQ
(
fill_zero_op
->
Output
(
"
Out
"
),
std
::
vector
<
std
::
string
>
({
std
::
string
(
"z1"
)
+
f
::
kZeroVarSuffix
}));
f
::
OpDesc
*
grad_op1
=
block
->
AllOps
()[
5
];
...
...
paddle/operators/fill_zeros_like_op.cc
浏览文件 @
24f77700
...
...
@@ -24,10 +24,10 @@ class FillZerosLikeOp : public framework::OperatorWithKernel {
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) of FillZerosLikeOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"
Y
"
),
"Output(
Y
) of FillZerosLikeOp should not be null."
);
ctx
->
SetOutputDim
(
"
Y
"
,
ctx
->
GetInputDim
(
"X"
));
ctx
->
ShareLoD
(
"X"
,
/*->*/
"
Y
"
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"
Out
"
),
"Output(
Out
) of FillZerosLikeOp should not be null."
);
ctx
->
SetOutputDim
(
"
Out
"
,
ctx
->
GetInputDim
(
"X"
));
ctx
->
ShareLoD
(
"X"
,
/*->*/
"
Out
"
);
}
};
...
...
@@ -36,7 +36,7 @@ class FillZerosLikeOpMaker : public framework::OpProtoAndCheckerMaker {
FillZerosLikeOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
framework
::
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"The input of fill-zeros-like op."
);
AddOutput
(
"
Y
"
,
"The variable will be filled up with zeros."
);
AddOutput
(
"
Out
"
,
"The variable will be filled up with zeros."
);
AddComment
(
R"DOC(
FillZerosLike Operator.
...
...
paddle/operators/fill_zeros_like_op.h
浏览文件 @
24f77700
...
...
@@ -23,7 +23,7 @@ template <typename DeviceContext, typename T>
class
FillZerosLikeKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"
Y
"
);
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"
Out
"
);
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
math
::
SetConstant
<
DeviceContext
,
T
>
setter
;
...
...
python/paddle/v2/fluid/tests/test_fill_zeros_like_op.py
浏览文件 @
24f77700
...
...
@@ -7,7 +7,7 @@ class TestFillZerosLikeOp(OpTest):
def
setUp
(
self
):
self
.
op_type
=
"fill_zeros_like"
self
.
inputs
=
{
'X'
:
np
.
random
.
random
((
219
,
232
)).
astype
(
"float32"
)}
self
.
outputs
=
{
'
Y
'
:
np
.
zeros_like
(
self
.
inputs
[
"X"
])}
self
.
outputs
=
{
'
Out
'
:
np
.
zeros_like
(
self
.
inputs
[
"X"
])}
def
test_check_output
(
self
):
self
.
check_output
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录