Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
33b92ddd
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33b92ddd
编写于
3月 31, 2020
作者:
P
panyifeng
提交者:
高东海
4月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix parallel related valuenode merging error
上级
ada46fc2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
0 deletion
+29
-0
mindspore/ccsrc/parallel/step_parallel.cc
mindspore/ccsrc/parallel/step_parallel.cc
+1
-0
mindspore/ccsrc/pipeline/action.cc
mindspore/ccsrc/pipeline/action.cc
+28
-0
未找到文件。
mindspore/ccsrc/parallel/step_parallel.cc
浏览文件 @
33b92ddd
...
...
@@ -112,6 +112,7 @@ void InsertNode(const Operator& op, const CNodePtr& node, size_t index, const An
MS_EXCEPTION_IF_NULL
(
new_node_value
);
PrimitivePtr
new_node_prim
=
new_node_value
->
value
()
->
cast
<
PrimitivePtr
>
();
new_node_prim
->
set_instance_name
(
instance_name
);
new_node_prim
->
set_attr
(
"keep_value_node_input"
,
MakeValue
(
true
));
new_node
->
set_scope
(
scope
);
node_input
[
0
]
->
set_scope
(
scope
);
manager
->
SetEdge
(
node
,
SizeToInt
(
index
),
new_node
);
...
...
mindspore/ccsrc/pipeline/action.cc
浏览文件 @
33b92ddd
...
...
@@ -276,6 +276,31 @@ bool ExecuteAction(const ResourcePtr& res) {
return
true
;
}
// The parallel primitive related valuenode might be partitioned so that its value changes by device,
// that will result in a syncronization error due to different executing order.
// Here we temporarily avoid the problem by skipping valuenode merging used by parallel related primitive,
// the final solution will be proposed later as a parallel feature.
bool
KeepValueNodeDuplication
(
const
AnfNodePtr
&
value_node
,
const
ResourcePtr
&
res
)
{
auto
&
node_users
=
res
->
manager
()
->
node_users
();
auto
&
users
=
node_users
[
value_node
];
auto
used_by_keep_value_prim
=
std
::
any_of
(
users
.
begin
(),
users
.
end
(),
[](
const
std
::
pair
<
AnfNodePtr
,
int
>&
user
)
->
bool
{
MS_EXCEPTION_IF_NULL
(
user
.
first
);
auto
cnode
=
user
.
first
->
cast
<
CNodePtr
>
();
if
(
cnode
==
nullptr
)
{
return
false
;
}
auto
prim_node
=
cnode
->
input
(
0
);
if
(
IsValueNode
<
Primitive
>
(
prim_node
))
{
auto
prim
=
GetValue
<
PrimitivePtr
>
(
prim_node
->
cast
<
ValueNodePtr
>
()
->
value
());
// value_node is referenced by some parallel primitive
return
prim
->
HasAttr
(
"keep_value_node_input"
);
}
return
false
;
});
return
used_by_keep_value_prim
;
}
bool
RemoveValueNodeDuplicationsAction
(
const
ResourcePtr
&
res
)
{
if
(
res
->
func_graph
()
==
nullptr
)
{
MS_LOG
(
EXCEPTION
)
<<
"Remove value node duplications error."
;
...
...
@@ -287,6 +312,9 @@ bool RemoveValueNodeDuplicationsAction(const ResourcePtr& res) {
HashCache
hash_cache
;
HashValue
hashes
;
for
(
const
auto
&
value_pair
:
value_nodes
)
{
if
(
KeepValueNodeDuplication
(
value_pair
.
first
,
res
))
{
continue
;
}
TryToDoReplace
(
manager
.
get
(),
value_pair
.
first
,
&
hash_cache
,
&
hashes
);
}
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录