Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
9c784a6c
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,发现更多精彩内容 >>
提交
9c784a6c
编写于
7月 10, 2020
作者:
M
Margaret_wangrui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
session code review
上级
0f4617a8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
16 deletion
+14
-16
mindspore/ccsrc/session/session_basic.cc
mindspore/ccsrc/session/session_basic.cc
+14
-16
未找到文件。
mindspore/ccsrc/session/session_basic.cc
浏览文件 @
9c784a6c
...
...
@@ -38,8 +38,8 @@
namespace
mindspore
{
namespace
session
{
static
std
::
shared_ptr
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
python_paras
_
;
void
ClearPythonParasMap
()
{
python_paras
_
=
nullptr
;
}
static
std
::
shared_ptr
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
python_paras
;
void
ClearPythonParasMap
()
{
python_paras
=
nullptr
;
}
namespace
{
const
int
kSummaryGetItem
=
2
;
...
...
@@ -387,17 +387,17 @@ ParameterPtr SessionBasic::CreateNewParameterFromParameter(const AnfNodePtr &anf
MS_EXCEPTION_IF_NULL
(
graph_inputs
);
ParameterPtr
new_parameter
=
nullptr
;
// if parameter's python parameter has been exist a backend parameter, reuse the exist parameter
if
(
python_paras
_
==
nullptr
)
{
python_paras
_
=
std
::
make_shared
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
();
if
(
python_paras
==
nullptr
)
{
python_paras
=
std
::
make_shared
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
();
}
auto
iter
=
python_paras
_
->
find
(
param_value
);
if
(
iter
!=
python_paras
_
->
end
())
{
auto
iter
=
python_paras
->
find
(
param_value
);
if
(
iter
!=
python_paras
->
end
())
{
new_parameter
=
iter
->
second
;
}
else
{
TraceManager
::
DebugTrace
(
std
::
make_shared
<
TraceCopy
>
(
anf
->
debug_info
()));
new_parameter
=
graph
->
NewParameter
(
anf
->
cast
<
ParameterPtr
>
());
if
(
param_value
!=
nullptr
)
{
(
*
python_paras
_
)[
param_value
]
=
new_parameter
;
(
*
python_paras
)[
param_value
]
=
new_parameter
;
}
TraceManager
::
EndTrace
();
}
...
...
@@ -469,7 +469,7 @@ CNodePtr SessionBasic::CreateNewCNode(const CNodePtr &cnode, bool valid_input, K
cnode_inputs
.
emplace_back
(
new_value_node
);
}
continue
;
}
else
if
(
anf
->
isa
<
Parameter
>
()
&&
AnfAlgo
::
GetOutputTensorNum
(
anf
)
==
1
)
{
}
else
if
(
anf
->
isa
<
Parameter
>
())
{
auto
new_parameter
=
CreateNewParameterFromParameter
(
anf
,
valid_input
,
graph
);
cnode_inputs
.
push_back
(
new_parameter
);
if
(
GetGraphIdByNode
(
anf
)
==
kInvalidGraphId
)
{
...
...
@@ -481,15 +481,13 @@ CNodePtr SessionBasic::CreateNewCNode(const CNodePtr &cnode, bool valid_input, K
}
else
if
(
optimize_depend
&&
input_idx
==
kDependAttachNodeIndex
)
{
cnode_inputs
.
push_back
(
origin_inputs
[
kRealInputIndexInDepend
]);
continue
;
}
else
if
(
anf
->
isa
<
AnfNode
>
())
{
}
else
{
*
from_other_graph
=
true
;
// the input node is a cnode from other graph
auto
parameter_from_cnode
=
CreateNewParameterFromCNode
(
anf
,
valid_input
,
graph
);
cnode_inputs
.
push_back
(
parameter_from_cnode
);
(
*
other_graph_cnode
)[
anf
]
=
parameter_from_cnode
;
continue
;
}
MS_LOG
(
EXCEPTION
)
<<
"Unexpected input["
<<
anf
->
DebugString
()
<<
"]"
;
}
TraceManager
::
DebugTrace
(
std
::
make_shared
<
TraceCopy
>
(
cnode
->
debug_info
()));
auto
new_cnode
=
graph
->
NewCNode
(
cnode_inputs
);
...
...
@@ -660,17 +658,17 @@ ParameterPtr SessionBasic::CreateNewParameter(const AnfNodePtr &anf, KernelGraph
auto
param_value
=
GetParamDefaultValue
(
anf
);
ParameterPtr
new_parameter
=
nullptr
;
if
(
python_paras
_
==
nullptr
)
{
python_paras
_
=
std
::
make_shared
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
();
if
(
python_paras
==
nullptr
)
{
python_paras
=
std
::
make_shared
<
std
::
map
<
ParamValuePtr
,
ParameterPtr
>>
();
}
auto
iter
=
python_paras
_
->
find
(
param_value
);
if
(
iter
!=
python_paras
_
->
end
())
{
auto
iter
=
python_paras
->
find
(
param_value
);
if
(
iter
!=
python_paras
->
end
())
{
new_parameter
=
iter
->
second
;
}
else
{
TraceManager
::
DebugTrace
(
std
::
make_shared
<
TraceCopy
>
(
anf
->
debug_info
()));
new_parameter
=
graph
->
NewParameter
(
anf
->
cast
<
ParameterPtr
>
());
if
(
param_value
!=
nullptr
)
{
(
*
python_paras
_
)[
param_value
]
=
new_parameter
;
(
*
python_paras
)[
param_value
]
=
new_parameter
;
}
TraceManager
::
EndTrace
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录