Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
1f8b00df
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看板
提交
1f8b00df
编写于
7月 03, 2020
作者:
Z
zhoufeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix empty graph dump ir
Signed-off-by:
N
zhoufeng
<
zhoufeng54@huawei.com
>
上级
a342a615
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
21 addition
and
15 deletion
+21
-15
mindspore/ccsrc/session/anf_runtime_algorithm.cc
mindspore/ccsrc/session/anf_runtime_algorithm.cc
+4
-1
mindspore/ccsrc/session/ascend_control_parser.cc
mindspore/ccsrc/session/ascend_control_parser.cc
+7
-6
mindspore/ccsrc/session/ascend_control_parser.h
mindspore/ccsrc/session/ascend_control_parser.h
+1
-1
mindspore/ccsrc/session/ascend_session.cc
mindspore/ccsrc/session/ascend_session.cc
+3
-0
mindspore/ccsrc/session/kernel_graph.cc
mindspore/ccsrc/session/kernel_graph.cc
+4
-6
tests/ut/cpp/session/anf_runtime_algorithm_test.cc
tests/ut/cpp/session/anf_runtime_algorithm_test.cc
+2
-1
未找到文件。
mindspore/ccsrc/session/anf_runtime_algorithm.cc
浏览文件 @
1f8b00df
...
...
@@ -694,7 +694,7 @@ void AnfRuntimeAlgorithm::SetOutputInferTypeAndShape(const std::vector<TypeId> &
MS_LOG
(
EXCEPTION
)
<<
"Types size "
<<
types
.
size
()
<<
"should be same with shapes size "
<<
shapes
.
size
();
}
if
(
shapes
.
empty
())
{
MS_LOG
(
EXCEPTION
)
<<
"Illegal empty output_types_shapes"
;
node
->
set_abstract
(
std
::
make_shared
<
abstract
::
AbstractNone
>
())
;
}
else
if
(
shapes
.
size
()
==
1
)
{
// single output handle
std
::
vector
<
int
>
shape_int
;
...
...
@@ -1012,6 +1012,9 @@ std::vector<KernelGraphPtr> AnfRuntimeAlgorithm::GetCallNodeKernelGraph(const CN
auto
get_switch_kernel_graph
=
[
switch_node
](
size_t
input_index
)
->
KernelGraphPtr
{
auto
partial
=
switch_node
->
input
(
input_index
);
MS_EXCEPTION_IF_NULL
(
partial
);
if
(
IsValueNode
<
KernelGraph
>
(
partial
))
{
return
GetValueNode
<
KernelGraphPtr
>
(
partial
);
}
auto
partial_cnode
=
partial
->
cast
<
CNodePtr
>
();
MS_EXCEPTION_IF_NULL
(
partial_cnode
);
auto
graph_node
=
partial_cnode
->
input
(
1
);
...
...
mindspore/ccsrc/session/ascend_control_parser.cc
浏览文件 @
1f8b00df
...
...
@@ -386,8 +386,7 @@ void AscendControlParser::RecurseSwitch(NotNull<KernelGraphPtr> kg, NotNull<CNod
origin_switch_inputs
[
kCNodeSwitchCond
]};
for
(
size_t
i
=
kCNodeSwitchCond
+
1
;
i
<
kCNodeSwitchLength
;
++
i
)
{
// 3.1 branch kernel graph and args
KernelGraphPtr
branch_fg
;
std
::
tie
(
std
::
ignore
,
branch_fg
)
=
ParsePartial
(
NOT_NULL
(
origin_switch_inputs
[
i
]));
KernelGraphPtr
branch_fg
=
ParsePartial
(
NOT_NULL
(
origin_switch_inputs
[
i
]));
// 3.2 recurse sub graph
CNodePtr
branch_label
=
ProcessKernelGraph
(
NOT_NULL
(
branch_fg
),
cur_node
,
back_label
,
memo
);
new_switch_inputs
.
push_back
(
branch_label
);
...
...
@@ -432,8 +431,7 @@ void AscendControlParser::RecurseSwitchLayer(NotNull<KernelGraphPtr> kg, NotNull
origin_switch_inputs
[
kCNodeSwitchCond
]};
for
(
size_t
i
=
0
;
i
<
branch_partial
.
size
();
++
i
)
{
// 3.1 branch kernel graph and args
KernelGraphPtr
branch_fg
;
std
::
tie
(
std
::
ignore
,
branch_fg
)
=
ParsePartial
(
NOT_NULL
(
origin_switch_inputs
[
i
]));
KernelGraphPtr
branch_fg
=
ParsePartial
(
NOT_NULL
(
origin_switch_inputs
[
i
]));
// 3.2 recurse sub graph
CNodePtr
branch_label
=
ProcessKernelGraph
(
NOT_NULL
(
branch_fg
),
cur_node
,
back_label
,
memo
);
new_switch_inputs
.
push_back
(
branch_label
);
...
...
@@ -444,8 +442,11 @@ void AscendControlParser::RecurseSwitchLayer(NotNull<KernelGraphPtr> kg, NotNull
MS_LOG
(
INFO
)
<<
"Succeed processing switch layer "
<<
cur_node
->
DebugString
();
}
std
::
tuple
<
CNodePtr
,
KernelGraphPtr
>
AscendControlParser
::
ParsePartial
(
NotNull
<
AnfNodePtr
>
node
)
{
KernelGraphPtr
AscendControlParser
::
ParsePartial
(
NotNull
<
AnfNodePtr
>
node
)
{
if
(
!
node
.
get
()
->
isa
<
CNode
>
())
{
if
(
IsValueNode
<
KernelGraph
>
(
node
))
{
return
GetValueNode
<
KernelGraphPtr
>
(
node
);
}
MS_LOG
(
EXCEPTION
)
<<
"Switch branches must be partial, node: "
<<
node
->
DebugString
();
}
// 2.1 branch kernel graph and args
...
...
@@ -460,7 +461,7 @@ std::tuple<CNodePtr, KernelGraphPtr> AscendControlParser::ParsePartial(NotNull<A
MS_LOG
(
EXCEPTION
)
<<
"Index out of range:"
<<
partial_inputs
.
size
()
<<
"."
;
}
auto
branch_kg
=
GetValueNode
<
KernelGraphPtr
>
(
partial_inputs
[
kCNodePartialFunc
]);
return
{
partial_cnode
,
branch_kg
}
;
return
branch_kg
;
}
void
AscendControlParser
::
InsertMultipleAssignToGraph
(
NotNull
<
KernelGraphPtr
>
from_graph
,
...
...
mindspore/ccsrc/session/ascend_control_parser.h
浏览文件 @
1f8b00df
...
...
@@ -52,7 +52,7 @@ class AscendControlParser {
static
void
LinkParentGraph
(
NotNull
<
KernelGraphPtr
>
kg
,
const
CNodePtr
&
from_graph_call_node
,
const
CNodePtr
&
last_label
);
static
std
::
tuple
<
CNodePtr
,
KernelGraphPtr
>
ParsePartial
(
NotNull
<
AnfNodePtr
>
node
);
static
KernelGraphPtr
ParsePartial
(
NotNull
<
AnfNodePtr
>
node
);
static
void
InsertMultipleAssignToGraph
(
NotNull
<
KernelGraphPtr
>
from_graph
,
NotNull
<
KernelGraphPtr
>
to_graph
,
NotNull
<
AnfNodePtr
>
from
,
NotNull
<
AnfNodePtr
>
to
);
...
...
mindspore/ccsrc/session/ascend_session.cc
浏览文件 @
1f8b00df
...
...
@@ -247,6 +247,9 @@ static void UpdateRealInput(NotNull<KernelGraphPtr> graph, bool split_flag) {
MS_EXCEPTION_IF_NULL
(
switch_cnode
);
auto
partial
=
switch_cnode
->
input
(
input_index
);
MS_EXCEPTION_IF_NULL
(
partial
);
if
(
IsValueNode
<
KernelGraph
>
(
partial
))
{
return
{};
}
auto
partial_cnode
=
partial
->
cast
<
CNodePtr
>
();
MS_EXCEPTION_IF_NULL
(
partial_cnode
);
auto
ret
=
std
::
vector
<
AnfNodePtr
>
(
partial_cnode
->
inputs
().
begin
()
+
2
,
partial_cnode
->
inputs
().
end
());
...
...
mindspore/ccsrc/session/kernel_graph.cc
浏览文件 @
1f8b00df
...
...
@@ -357,18 +357,16 @@ ParameterPtr KernelGraph::NewParameter(const ParameterPtr ¶meter) {
}
else
{
kernel_info
->
SetFeatureMapFlag
(
true
);
}
// if output is a tuple tensor,now can use for loop to handle tuple tensor
output_tensor_num
=
AnfAlgo
::
GetOutputTensorNum
(
parameter
);
}
new_parameter
->
set_kernel_info
(
kernel_info
);
// create kernel_build_info for new parameter
auto
kernel_build_info_builder
=
std
::
make_shared
<
kernel
::
KernelBuildInfo
::
KernelBuildInfoBuilder
>
();
// create init data type,
std
::
vector
<
TypeId
>
init_data_type
=
{};
for
(
size_t
i
=
0
;
i
<
output_tensor_num
;
i
++
)
{
TypeId
infer_data_type
=
AnfAlgo
::
GetOutputInferDataType
(
new_parameter
,
i
);
TypeId
infer_data_type
=
AnfAlgo
::
GetOutputInferDataType
(
new_parameter
,
0
);
init_data_type
.
push_back
(
AnfAlgo
::
IsParameterWeight
(
new_parameter
)
?
kTypeUnknown
:
infer_data_type
);
}
// set the format of parameter to DEFAULT_FORMAT
kernel_build_info_builder
->
SetOutputsFormat
(
std
::
vector
<
std
::
string
>
(
output_tensor_num
,
kOpFormat_DEFAULT
));
// set parameter initaial device data type
...
...
tests/ut/cpp/session/anf_runtime_algorithm_test.cc
浏览文件 @
1f8b00df
...
...
@@ -590,7 +590,8 @@ TEST_F(AnfRuntimeAlgorithmTest, SetOutputInferTypeAndShape) {
std
::
vector
<
TypeId
>
none_types
=
{};
std
::
vector
<
std
::
vector
<
size_t
>>
none_shapes
=
{};
EXPECT_THROW
(
AnfAlgo
::
SetOutputInferTypeAndShape
(
none_types
,
none_shapes
,
nullptr
),
std
::
runtime_error
);
EXPECT_THROW
(
AnfAlgo
::
SetOutputInferTypeAndShape
(
none_types
,
none_shapes
,
add
.
get
()),
std
::
runtime_error
);
AnfAlgo
::
SetOutputInferTypeAndShape
(
none_types
,
none_shapes
,
add
.
get
());
EXPECT_EQ
((
*
add
->
abstract
()),
abstract
::
AbstractNone
());
// set single input
std
::
vector
<
TypeId
>
single_types
=
{
kFloat32
->
type_id
()};
std
::
vector
<
std
::
vector
<
size_t
>>
single_shapes
=
{{
2
,
32
,
224
,
224
}};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录