Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
fb370f44
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看板
提交
fb370f44
编写于
5月 22, 2018
作者:
Y
yuyang18
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine code
上级
03e4da6d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
26 deletion
+31
-26
paddle/fluid/framework/details/multi_devices_graph_builder.cc
...le/fluid/framework/details/multi_devices_graph_builder.cc
+27
-20
paddle/fluid/framework/op_desc.cc
paddle/fluid/framework/op_desc.cc
+2
-3
paddle/fluid/framework/op_desc.h
paddle/fluid/framework/op_desc.h
+1
-2
python/paddle/fluid/backward.py
python/paddle/fluid/backward.py
+1
-1
未找到文件。
paddle/fluid/framework/details/multi_devices_graph_builder.cc
浏览文件 @
fb370f44
...
@@ -163,27 +163,34 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
...
@@ -163,27 +163,34 @@ std::unique_ptr<SSAGraph> MultiDevSSAGraphBuilder::Build(
if
(
static_cast
<
bool
>
(
boost
::
get
<
int
>
(
op
->
GetAttr
(
if
(
static_cast
<
bool
>
(
boost
::
get
<
int
>
(
op
->
GetAttr
(
OpProtoAndCheckerMaker
::
OpRoleAttrName
()))
&
OpProtoAndCheckerMaker
::
OpRoleAttrName
()))
&
static_cast
<
int
>
(
OpRole
::
kBackward
)))
{
static_cast
<
int
>
(
OpRole
::
kBackward
)))
{
auto
backward_vars
=
boost
::
get
<
std
::
vector
<
std
::
string
>>
(
try
{
op
->
GetAttrOrDefault
(
OpProtoAndCheckerMaker
::
OpRoleVarAttrName
(),
auto
backward_vars
=
std
::
vector
<
std
::
string
>
()));
boost
::
get
<
std
::
vector
<
std
::
string
>>
(
op
->
GetNullableAttr
(
for
(
auto
&
og
:
backward_vars
)
{
OpProtoAndCheckerMaker
::
OpRoleVarAttrName
()));
switch
(
strategy_
.
reduce_
)
{
case
BuildStrategy
::
ReduceStrategy
::
kReduce
:
PADDLE_ENFORCE_EQ
(
backward_vars
.
size
()
%
2
,
0
);
CreateReduceOp
(
&
result
,
og
,
cur_device_id
);
var_name_on_devices
[
cur_device_id
].
emplace
(
og
);
for
(
size_t
i
=
0
;
i
<
backward_vars
.
size
();
++
i
)
{
bcast_var_name_set
[
cur_device_id
].
emplace
(
auto
&
p_name
=
backward_vars
[
i
];
og
.
substr
(
0
,
og
.
size
()
-
strlen
(
kGradVarSuffix
)));
auto
&
g_name
=
backward_vars
[
i
+
1
];
cur_device_id
=
(
cur_device_id
+
1
)
%
places_
.
size
();
switch
(
strategy_
.
reduce_
)
{
break
;
case
BuildStrategy
::
ReduceStrategy
::
kReduce
:
case
BuildStrategy
::
ReduceStrategy
::
kAllReduce
:
CreateReduceOp
(
&
result
,
g_name
,
cur_device_id
);
if
(
IsSparseGradient
(
var_types
,
og
))
{
var_name_on_devices
[
cur_device_id
].
emplace
(
g_name
);
CreateReduceOp
(
&
result
,
og
,
0
);
bcast_var_name_set
[
cur_device_id
].
emplace
(
p_name
);
CreateBroadcastOp
(
&
result
,
og
,
0
);
cur_device_id
=
(
cur_device_id
+
1
)
%
places_
.
size
();
}
else
{
break
;
InsertNCCLAllReduceOp
(
&
result
,
og
);
case
BuildStrategy
::
ReduceStrategy
::
kAllReduce
:
}
if
(
IsSparseGradient
(
var_types
,
g_name
))
{
break
;
CreateReduceOp
(
&
result
,
g_name
,
0
);
CreateBroadcastOp
(
&
result
,
g_name
,
0
);
}
else
{
InsertNCCLAllReduceOp
(
&
result
,
g_name
);
}
break
;
}
}
}
}
catch
(
boost
::
bad_get
e
)
{
}
}
}
}
}
}
...
...
paddle/fluid/framework/op_desc.cc
浏览文件 @
fb370f44
...
@@ -223,13 +223,12 @@ Attribute OpDesc::GetAttr(const std::string &name) const {
...
@@ -223,13 +223,12 @@ Attribute OpDesc::GetAttr(const std::string &name) const {
return
it
->
second
;
return
it
->
second
;
}
}
Attribute
OpDesc
::
GetAttrOrDefault
(
Attribute
OpDesc
::
GetNullableAttr
(
const
std
::
string
&
name
)
const
{
const
std
::
string
&
name
,
paddle
::
framework
::
Attribute
default_attr
)
const
{
auto
it
=
attrs_
.
find
(
name
);
auto
it
=
attrs_
.
find
(
name
);
if
(
it
!=
attrs_
.
end
())
{
if
(
it
!=
attrs_
.
end
())
{
return
it
->
second
;
return
it
->
second
;
}
else
{
}
else
{
return
default_attr
;
return
Attribute
()
;
}
}
}
}
...
...
paddle/fluid/framework/op_desc.h
浏览文件 @
fb370f44
...
@@ -78,8 +78,7 @@ class OpDesc {
...
@@ -78,8 +78,7 @@ class OpDesc {
Attribute
GetAttr
(
const
std
::
string
&
name
)
const
;
Attribute
GetAttr
(
const
std
::
string
&
name
)
const
;
Attribute
GetAttrOrDefault
(
const
std
::
string
&
name
,
Attribute
GetNullableAttr
(
const
std
::
string
&
name
)
const
;
Attribute
default_attr
)
const
;
int
GetBlockAttr
(
const
std
::
string
&
name
)
const
;
int
GetBlockAttr
(
const
std
::
string
&
name
)
const
;
...
...
python/paddle/fluid/backward.py
浏览文件 @
fb370f44
...
@@ -536,7 +536,7 @@ def append_backward(loss, parameter_list=None, no_grad_set=None,
...
@@ -536,7 +536,7 @@ def append_backward(loss, parameter_list=None, no_grad_set=None,
if
g
.
op
is
None
:
if
g
.
op
is
None
:
raise
ValueError
(
"Unexpected branch"
)
raise
ValueError
(
"Unexpected branch"
)
attr_val
=
[
p
.
name
]
attr_val
=
[
p
.
name
,
g
.
name
]
if
g
.
op
.
has_attr
(
op_role_var_attr_name
):
if
g
.
op
.
has_attr
(
op_role_var_attr_name
):
attr_val
.
extend
(
g
.
op
.
attr
(
op_role_var_attr_name
))
attr_val
.
extend
(
g
.
op
.
attr
(
op_role_var_attr_name
))
g
.
op
.
set_attr
(
op_role_var_attr_name
,
attr_val
)
g
.
op
.
set_attr
(
op_role_var_attr_name
,
attr_val
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录