Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3f09620e
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f09620e
编写于
2月 13, 2018
作者:
Y
Yang Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pass compile
上级
e021ad67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
14 deletion
+17
-14
paddle/fluid/framework/executor.cc
paddle/fluid/framework/executor.cc
+1
-1
paddle/fluid/operators/nccl_op.cc
paddle/fluid/operators/nccl_op.cc
+1
-1
python/paddle/v2/fluid/backward.py
python/paddle/v2/fluid/backward.py
+15
-12
未找到文件。
paddle/fluid/framework/executor.cc
浏览文件 @
3f09620e
...
...
@@ -55,7 +55,7 @@ static void CreateTensor(Variable* var, proto::VarType::Type var_type) {
var
->
GetMutable
<
platform
::
PlaceList
>
();
}
else
if
(
var_type
==
proto
::
VarType
::
READER
)
{
var
->
GetMutable
<
ReaderHolder
>
();
}
else
if
(
var_type
==
proto
::
Var
Desc
::
NCCL_COM
)
{
}
else
if
(
var_type
==
proto
::
Var
Type
::
NCCL_COM
)
{
// GetMutable will be called in ncclInit
}
else
{
PADDLE_THROW
(
...
...
paddle/fluid/operators/nccl_op.cc
浏览文件 @
3f09620e
...
...
@@ -65,7 +65,7 @@ class NCCLInitOpVarTypeInference : public framework::VarTypeInference {
framework
::
BlockDesc
*
block
)
const
override
{
auto
out_var_name
=
op_desc
.
Output
(
"Communicator"
).
front
();
auto
&
out_var
=
block
->
FindRecursiveOrCreateVar
(
out_var_name
);
auto
var_type
=
framework
::
proto
::
Var
Desc
::
NCCL_COM
;
auto
var_type
=
framework
::
proto
::
Var
Type
::
NCCL_COM
;
out_var
.
SetType
(
var_type
);
}
};
...
...
python/paddle/v2/fluid/backward.py
浏览文件 @
3f09620e
...
...
@@ -269,7 +269,7 @@ def _append_backward_ops_(block,
target_block
,
no_grad_dict
,
grad_to_var
,
callback
=
None
):
callback
s
=
None
):
"""
Create all grad ops, and insert them into given block
...
...
@@ -285,14 +285,13 @@ def _append_backward_ops_(block,
val(str): corresponding forward variable name
callback(callable object): a callable object used to decorate new generated grad ops
"""
if
callback
is
None
:
def
empty_callback
(
block
,
context
):
pass
callback
=
empty_callback
elif
not
hasattr
(
callback
,
'__call__'
):
raise
ValueError
(
"'callback' must be a callable object."
)
if
callbacks
is
None
:
callbacks
=
[]
else
:
assert
(
isinstance
(
callbacks
,
list
))
for
cb
in
callbacks
:
if
not
hasattr
(
cb
,
'__call__'
):
raise
ValueError
(
"'callback' must be a callable object."
)
# grad_op_descs holds created grad_op, and will be appended to target_block
grad_op_descs
=
[]
...
...
@@ -303,9 +302,12 @@ def _append_backward_ops_(block,
if
op
.
has_attr
(
"sub_block"
):
sub_block
=
program
.
block
(
op
.
block_attr
(
"sub_block"
))
grad_sub_block
=
program
.
create_block
(
parent_idx
=
sub_block
.
idx
)
if
callbacks
is
None
:
callbacks
=
[
_callback_lookup_
(
op
)]
else
:
callbacks
.
append
(
_callback_lookup_
(
op
))
_append_backward_ops_
(
sub_block
,
sub_block
.
ops
,
grad_sub_block
,
no_grad_dict
,
grad_to_var
,
_callback_lookup_
(
op
))
no_grad_dict
,
grad_to_var
,
callbacks
)
grad_sub_block_list
.
append
(
grad_sub_block
.
desc
)
# Getting op's corresponding grad_op
...
...
@@ -325,7 +327,8 @@ def _append_backward_ops_(block,
new_op_desc
=
target_block
.
desc
.
append_op
()
new_op_desc
.
copy_from
(
op_desc
)
grad_to_var
[
"__current_op_desc__"
]
=
new_op_desc
callback
(
block
=
target_block
,
context
=
grad_to_var
)
for
cb
in
callbacks
:
cb
(
block
=
target_block
,
context
=
grad_to_var
)
def
_append_backward_vars_
(
block
,
start_op_idx
,
grad_to_var
,
grad_info_map
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录