Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
67f5b0e9
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,发现更多精彩内容 >>
提交
67f5b0e9
编写于
8月 11, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4258 change binary to mindir
Merge pull request !4258 from leopz/fix_doc
上级
e48293a5
eea597c9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
20 addition
and
16 deletion
+20
-16
mindspore/ccsrc/pipeline/jit/pipeline.cc
mindspore/ccsrc/pipeline/jit/pipeline.cc
+2
-2
mindspore/train/quant/quant.py
mindspore/train/quant/quant.py
+5
-3
mindspore/train/serialization.py
mindspore/train/serialization.py
+8
-6
serving/example/export_model/add_model.py
serving/example/export_model/add_model.py
+1
-1
tests/st/serving/generate_model.py
tests/st/serving/generate_model.py
+2
-2
tests/ut/python/utils/test_serialize.py
tests/ut/python/utils/test_serialize.py
+2
-2
未找到文件。
mindspore/ccsrc/pipeline/jit/pipeline.cc
浏览文件 @
67f5b0e9
...
...
@@ -68,7 +68,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"
;
const
char
IR_TYPE_
MINDIR
[]
=
"mind
_ir"
;
ExecutorPyPtr
ExecutorPy
::
executor_
=
nullptr
;
std
::
mutex
ExecutorPy
::
instance_lock_
;
...
...
@@ -222,7 +222,7 @@ py::bytes ExecutorPy::GetFuncGraphProto(const std::string &phase, const std::str
return
proto_str
;
}
if
(
ir_type
==
IR_TYPE_
BINARY
)
{
if
(
ir_type
==
IR_TYPE_
MINDIR
)
{
std
::
string
proto_str
=
GetBinaryProtoString
(
fg_ptr
);
if
(
proto_str
.
empty
())
{
MS_LOG
(
EXCEPTION
)
<<
"Graph proto is empty."
;
...
...
mindspore/train/quant/quant.py
浏览文件 @
67f5b0e9
...
...
@@ -445,15 +445,17 @@ def export(network, *inputs, file_name, mean=127.5, std_dev=127.5, file_format='
file_name (str): File name of model to export.
mean (int): Input data mean. Default: 127.5.
std_dev (int, float): Input data variance. Default: 127.5.
file_format (str): MindSpore currently supports 'GEIR', 'ONNX' and '
BINARY
' format for exported
file_format (str): MindSpore currently supports 'GEIR', 'ONNX' and '
MINDIR
' format for exported
quantization aware model. Default: 'GEIR'.
- GEIR: Graph Engine Intermidiate Representation. An intermidiate representation format of
Ascend model.
- BINARY: Binary format for model. An intermidiate representation format for models.
- MINDIR: MindSpore Native Intermidiate Representation for Anf. An intermidiate representation format
for MindSpore models.
Recommended suffix for output file is '.mindir'.
"""
supported_device
=
[
"Ascend"
,
"GPU"
]
supported_formats
=
[
'GEIR'
,
'
BINARY
'
]
supported_formats
=
[
'GEIR'
,
'
MINDIR
'
]
mean
=
validator
.
check_type
(
"mean"
,
mean
,
(
int
,
float
))
std_dev
=
validator
.
check_type
(
"std_dev"
,
std_dev
,
(
int
,
float
))
...
...
mindspore/train/serialization.py
浏览文件 @
67f5b0e9
...
...
@@ -453,17 +453,19 @@ 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 '
BINARY
' format for exported model.
file_format (str): MindSpore currently supports 'GEIR', 'ONNX' and '
MINDIR
' 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.
- BINARY: Binary format for model. An intermidiate representation format for models.
- MINDIR: MindSpore Native Intermidiate Representation for Anf. An intermidiate representation format
for MindSpore models.
Recommended suffix for output file is '.mindir'.
"""
logger
.
info
(
"exporting model file:%s format:%s."
,
file_name
,
file_format
)
check_input_data
(
*
inputs
,
data_class
=
Tensor
)
supported_formats
=
[
'GEIR'
,
'ONNX'
,
'
BINARY
'
]
supported_formats
=
[
'GEIR'
,
'ONNX'
,
'
MINDIR
'
]
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
...
...
@@ -485,10 +487,10 @@ 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
'
elif
file_format
==
'
MINDIR'
:
# file_format is 'MINDIR
'
phase_name
=
'export.
mindir
'
graph_id
,
_
=
_executor
.
compile
(
net
,
*
inputs
,
phase
=
phase_name
,
do_convert
=
False
)
onnx_stream
=
_executor
.
_get_func_graph_proto
(
graph_id
,
'
binary
_ir'
)
onnx_stream
=
_executor
.
_get_func_graph_proto
(
graph_id
,
'
mind
_ir'
)
with
open
(
file_name
,
'wb'
)
as
f
:
os
.
chmod
(
file_name
,
stat
.
S_IWUSR
|
stat
.
S_IRUSR
)
f
.
write
(
onnx_stream
)
...
...
serving/example/export_model/add_model.py
浏览文件 @
67f5b0e9
...
...
@@ -36,7 +36,7 @@ y = np.ones(4).astype(np.float32)
def
export_net
():
add
=
Net
()
output
=
add
(
Tensor
(
x
),
Tensor
(
y
))
export
(
add
,
Tensor
(
x
),
Tensor
(
y
),
file_name
=
'tensor_add.pb'
,
file_format
=
'
BINARY
'
)
export
(
add
,
Tensor
(
x
),
Tensor
(
y
),
file_name
=
'tensor_add.pb'
,
file_format
=
'
MINDIR
'
)
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
...
...
tests/st/serving/generate_model.py
浏览文件 @
67f5b0e9
...
...
@@ -62,14 +62,14 @@ def export_add_model():
net
=
AddNet
()
x
=
np
.
ones
(
4
).
astype
(
np
.
float32
)
y
=
np
.
ones
(
4
).
astype
(
np
.
float32
)
export
(
net
,
Tensor
(
x
),
Tensor
(
y
),
file_name
=
'add.pb'
,
file_format
=
'
BINARY
'
)
export
(
net
,
Tensor
(
x
),
Tensor
(
y
),
file_name
=
'add.pb'
,
file_format
=
'
MINDIR
'
)
def
export_bert_model
():
net
=
BertModel
(
bert_net_cfg
,
False
)
input_ids
=
np
.
random
.
randint
(
0
,
1000
,
size
=
(
2
,
32
),
dtype
=
np
.
int32
)
segment_ids
=
np
.
zeros
((
2
,
32
),
dtype
=
np
.
int32
)
input_mask
=
np
.
zeros
((
2
,
32
),
dtype
=
np
.
int32
)
export
(
net
,
Tensor
(
input_ids
),
Tensor
(
segment_ids
),
Tensor
(
input_mask
),
file_name
=
'bert.pb'
,
file_format
=
'
BINARY
'
)
export
(
net
,
Tensor
(
input_ids
),
Tensor
(
segment_ids
),
Tensor
(
input_mask
),
file_name
=
'bert.pb'
,
file_format
=
'
MINDIR
'
)
if
__name__
==
'__main__'
:
export_add_model
()
...
...
tests/ut/python/utils/test_serialize.py
浏览文件 @
67f5b0e9
...
...
@@ -322,10 +322,10 @@ def test_export():
@
non_graph_engine
def
test_
binary
_export
():
def
test_
mindir
_export
():
net
=
MYNET
()
input_data
=
Tensor
(
np
.
random
.
randint
(
0
,
255
,
[
1
,
3
,
224
,
224
]).
astype
(
np
.
float32
))
export
(
net
,
input_data
,
file_name
=
"./me_binary_export.
pb"
,
file_format
=
"BINARY
"
)
export
(
net
,
input_data
,
file_name
=
"./me_binary_export.
mindir"
,
file_format
=
"MINDIR
"
)
class
PrintNet
(
nn
.
Cell
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录