Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
402bb4c0
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看板
提交
402bb4c0
编写于
9月 01, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
9月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
!5461 add atomic clean for every communication op's inputs
Merge pull request !5461 from laiyongqiang/atomic_clean_every_master
上级
660aa8e6
0c1e3915
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
1 deletion
+46
-1
mindspore/ccsrc/backend/optimizer/mem_reuse/mem_reuse.h
mindspore/ccsrc/backend/optimizer/mem_reuse/mem_reuse.h
+1
-1
mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc
mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc
+45
-0
未找到文件。
mindspore/ccsrc/backend/optimizer/mem_reuse/mem_reuse.h
浏览文件 @
402bb4c0
...
@@ -49,7 +49,7 @@ class MemReuseUtil {
...
@@ -49,7 +49,7 @@ class MemReuseUtil {
}
}
MS_LOG
(
INFO
)
<<
"Total Dynamic Memory Size: "
<<
total_dy_size_
;
MS_LOG
(
INFO
)
<<
"Total Dynamic Memory Size: "
<<
total_dy_size_
;
MS_LOG
(
INFO
)
<<
"Total WorkSpace Memory Size: "
<<
total_workspace_size_
;
MS_LOG
(
INFO
)
<<
"Total WorkSpace Memory Size: "
<<
total_workspace_size_
;
MS_LOG
(
INFO
)
<<
"Total Reused WorkSpa
f
ce Memory Size: "
<<
total_reuseworkspace_size_
;
MS_LOG
(
INFO
)
<<
"Total Reused WorkSpace Memory Size: "
<<
total_reuseworkspace_size_
;
}
}
void
SetAllInfo
(
const
KernelGraph
*
graph
);
void
SetAllInfo
(
const
KernelGraph
*
graph
);
...
...
mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc
浏览文件 @
402bb4c0
...
@@ -205,6 +205,10 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) {
...
@@ -205,6 +205,10 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) {
}
}
// process output
// process output
std
::
vector
<
size_t
>
output_indexs
=
{};
std
::
vector
<
size_t
>
output_indexs
=
{};
if
(
AnfAlgo
::
HasNodeAttr
(
kAttrAtomicOutputIndexs
,
kernel_node
))
{
output_indexs
=
AnfAlgo
::
GetNodeAttr
<
std
::
vector
<
size_t
>>
(
kernel_node
,
kAttrAtomicOutputIndexs
);
}
for
(
size_t
i
=
0
;
i
<
output_num
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
output_num
;
++
i
)
{
auto
param_output
=
parameters_indexs
.
at
(
input_num
+
workspace_num
+
i
);
auto
param_output
=
parameters_indexs
.
at
(
input_num
+
workspace_num
+
i
);
if
(
param_output
==
1
)
{
if
(
param_output
==
1
)
{
...
@@ -212,7 +216,10 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) {
...
@@ -212,7 +216,10 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) {
MS_LOG
(
INFO
)
<<
"Atomic clear output index: "
<<
i
;
MS_LOG
(
INFO
)
<<
"Atomic clear output index: "
<<
i
;
}
}
}
}
if
(
!
output_indexs
.
empty
())
{
if
(
!
output_indexs
.
empty
())
{
std
::
set
<
size_t
>
s
(
output_indexs
.
begin
(),
output_indexs
.
end
());
output_indexs
.
assign
(
s
.
begin
(),
s
.
end
());
AnfAlgo
::
SetNodeAttr
(
kAttrAtomicOutputIndexs
,
MakeValue
(
output_indexs
),
kernel_node
);
AnfAlgo
::
SetNodeAttr
(
kAttrAtomicOutputIndexs
,
MakeValue
(
output_indexs
),
kernel_node
);
}
}
// process workspace
// process workspace
...
@@ -244,11 +251,49 @@ bool KernelBuild(const mindspore::session::KernelGraph *kernel_graph_ptr) {
...
@@ -244,11 +251,49 @@ bool KernelBuild(const mindspore::session::KernelGraph *kernel_graph_ptr) {
return
ret
;
return
ret
;
}
}
std
::
map
<
AnfNodePtr
,
std
::
vector
<
size_t
>>
GetCommunicationOpInputInfo
(
const
mindspore
::
session
::
KernelGraph
*
kernel_graph
)
{
std
::
map
<
AnfNodePtr
,
std
::
vector
<
size_t
>>
comm_input_info_map
;
for
(
auto
&
kernel
:
kernel_graph
->
execution_order
())
{
auto
input_num
=
AnfAlgo
::
GetInputTensorNum
(
kernel
);
if
(
mindspore
::
session
::
AnfRuntimeAlgorithm
::
IsCommunicationOp
(
kernel
))
{
for
(
size_t
i
=
0
;
i
<
input_num
;
i
++
)
{
auto
input_node
=
kernel
->
input
(
i
+
1
);
auto
kernel_input
=
AnfAlgo
::
VisitKernelWithReturnType
(
input_node
,
0
,
true
);
MS_LOG
(
INFO
)
<<
" Add atomic clean for single communication op input, comm:"
<<
kernel
->
fullname_with_scope
()
<<
" input_node: "
<<
kernel_input
.
first
->
fullname_with_scope
()
<<
" index: "
<<
kernel_input
.
second
;
auto
iter
=
comm_input_info_map
.
find
(
kernel_input
.
first
);
if
(
iter
!=
comm_input_info_map
.
end
())
{
iter
->
second
.
push_back
(
kernel_input
.
second
);
}
else
{
std
::
vector
<
size_t
>
indexes
=
{
kernel_input
.
second
};
comm_input_info_map
[
kernel_input
.
first
]
=
indexes
;
}
}
}
}
// remove duplicate index
for
(
auto
&
info
:
comm_input_info_map
)
{
std
::
set
<
size_t
>
s
(
info
.
second
.
begin
(),
info
.
second
.
end
());
info
.
second
.
assign
(
s
.
begin
(),
s
.
end
());
}
return
comm_input_info_map
;
}
void
KernelBuildPreprocess
(
mindspore
::
session
::
KernelGraph
*
kernel_graph
)
{
void
KernelBuildPreprocess
(
mindspore
::
session
::
KernelGraph
*
kernel_graph
)
{
MS_EXCEPTION_IF_NULL
(
kernel_graph
);
MS_EXCEPTION_IF_NULL
(
kernel_graph
);
std
::
vector
<
CNodePtr
>
new_nodes
;
std
::
vector
<
CNodePtr
>
new_nodes
;
std
::
map
<
AnfNodePtr
,
std
::
vector
<
size_t
>>
comm_input_info_map
=
GetCommunicationOpInputInfo
(
kernel_graph
);
for
(
const
auto
&
anf_node
:
kernel_graph
->
execution_order
())
{
for
(
const
auto
&
anf_node
:
kernel_graph
->
execution_order
())
{
std
::
string
apply_function_name
=
AnfAlgo
::
GetCNodeName
(
anf_node
);
std
::
string
apply_function_name
=
AnfAlgo
::
GetCNodeName
(
anf_node
);
if
(
comm_input_info_map
.
find
(
anf_node
)
!=
comm_input_info_map
.
end
())
{
auto
indexes
=
comm_input_info_map
[
anf_node
];
AnfAlgo
::
SetNodeAttr
(
kAttrAtomicOutputIndexs
,
MakeValue
(
indexes
),
anf_node
);
}
if
(
apply_function_name
==
prim
::
kPrimMaxPoolGrad
->
name
()
&&
if
(
apply_function_name
==
prim
::
kPrimMaxPoolGrad
->
name
()
&&
AnfAlgo
::
GetKernelType
(
anf_node
)
==
KernelType
::
AKG_KERNEL
)
{
AnfAlgo
::
GetKernelType
(
anf_node
)
==
KernelType
::
AKG_KERNEL
)
{
auto
clear_zero_prim
=
std
::
make_shared
<
Primitive
>
(
kClearZeroOpName
);
auto
clear_zero_prim
=
std
::
make_shared
<
Primitive
>
(
kClearZeroOpName
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录