Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
ef35e2d9
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看板
提交
ef35e2d9
编写于
6月 12, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
6月 12, 2020
浏览文件
操作
浏览文件
下载
差异文件
!2002 Add dump ir function in binary format
Merge pull request !2002 from leopz/test_dump
上级
47404538
c45f4d22
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
657 addition
and
6 deletion
+657
-6
mindspore/ccsrc/debug/anf_ir_utils.cc
mindspore/ccsrc/debug/anf_ir_utils.cc
+1
-1
mindspore/ccsrc/debug/anf_ir_utils.h
mindspore/ccsrc/debug/anf_ir_utils.h
+2
-0
mindspore/ccsrc/onnx/ir_exporter.cc
mindspore/ccsrc/onnx/ir_exporter.cc
+631
-0
mindspore/ccsrc/pipeline/pipeline.cc
mindspore/ccsrc/pipeline/pipeline.cc
+10
-1
mindspore/train/serialization.py
mindspore/train/serialization.py
+10
-2
tests/ut/cpp/stub/anf_ir/dump_proto_stub.cc
tests/ut/cpp/stub/anf_ir/dump_proto_stub.cc
+3
-2
未找到文件。
mindspore/ccsrc/debug/anf_ir_utils.cc
浏览文件 @
ef35e2d9
...
...
@@ -1566,7 +1566,7 @@ class IrParser {
return
lexer_
.
GetNextToken
();
}
else
if
(
type
==
"Tuple"
)
{
return
ParseTypeVector
(
func_graph
,
lexer_
.
GetNextToken
(),
type
,
ptr
);
}
else
if
(
type
==
"
Array
"
)
{
}
else
if
(
type
==
"
Tensor
"
)
{
return
ParseTypeArray
(
func_graph
,
lexer_
.
GetNextToken
(),
ptr
);
}
else
if
(
type
==
"List"
)
{
return
ParseTypeVector
(
func_graph
,
lexer_
.
GetNextToken
(),
type
,
ptr
);
...
...
mindspore/ccsrc/debug/anf_ir_utils.h
浏览文件 @
ef35e2d9
...
...
@@ -118,6 +118,8 @@ std::string GetFuncGraphProtoString(const FuncGraphPtr &func_graph);
void
DumpIRProto
(
const
FuncGraphPtr
&
func_graph
,
const
std
::
string
&
suffix
);
std
::
string
GetOnnxProtoString
(
const
FuncGraphPtr
&
func_graph
);
std
::
string
GetBinaryProtoString
(
const
FuncGraphPtr
&
func_graph
);
}
// namespace mindspore
#endif // MINDSPORE_CCSRC_DEBUG_ANF_IR_UTILS_H_
mindspore/ccsrc/onnx/ir_exporter.cc
0 → 100644
浏览文件 @
ef35e2d9
此差异已折叠。
点击以展开。
mindspore/ccsrc/pipeline/pipeline.cc
浏览文件 @
ef35e2d9
...
...
@@ -59,6 +59,7 @@ using mindspore::abstract::AbstractTuplePtr;
const
char
IR_TYPE_ANF
[]
=
"anf_ir"
;
const
char
IR_TYPE_ONNX
[]
=
"onnx_ir"
;
const
char
IR_TYPE_BINARY
[]
=
"binary_ir"
;
ExecutorPyPtr
ExecutorPy
::
executor_
=
nullptr
;
std
::
mutex
ExecutorPy
::
instance_lock_
;
...
...
@@ -212,6 +213,14 @@ py::bytes ExecutorPy::GetFuncGraphProto(const std::string &phase, const std::str
return
proto_str
;
}
if
(
ir_type
==
IR_TYPE_BINARY
)
{
std
::
string
proto_str
=
GetBinaryProtoString
(
fg_ptr
);
if
(
proto_str
.
empty
())
{
MS_LOG
(
EXCEPTION
)
<<
"Graph proto is empty."
;
}
return
proto_str
;
}
MS_LOG
(
EXCEPTION
)
<<
"Unknown ir type: "
<<
ir_type
;
}
...
...
@@ -506,7 +515,6 @@ void RunPipelineAction(const ActionItem &action, pipeline::ResourcePtr resource,
// when in loading anf ir mode, action `parse` do nothing
if
(
action
.
first
==
"parse"
)
{
parse
::
PythonAdapter
::
SetPythonEnvFlag
(
true
);
return
;
}
...
...
@@ -566,6 +574,7 @@ void Pipeline::Run() {
draw
::
Draw
(
base_name
+
".dot"
,
graph
);
// generate IR file in human readable format
DumpIR
(
base_name
+
".ir"
,
graph
);
// generate IR file in a heavily commented format, which can also be reloaded
if
(
action
.
first
!=
"parse"
)
{
ExportIR
(
base_name
+
".dat"
,
std
::
to_string
(
i
),
graph
);
...
...
mindspore/train/serialization.py
浏览文件 @
ef35e2d9
...
...
@@ -398,17 +398,18 @@ def export(net, *inputs, file_name, file_format='GEIR'):
net (Cell): MindSpore network.
inputs (Tensor): Inputs of the `net`.
file_name (str): File name of model to export.
file_format (str): MindSpore currently supports 'GEIR', 'ONNX'
and 'LITE
' format for exported model.
file_format (str): MindSpore currently supports 'GEIR', 'ONNX'
'LITE' and 'BINARY
' format for exported model.
- GEIR: Graph Engine Intermidiate Representation. An intermidiate representation format of
Ascend model.
- ONNX: Open Neural Network eXchange. An open format built to represent machine learning models.
- LITE: Huawei model format for mobile. A lite model only for the MindSpore Lite
- BINARY: Binary format for model. An intermidiate representation format for models.
"""
logger
.
info
(
"exporting model file:%s format:%s."
,
file_name
,
file_format
)
check_input_data
(
*
inputs
,
data_class
=
Tensor
)
supported_formats
=
[
'GEIR'
,
'ONNX'
,
'LITE'
]
supported_formats
=
[
'GEIR'
,
'ONNX'
,
'LITE'
,
'BINARY'
]
if
file_format
not
in
supported_formats
:
raise
ValueError
(
f
'Illegal file format
{
file_format
}
, it must be one of
{
supported_formats
}
'
)
# switch network mode to infer when it is training
...
...
@@ -428,6 +429,13 @@ def export(net, *inputs, file_name, file_format='GEIR'):
with
open
(
file_name
,
'wb'
)
as
f
:
os
.
chmod
(
file_name
,
stat
.
S_IWUSR
|
stat
.
S_IRUSR
)
f
.
write
(
onnx_stream
)
elif
file_format
==
'BINARY'
:
# file_format is 'BINARY'
phase_name
=
'export_binary'
graph_id
,
_
=
_executor
.
compile
(
net
,
*
inputs
,
phase
=
phase_name
,
do_convert
=
False
)
onnx_stream
=
_executor
.
_get_func_graph_proto
(
graph_id
,
'binary_ir'
)
with
open
(
file_name
,
'wb'
)
as
f
:
os
.
chmod
(
file_name
,
stat
.
S_IWUSR
|
stat
.
S_IRUSR
)
f
.
write
(
onnx_stream
)
elif
file_format
==
'LITE'
:
# file_format is 'LITE'
context
.
set_context
(
save_ms_model
=
True
,
save_ms_model_path
=
file_name
)
net
(
*
inputs
)
...
...
tests/ut/cpp/stub/anf_ir/dump_proto_stub.cc
浏览文件 @
ef35e2d9
...
...
@@ -17,8 +17,9 @@
namespace
mindspore
{
std
::
string
GetFuncGraphProtoString
(
const
FuncGraphPtr
&
func_graph
)
{
return
""
;
}
std
::
string
GetFuncGraphProtoString
(
const
FuncGraphPtr
&
func_graph
)
{
return
""
;
}
std
::
string
GetOnnxProtoString
(
const
FuncGraphPtr
&
func_graph
)
{
return
""
;
}
std
::
string
GetOnnxProtoString
(
const
FuncGraphPtr
&
func_graph
)
{
return
""
;
}
std
::
string
GetBinaryProtoString
(
const
FuncGraphPtr
&
func_graph
)
{
return
""
;
}
}
// namespace mindspore
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录