Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
6e934530
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e934530
编写于
5月 14, 2020
作者:
C
chenfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new compile graph of new control sink
上级
ebdba965
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
82 addition
and
0 deletion
+82
-0
mindspore/ccsrc/session/ascend_session.cc
mindspore/ccsrc/session/ascend_session.cc
+37
-0
mindspore/ccsrc/session/ascend_session.h
mindspore/ccsrc/session/ascend_session.h
+9
-0
mindspore/ccsrc/session/kernel_graph.cc
mindspore/ccsrc/session/kernel_graph.cc
+18
-0
mindspore/ccsrc/session/kernel_graph.h
mindspore/ccsrc/session/kernel_graph.h
+14
-0
mindspore/ccsrc/session/session_basic.cc
mindspore/ccsrc/session/session_basic.cc
+2
-0
mindspore/ccsrc/session/session_basic.h
mindspore/ccsrc/session/session_basic.h
+2
-0
未找到文件。
mindspore/ccsrc/session/ascend_session.cc
浏览文件 @
6e934530
...
...
@@ -138,6 +138,43 @@ GraphId AscendSession::CompileGraph(const AnfNodePtrList &lst, const AnfNodePtrL
return
graph_id
;
}
GraphId
AscendSession
::
CompileGraph
(
const
FuncGraphPtr
&
func_graph
)
{
MS_LOG
(
INFO
)
<<
"start"
;
auto
graph
=
ConstructKernelGraph
(
func_graph
);
// split switch
SplitSwitch
(
graph
.
get
());
// insert goto labels and label_sets
LinkChildGraphs
(
graph
.
get
());
// resource initialize
InitRuntimeResource
();
// ir fusion
IRFusion
(
graph
);
// kernel select
SelectKernelGraphKernel
(
*
graph
);
// convert model of predict module
ConvertPredictModel
(
graph
);
// hardware optimize
HardwareOptimizeGraphs
(
graph
);
// adjust kernel
AdjustKernel
(
graph
);
// root graph valiate,include genearte execute order and so on
RootGraphExecutorValidate
(
graph
.
get
());
// assign stream
AssignStream
(
graph
);
// build kernel if node is cnode
BuildKernel
(
graph
);
// alloc mem
MemoryAlloc
(
graph
.
get
());
// task generate
GenerateTaskInfo
(
graph
);
// load task into device
LoadTask
(
graph
);
// return the graph id to backend
auto
graph_id
=
graph
->
graph_id
();
MS_LOG
(
INFO
)
<<
"Compile graph "
<<
graph_id
<<
" success"
;
return
graph_id
;
}
void
AscendSession
::
BuildGraph
(
GraphId
graph_id
)
{
MS_LOG
(
INFO
)
<<
"start"
;
auto
graph
=
GetGraph
(
graph_id
);
...
...
mindspore/ccsrc/session/ascend_session.h
浏览文件 @
6e934530
...
...
@@ -42,6 +42,7 @@ class AscendSession : public SessionBasic {
context_
=
std
::
make_shared
<
Context
>
(
kAscendDevice
,
device_id
);
}
GraphId
CompileGraph
(
const
AnfNodePtrList
&
lst
,
const
AnfNodePtrList
&
outputs
)
override
;
GraphId
CompileGraph
(
const
FuncGraphPtr
&
func_graph
)
override
;
void
RunGraph
(
const
GraphId
&
graph_id
,
const
std
::
vector
<
tensor
::
TensorPtr
>
&
inputs
,
VectorRef
*
outputs
)
override
;
void
BuildGraph
(
GraphId
)
override
;
void
BuildOp
(
const
OpRunInfo
&
op_run_info
,
const
GraphInfo
&
graph_info
,
...
...
@@ -92,6 +93,14 @@ class AscendSession : public SessionBasic {
void
SetFinalGraphOutput
(
const
ValuePtr
&
value
);
void
SetFinalGraphOutput
(
const
VectorRef
&
vec_output
);
void
SplitSwitch
(
KernelGraph
*
graph
)
{}
void
LinkChildGraphs
(
KernelGraph
*
graph
)
{}
void
IRFusion
(
const
KernelGraphPtr
&
graph
)
{}
void
SelectKernelGraphKernel
(
const
KernelGraph
&
graph
)
{}
void
ConvertPredictModel
(
const
KernelGraphPtr
graph
)
{}
void
HardwareOptimizeGraphs
(
const
KernelGraphPtr
graph
)
{}
void
RootGraphExecutorValidate
(
KernelGraph
*
graph
)
{}
// merge execution order list of child graphs
void
MergeGraphExecOrder
();
// insert assion op to sync data bettween different graphs
...
...
mindspore/ccsrc/session/kernel_graph.cc
浏览文件 @
6e934530
...
...
@@ -580,5 +580,23 @@ void KernelGraph::UpdateExecuteKernelStreamLabel() {
AnfAlgo
::
SetStreamDistinctionLabel
(
stream_distinction_label_
,
kernel
.
get
());
}
}
void
KernelGraph
::
UpdateChildGraphOrder
()
{}
std
::
vector
<
std
::
shared_ptr
<
KernelGraph
>>
KernelGraph
::
GetLeafGraphOrder
()
{
std
::
vector
<
std
::
shared_ptr
<
KernelGraph
>>
leaf_graph_order
;
if
(
IsLeafGraph
())
{
leaf_graph_order
.
push_back
(
shared_from_this
()
->
cast
<
KernelGraphPtr
>
());
}
else
{
for
(
const
auto
&
child_graph
:
child_graph_order_
)
{
MS_EXCEPTION_IF_NULL
(
child_graph
);
auto
child_leaf_graph_order
=
child_graph
->
GetLeafGraphOrder
();
std
::
copy
(
child_leaf_graph_order
.
begin
(),
child_leaf_graph_order
.
end
(),
std
::
back_inserter
(
leaf_graph_order
));
}
}
return
leaf_graph_order
;
}
bool
KernelGraph
::
IsLeafGraph
()
const
{
return
child_graph_order_
.
empty
();
}
}
// namespace session
}
// namespace mindspore
mindspore/ccsrc/session/kernel_graph.h
浏览文件 @
6e934530
...
...
@@ -99,6 +99,14 @@ class KernelGraph : public FuncGraph {
uint32_t
stream_distinction_label
()
{
return
stream_distinction_label_
;
}
// refresh execute kernel stream label
void
UpdateExecuteKernelStreamLabel
();
// calculate the leaf graph order of root graph
std
::
vector
<
std
::
shared_ptr
<
KernelGraph
>>
GetLeafGraphOrder
();
// update the child graph order of graph
void
UpdateChildGraphOrder
();
// get the child graph of current graph
std
::
vector
<
std
::
shared_ptr
<
KernelGraph
>>
child_graph_order
()
const
{
return
child_graph_order_
;
}
// checkout whether current graph is leaf graph
bool
IsLeafGraph
()
const
;
private:
// remove value node form graph
...
...
@@ -136,6 +144,12 @@ class KernelGraph : public FuncGraph {
bool
executable_
;
// valid inputs
std
::
vector
<
bool
>
valid_inputs_
;
// new members for control sink process
// all child grahs refers to partial node
std
::
map
<
AnfNodePtr
,
std
::
shared_ptr
<
KernelGraph
>>
node_to_child_graphs_
;
// child graph execute order in root graph
std
::
vector
<
std
::
shared_ptr
<
KernelGraph
>>
child_graph_order_
;
};
}
// namespace session
using
KernelGraphPtr
=
std
::
shared_ptr
<
session
::
KernelGraph
>
;
...
...
mindspore/ccsrc/session/session_basic.cc
浏览文件 @
6e934530
...
...
@@ -494,6 +494,8 @@ KernelGraphPtr SessionBasic::ConstructKernelGraph(const AnfNodePtrList &lst, con
return
graph
;
}
std
::
shared_ptr
<
KernelGraph
>
SessionBasic
::
ConstructKernelGraph
(
const
FuncGraphPtr
&
)
{
return
nullptr
;
}
// run graph steps
void
SessionBasic
::
LoadInputData
(
const
std
::
shared_ptr
<
KernelGraph
>
&
kernel_graph
,
const
std
::
vector
<
tensor
::
TensorPtr
>
&
inputs_const
)
const
{
...
...
mindspore/ccsrc/session/session_basic.h
浏览文件 @
6e934530
...
...
@@ -57,6 +57,7 @@ class SessionBasic {
virtual
~
SessionBasic
()
{
summary_callback_
=
nullptr
;
}
virtual
GraphId
CompileGraph
(
const
AnfNodePtrList
&
lst
,
const
AnfNodePtrList
&
outputs
)
=
0
;
virtual
GraphId
CompileGraph
(
const
FuncGraphPtr
&
)
{
return
kInvalidGraphId
;
}
// build graph, used to handle multiple child graphs
virtual
void
BuildGraph
(
GraphId
)
{}
...
...
@@ -72,6 +73,7 @@ class SessionBasic {
virtual
void
RegisterSummaryCallBackFunc
(
const
CallBackFunc
&
callback
);
std
::
shared_ptr
<
KernelGraph
>
ConstructKernelGraph
(
const
AnfNodePtrList
&
lst
,
const
AnfNodePtrList
&
outputs
);
std
::
shared_ptr
<
KernelGraph
>
ConstructKernelGraph
(
const
FuncGraphPtr
&
func_graph
);
CNodePtr
CreateNewCNode
(
const
CNodePtr
&
cnode
,
bool
valid_input
,
KernelGraph
*
graph
,
bool
*
from_other_graph
,
std
::
unordered_map
<
AnfNodePtr
,
AnfNodePtr
>
*
other_graph_cnode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录