Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
bbedc027
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看板
提交
bbedc027
编写于
8月 21, 2020
作者:
X
xuanyue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
492e41a4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
31 addition
and
67 deletion
+31
-67
mindspore/lite/src/runtime/kernel/arm/fp32/topk.h
mindspore/lite/src/runtime/kernel/arm/fp32/topk.h
+0
-2
mindspore/lite/tools/anf_exporter/anf_exporter.cc
mindspore/lite/tools/anf_exporter/anf_exporter.cc
+27
-61
mindspore/lite/tools/anf_exporter/anf_exporter.h
mindspore/lite/tools/anf_exporter/anf_exporter.h
+2
-2
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc
...tools/converter/parser/tflite/tflite_activation_parser.cc
+1
-1
mindspore/lite/tools/time_profile/time_profile.cc
mindspore/lite/tools/time_profile/time_profile.cc
+1
-1
未找到文件。
mindspore/lite/src/runtime/kernel/arm/fp32/topk.h
浏览文件 @
bbedc027
...
...
@@ -28,8 +28,6 @@ class TopKCPUKernel : public LiteKernel {
const
mindspore
::
lite
::
PrimitiveC
*
primitive
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
,
ctx
,
primitive
)
{}
~
TopKCPUKernel
()
override
{
TopkParameter
*
parameter
=
reinterpret_cast
<
TopkParameter
*>
(
op_parameter_
);
free
(
parameter
->
topk_node_list_
);
}
int
Init
()
override
;
...
...
mindspore/lite/tools/anf_exporter/anf_exporter.cc
浏览文件 @
bbedc027
...
...
@@ -55,60 +55,6 @@ void AnfExporter::RemoveIfMakeTuple(const CNodePtr &cnode) {
}
}
bool
AnfExporter
::
RemoveIfTupleGetItem
(
const
CNodePtr
&
cnode
)
{
MS_ASSERT
(
cnode
!=
nullptr
);
bool
has_tuple_get_item
=
false
;
std
::
vector
<
AnfNodePtr
>
inputs
;
inputs
.
clear
();
inputs
.
emplace_back
(
cnode
->
input
(
0
));
for
(
size_t
i
=
1
;
i
<
cnode
->
inputs
().
size
();
++
i
)
{
AnfNodePtr
input_node
=
cnode
->
input
(
i
);
if
(
!
input_node
->
isa
<
CNode
>
())
{
inputs
.
emplace_back
(
cnode
->
input
(
i
));
continue
;
}
auto
tuple_get_item_node
=
utils
::
cast
<
CNodePtr
>
(
input_node
);
if
(
IsPrimitiveCNode
(
tuple_get_item_node
,
schema
::
PrimitiveType_TupleGetItem
))
{
has_tuple_get_item
=
true
;
inputs
.
emplace_back
(
tuple_get_item_node
->
input
(
1
));
AnfNodePtr
indexNode
=
tuple_get_item_node
->
input
(
2
);
if
(
!
utils
::
isa
<
ValueNode
>
(
indexNode
))
{
MS_LOG
(
ERROR
)
<<
"TupleGetItem's input 2 is not valuenode"
;
return
false
;
}
auto
value_node
=
utils
::
cast
<
ValueNodePtr
>
(
indexNode
);
}
else
{
inputs
.
emplace_back
(
cnode
->
input
(
i
));
}
}
if
(
has_tuple_get_item
)
{
cnode
->
set_inputs
(
inputs
);
}
return
true
;
}
bool
AnfExporter
::
AddOutPutIfReturn
(
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
const
CNodePtr
&
cnode
)
{
MS_ASSERT
(
meta_graphT
!=
nullptr
);
MS_ASSERT
(
cnode
!=
nullptr
);
for
(
size_t
i
=
1
;
i
<
cnode
->
inputs
().
size
();
++
i
)
{
auto
input_anode
=
cnode
->
input
(
i
);
if
(
!
input_anode
->
isa
<
CNode
>
())
{
MS_LOG
(
ERROR
)
<<
"Node of Return's input is not CNode"
;
return
false
;
}
auto
input_cnode
=
utils
::
cast
<
CNodePtr
>
(
input_anode
);
std
::
string
input_name
=
input_anode
->
fullname_with_scope
();
auto
iter
=
node_id_map_
.
find
(
input_name
);
if
(
iter
==
node_id_map_
.
end
())
{
MS_LOG
(
ERROR
)
<<
"Could not find output node"
;
return
false
;
}
auto
graph_output
=
iter
->
second
;
meta_graphT
->
outputIndex
.
emplace_back
(
graph_output
);
}
return
true
;
}
int
AnfExporter
::
ConvertQuantParam
(
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graph
,
const
std
::
shared_ptr
<
PrimitiveTValue
>
primitive
,
const
std
::
unique_ptr
<
schema
::
CNodeT
>
&
dst_node
)
{
...
...
@@ -182,6 +128,28 @@ void AnfExporter::SetGraphInputIndex(const std::unique_ptr<schema::MetaGraphT> &
}
}
void
AnfExporter
::
SetGraphoutputIndex
(
const
CNodePtr
&
cnode
,
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
schema
::
CNodeT
*
return_node
)
{
MS_ASSERT
(
nullptr
!=
meta_graph
);
MS_ASSERT
(
nullptr
!=
return_node
);
for
(
size_t
i
=
1
;
i
<
cnode
->
inputs
().
size
();
i
++
)
{
auto
input_node
=
cnode
->
input
(
i
);
if
(
input_node
->
isa
<
CNode
>
())
{
auto
ret
=
ConvertInputCNode
(
input_node
,
return_node
);
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"obtain outputs failed"
;
return
;
}
}
else
{
MS_LOG
(
ERROR
)
<<
"the node "
<<
input_node
->
fullname_with_scope
().
c_str
()
<<
"is not output node"
;
return
;
}
}
for
(
size_t
i
=
0
;
i
<
return_node
->
inputIndex
.
size
();
++
i
)
{
meta_graphT
->
outputIndex
.
push_back
(
return_node
->
inputIndex
[
i
]);
}
}
schema
::
MetaGraphT
*
AnfExporter
::
Export
(
const
FuncGraphPtr
&
func_graph
)
{
auto
cnodes
=
func_graph
->
GetOrderedCnodes
();
auto
meta_graphT
=
std
::
make_unique
<
schema
::
MetaGraphT
>
();
...
...
@@ -202,24 +170,22 @@ schema::MetaGraphT *AnfExporter::Export(const FuncGraphPtr &func_graph) {
}
RemoveIfMakeTuple
(
cnode
);
auto
node
=
std
::
make_unique
<
schema
::
CNodeT
>
();
if
(
primT
->
value
.
type
==
schema
::
PrimitiveType_Return
)
{
AddOutPutIfReturn
(
meta_graphT
,
cnode
);
node
->
name
=
"return_node"
;
SetGraphoutputIndex
(
cnode
,
meta_graphT
,
node
.
get
());
continue
;
}
auto
node
=
std
::
make_unique
<
schema
::
CNodeT
>
();
node
->
name
=
cnode
->
fullname_with_scope
();
node
->
nodeType
=
schema
::
NodeType_CNode
;
node
->
name
=
cnode
->
fullname_with_scope
();
node
->
primitive
=
std
::
unique_ptr
<
schema
::
PrimitiveT
>
(
primT
);
auto
ret
=
SetOpInputNode
(
cnode
,
meta_graphT
,
node
.
get
());
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"SetOpInputNode failed"
;
return
nullptr
;
}
SetOpOutputNode
(
cnode
,
meta_graphT
,
node
.
get
());
ret
=
ConvertQuantParam
(
meta_graphT
,
primitiveT_value
,
node
);
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"ConvertQuantParam failed"
;
...
...
mindspore/lite/tools/anf_exporter/anf_exporter.h
浏览文件 @
bbedc027
...
...
@@ -36,8 +36,6 @@ class AnfExporter {
int
SetOpInputNode
(
const
CNodePtr
&
cnode
,
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
schema
::
CNodeT
*
fb_node
);
void
RemoveIfMakeTuple
(
const
CNodePtr
&
cnode
);
bool
RemoveIfTupleGetItem
(
const
CNodePtr
&
cnode
);
bool
AddOutPutIfReturn
(
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
const
CNodePtr
&
cnode
);
protected:
int
ConvertInputCNode
(
const
std
::
shared_ptr
<
AnfNode
>
input_anode
,
schema
::
CNodeT
*
output_cnode
);
...
...
@@ -46,6 +44,8 @@ class AnfExporter {
int
ConvertInputValueNode
(
std
::
shared_ptr
<
AnfNode
>
input_anode
,
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
schema
::
CNodeT
*
output_cnode
);
void
SetGraphInputIndex
(
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
);
void
SetGraphoutputIndex
(
const
CNodePtr
&
cnode
,
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graphT
,
schema
::
CNodeT
*
return_node
);
bool
IsPrimitiveCNode
(
const
AnfNodePtr
&
node
,
schema
::
PrimitiveType
type
);
int
ConvertQuantParam
(
const
std
::
unique_ptr
<
schema
::
MetaGraphT
>
&
meta_graph
,
const
std
::
shared_ptr
<
PrimitiveTValue
>
primitive
,
...
...
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc
浏览文件 @
bbedc027
...
...
@@ -63,7 +63,7 @@ STATUS TfliteActivationParser::Parse(const std::unique_ptr<tflite::OperatorT> &t
attr
->
type
=
schema
::
ActivationType_SIGMOID
;
}
else
if
(
std
::
strcmp
(
node_name
,
"HardSwish"
)
==
0
)
{
MS_LOG
(
DEBUG
)
<<
"parse TfliteHardSwishParser"
;
attr
->
type
=
schema
::
ActivationType_
SIGMOID
;
attr
->
type
=
schema
::
ActivationType_
HSWISH
;
}
else
if
(
std
::
strcmp
(
node_name
,
"LeakyRelu"
)
==
0
)
{
const
auto
&
tflite_attr
=
tflite_op
->
builtin_options
.
AsLeakyReluOptions
();
if
(
tflite_attr
==
nullptr
)
{
...
...
mindspore/lite/tools/time_profile/time_profile.cc
浏览文件 @
bbedc027
...
...
@@ -273,7 +273,7 @@ int TimeProfile::PrintResult(const std::vector<std::string> &title,
columnLenMax
.
at
(
i
)
=
printBuf
.
size
();
}
printBuf
.
resize
(
columnLenMax
.
at
(
i
),
' '
);
printf
(
"%s"
,
printBuf
.
c_str
());
printf
(
"%s
\t
"
,
printBuf
.
c_str
());
}
printf
(
"
\n
"
);
for
(
size_t
i
=
0
;
i
<
rows
.
size
();
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录