Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
c3f762eb
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c3f762eb
编写于
6月 17, 2022
作者:
H
Hui Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
format code
上级
3cf1f1f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
20 deletion
+34
-20
speechx/examples/ds2_ol/onnx/README.md
speechx/examples/ds2_ol/onnx/README.md
+1
-1
speechx/examples/ds2_ol/onnx/local/onnx_convert_opset.py
speechx/examples/ds2_ol/onnx/local/onnx_convert_opset.py
+13
-6
speechx/examples/ds2_ol/onnx/local/onnx_infer_shape.py
speechx/examples/ds2_ol/onnx/local/onnx_infer_shape.py
+2
-0
speechx/examples/ds2_ol/onnx/local/ort_dyanmic_quant.py
speechx/examples/ds2_ol/onnx/local/ort_dyanmic_quant.py
+18
-13
未找到文件。
speechx/examples/ds2_ol/onnx/README.md
浏览文件 @
c3f762eb
...
@@ -51,4 +51,4 @@ Acoustic Model | Model Size | enigne | dedoding_method | ctc_weight | decoding_c
...
@@ -51,4 +51,4 @@ Acoustic Model | Model Size | enigne | dedoding_method | ctc_weight | decoding_c
| deepspeech2online_wenetspeech | 166MB | onnx quant | ctc_prefix_beam_search | - | 1 | - | 0.44507715475808385 (utts=80) |
| deepspeech2online_wenetspeech | 166MB | onnx quant | ctc_prefix_beam_search | - | 1 | - | 0.44507715475808385 (utts=80) |
> quant 和机器有关,不是所有机器都支持。ONNX quant测试机器指令集支持:
> quant 和机器有关,不是所有机器都支持。ONNX quant测试机器指令集支持:
> Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat umip pku ospke avx512_vnni spec_ctrl
> Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat umip pku ospke avx512_vnni spec_ctrl
\ No newline at end of file
speechx/examples/ds2_ol/onnx/local/onnx_convert_opset.py
浏览文件 @
c3f762eb
#!/usr/bin/env python3
#!/usr/bin/env python3
import
argparse
import
argparse
import
onnx
from
onnx
import
version_converter
,
helper
import
onnx
from
onnx
import
version_converter
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
prog
=
__doc__
)
parser
=
argparse
.
ArgumentParser
(
prog
=
__doc__
)
parser
.
add_argument
(
"--model-file"
,
type
=
str
,
required
=
True
,
help
=
'path/to/the/model.onnx.'
)
parser
.
add_argument
(
parser
.
add_argument
(
"--save-model"
,
type
=
str
,
required
=
True
,
help
=
'path/to/saved/model.onnx.'
)
"--model-file"
,
type
=
str
,
required
=
True
,
help
=
'path/to/the/model.onnx.'
)
parser
.
add_argument
(
"--save-model"
,
type
=
str
,
required
=
True
,
help
=
'path/to/saved/model.onnx.'
)
# Models must be opset10 or higher to be quantized.
# Models must be opset10 or higher to be quantized.
parser
.
add_argument
(
"--target-opset"
,
type
=
int
,
default
=
11
,
help
=
'path/to/the/model.onnx.'
)
parser
.
add_argument
(
"--target-opset"
,
type
=
int
,
default
=
11
,
help
=
'path/to/the/model.onnx.'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -24,7 +30,8 @@ if __name__ == '__main__':
...
@@ -24,7 +30,8 @@ if __name__ == '__main__':
# A full list of supported adapters can be found here:
# A full list of supported adapters can be found here:
# https://github.com/onnx/onnx/blob/main/onnx/version_converter.py#L21
# https://github.com/onnx/onnx/blob/main/onnx/version_converter.py#L21
# Apply the version conversion on the original model
# Apply the version conversion on the original model
converted_model
=
version_converter
.
convert_version
(
original_model
,
args
.
target_opset
)
converted_model
=
version_converter
.
convert_version
(
original_model
,
args
.
target_opset
)
# print('The model after conversion:\n{}'.format(converted_model))
# print('The model after conversion:\n{}'.format(converted_model))
onnx
.
save
(
converted_model
,
args
.
save_model
)
onnx
.
save
(
converted_model
,
args
.
save_model
)
speechx/examples/ds2_ol/onnx/local/onnx_infer_shape.py
浏览文件 @
c3f762eb
...
@@ -494,6 +494,8 @@ class SymbolicShapeInference:
...
@@ -494,6 +494,8 @@ class SymbolicShapeInference:
# contrib ops
# contrib ops
'Attention'
,
'BiasGelu'
,
\
'Attention'
,
'BiasGelu'
,
\
'EmbedLayerNormalization'
,
\
'EmbedLayerNormalization'
,
\
'FastGelu'
,
'Gelu'
,
'LayerNormalization'
,
\
'FastGelu'
,
'Gelu'
,
'LayerNormalization'
,
\
...
...
speechx/examples/ds2_ol/onnx/local/ort_dyanmic_quant.py
浏览文件 @
c3f762eb
#!/usr/bin/env python3
#!/usr/bin/env python3
import
argparse
import
argparse
import
onnx
from
onnxruntime.quantization
import
quantize_dynamic
,
QuantType
def
quantize_onnx_model
(
onnx_model_path
,
quantized_model_path
,
nodes_to_exclude
=
[]):
from
onnxruntime.quantization
import
quantize_dynamic
from
onnxruntime.quantization
import
QuantType
def
quantize_onnx_model
(
onnx_model_path
,
quantized_model_path
,
nodes_to_exclude
=
[]):
print
(
"Starting quantization..."
)
print
(
"Starting quantization..."
)
from
onnxruntime.quantization
import
QuantType
,
quantize_dynamic
quantize_dynamic
(
onnx_model_path
,
quantized_model_path
,
weight_type
=
QuantType
.
QInt8
,
nodes_to_exclude
=
nodes_to_exclude
)
quantize_dynamic
(
onnx_model_path
,
quantized_model_path
,
weight_type
=
QuantType
.
QInt8
,
nodes_to_exclude
=
nodes_to_exclude
)
print
(
f
"Quantized model saved to:
{
quantized_model_path
}
"
)
print
(
f
"Quantized model saved to:
{
quantized_model_path
}
"
)
...
@@ -18,26 +25,24 @@ def main():
...
@@ -18,26 +25,24 @@ def main():
"--model-in"
,
"--model-in"
,
type
=
str
,
type
=
str
,
required
=
True
,
required
=
True
,
help
=
"ONNX model"
,
help
=
"ONNX model"
,
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"--model-out"
,
"--model-out"
,
type
=
str
,
type
=
str
,
required
=
True
,
required
=
True
,
default
=
'model.quant.onnx'
,
default
=
'model.quant.onnx'
,
help
=
"ONNX model"
,
help
=
"ONNX model"
,
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"--nodes-to-exclude"
,
"--nodes-to-exclude"
,
type
=
str
,
type
=
str
,
required
=
True
,
required
=
True
,
help
=
"nodes to exclude. e.g. conv,linear."
,
help
=
"nodes to exclude. e.g. conv,linear."
,
)
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
nodes_to_exclude
=
args
.
nodes_to_exclude
.
split
(
','
)
nodes_to_exclude
=
args
.
nodes_to_exclude
.
split
(
','
)
quantize_onnx_model
(
args
.
model_in
,
args
.
model_out
,
nodes_to_exclude
)
quantize_onnx_model
(
args
.
model_in
,
args
.
model_out
,
nodes_to_exclude
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
main
()
main
()
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录