Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
3f09620e
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
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) {
...
@@ -55,7 +55,7 @@ static void CreateTensor(Variable* var, proto::VarType::Type var_type) {
var
->
GetMutable
<
platform
::
PlaceList
>
();
var
->
GetMutable
<
platform
::
PlaceList
>
();
}
else
if
(
var_type
==
proto
::
VarType
::
READER
)
{
}
else
if
(
var_type
==
proto
::
VarType
::
READER
)
{
var
->
GetMutable
<
ReaderHolder
>
();
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
// GetMutable will be called in ncclInit
}
else
{
}
else
{
PADDLE_THROW
(
PADDLE_THROW
(
...
...
paddle/fluid/operators/nccl_op.cc
浏览文件 @
3f09620e
...
@@ -65,7 +65,7 @@ class NCCLInitOpVarTypeInference : public framework::VarTypeInference {
...
@@ -65,7 +65,7 @@ class NCCLInitOpVarTypeInference : public framework::VarTypeInference {
framework
::
BlockDesc
*
block
)
const
override
{
framework
::
BlockDesc
*
block
)
const
override
{
auto
out_var_name
=
op_desc
.
Output
(
"Communicator"
).
front
();
auto
out_var_name
=
op_desc
.
Output
(
"Communicator"
).
front
();
auto
&
out_var
=
block
->
FindRecursiveOrCreateVar
(
out_var_name
);
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
);
out_var
.
SetType
(
var_type
);
}
}
};
};
...
...
python/paddle/v2/fluid/backward.py
浏览文件 @
3f09620e
...
@@ -269,7 +269,7 @@ def _append_backward_ops_(block,
...
@@ -269,7 +269,7 @@ def _append_backward_ops_(block,
target_block
,
target_block
,
no_grad_dict
,
no_grad_dict
,
grad_to_var
,
grad_to_var
,
callback
=
None
):
callback
s
=
None
):
"""
"""
Create all grad ops, and insert them into given block
Create all grad ops, and insert them into given block
...
@@ -285,14 +285,13 @@ def _append_backward_ops_(block,
...
@@ -285,14 +285,13 @@ def _append_backward_ops_(block,
val(str): corresponding forward variable name
val(str): corresponding forward variable name
callback(callable object): a callable object used to decorate new generated grad ops
callback(callable object): a callable object used to decorate new generated grad ops
"""
"""
if
callback
is
None
:
if
callbacks
is
None
:
callbacks
=
[]
def
empty_callback
(
block
,
context
):
else
:
pass
assert
(
isinstance
(
callbacks
,
list
))
for
cb
in
callbacks
:
callback
=
empty_callback
if
not
hasattr
(
cb
,
'__call__'
):
elif
not
hasattr
(
callback
,
'__call__'
):
raise
ValueError
(
"'callback' must be a callable object."
)
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 holds created grad_op, and will be appended to target_block
grad_op_descs
=
[]
grad_op_descs
=
[]
...
@@ -303,9 +302,12 @@ def _append_backward_ops_(block,
...
@@ -303,9 +302,12 @@ def _append_backward_ops_(block,
if
op
.
has_attr
(
"sub_block"
):
if
op
.
has_attr
(
"sub_block"
):
sub_block
=
program
.
block
(
op
.
block_attr
(
"sub_block"
))
sub_block
=
program
.
block
(
op
.
block_attr
(
"sub_block"
))
grad_sub_block
=
program
.
create_block
(
parent_idx
=
sub_block
.
idx
)
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
,
_append_backward_ops_
(
sub_block
,
sub_block
.
ops
,
grad_sub_block
,
no_grad_dict
,
grad_to_var
,
no_grad_dict
,
grad_to_var
,
callbacks
)
_callback_lookup_
(
op
))
grad_sub_block_list
.
append
(
grad_sub_block
.
desc
)
grad_sub_block_list
.
append
(
grad_sub_block
.
desc
)
# Getting op's corresponding grad_op
# Getting op's corresponding grad_op
...
@@ -325,7 +327,8 @@ def _append_backward_ops_(block,
...
@@ -325,7 +327,8 @@ def _append_backward_ops_(block,
new_op_desc
=
target_block
.
desc
.
append_op
()
new_op_desc
=
target_block
.
desc
.
append_op
()
new_op_desc
.
copy_from
(
op_desc
)
new_op_desc
.
copy_from
(
op_desc
)
grad_to_var
[
"__current_op_desc__"
]
=
new_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
):
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录