Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
b007324c
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 2 年 前同步成功
通知
51
Star
1434
Fork
344
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
16
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSlim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
16
合并请求
16
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b007324c
编写于
6月 08, 2022
作者:
G
Guanghua Yu
提交者:
GitHub
6月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support skip_tensor_list in PTQ (#1160)
上级
f6b827fc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
7 addition
and
1 deletion
+7
-1
docs/zh_cn/api_cn/static/quant/quantization_api.rst
docs/zh_cn/api_cn/static/quant/quantization_api.rst
+3
-1
paddleslim/quant/quanter.py
paddleslim/quant/quanter.py
+4
-0
未找到文件。
docs/zh_cn/api_cn/static/quant/quantization_api.rst
浏览文件 @
b007324c
...
@@ -118,7 +118,7 @@ quant_post_dynamic
...
@@ -118,7 +118,7 @@ quant_post_dynamic
quant_post_static
quant_post_static
---------------
---------------
..
py
:
function
::
paddleslim
.
quant
.
quant_post_static
(
executor
,
model_dir
,
quantize_model_path
,
batch_generator
=
None
,
sample_generator
=
None
,
model_filename
=
None
,
params_filename
=
None
,
save_model_filename
=
'__model__'
,
save_params_filename
=
'__params__'
,
batch_size
=
16
,
batch_nums
=
None
,
scope
=
None
,
algo
=
'KL'
,
round_type
=
'round'
,
quantizable_op_type
=[
"conv2d"
,
"depthwise_conv2d"
,
"mul"
],
is_full_quantize
=
False
,
weight_bits
=
8
,
activation_bits
=
8
,
activation_quantize_type
=
'range_abs_max'
,
weight_quantize_type
=
'channel_wise_abs_max'
,
optimize_model
=
False
)
..
py
:
function
::
paddleslim
.
quant
.
quant_post_static
(
executor
,
model_dir
,
quantize_model_path
,
batch_generator
=
None
,
sample_generator
=
None
,
model_filename
=
None
,
params_filename
=
None
,
save_model_filename
=
'__model__'
,
save_params_filename
=
'__params__'
,
batch_size
=
16
,
batch_nums
=
None
,
scope
=
None
,
algo
=
'KL'
,
round_type
=
'round'
,
quantizable_op_type
=[
"conv2d"
,
"depthwise_conv2d"
,
"mul"
],
is_full_quantize
=
False
,
weight_bits
=
8
,
activation_bits
=
8
,
activation_quantize_type
=
'range_abs_max'
,
weight_quantize_type
=
'channel_wise_abs_max'
,
o
nnx_format
=
False
,
skip_tensor_list
=
None
,
o
ptimize_model
=
False
)
`
源代码
<
https
://
github
.
com
/
PaddlePaddle
/
PaddleSlim
/
blob
/
develop
/
paddleslim
/
quant
/
quanter
.
py
>`
_
`
源代码
<
https
://
github
.
com
/
PaddlePaddle
/
PaddleSlim
/
blob
/
develop
/
paddleslim
/
quant
/
quanter
.
py
>`
_
...
@@ -170,6 +170,8 @@ quant_post_static
...
@@ -170,6 +170,8 @@ quant_post_static
-
**
activation_bits
(
int
)**
-
激活值的量化比特位数
,
默认值为
8
。
-
**
activation_bits
(
int
)**
-
激活值的量化比特位数
,
默认值为
8
。
-
**
weight_quantize_type
(
str
)**
-
weight
的量化方式,可选
`
abs_max
`
或者
`
channel_wise_abs_max
`
,
通常情况下选
`
channel_wise_abs_max
`
模型量化精度更高。
-
**
weight_quantize_type
(
str
)**
-
weight
的量化方式,可选
`
abs_max
`
或者
`
channel_wise_abs_max
`
,
通常情况下选
`
channel_wise_abs_max
`
模型量化精度更高。
-
**
activation_quantize_type
(
str
)**
-
激活值的量化方式
,
可选
`
range_abs_max
`
和
`
moving_average_abs_max
`
。设置激活量化方式不会影响计算
scale
的算法,只是影响在保存模型时使用哪种
operator
。
-
**
activation_quantize_type
(
str
)**
-
激活值的量化方式
,
可选
`
range_abs_max
`
和
`
moving_average_abs_max
`
。设置激活量化方式不会影响计算
scale
的算法,只是影响在保存模型时使用哪种
operator
。
-
**
onnx_format
(
bool
)**
-
ONNX
量化模型格式,可选
`
True
`
和
`
False
`
。默认是
False
。
-
**
skip_tensor_list
(
list
)**
-
跳过量化
Tensor
的列表,默认是
None
,需设置成
Tensor
的
name
,
Tensor
的
name
可以通过可视化工具查看。
-
**
optimize_model
(
bool
)**
-
是否在量化之前对模型进行
fuse
优化。
executor
必须在
cpu
上执才可以设置该参数为
True
,然后会将
`
conv2d
/
depthwise_conv2d
/
conv2d_tranpose
+
batch_norm
`
进行
fuse
。
-
**
optimize_model
(
bool
)**
-
是否在量化之前对模型进行
fuse
优化。
executor
必须在
cpu
上执才可以设置该参数为
True
,然后会将
`
conv2d
/
depthwise_conv2d
/
conv2d_tranpose
+
batch_norm
`
进行
fuse
。
**
返回
**
**
返回
**
...
...
paddleslim/quant/quanter.py
浏览文件 @
b007324c
...
@@ -373,6 +373,7 @@ def quant_post_static(
...
@@ -373,6 +373,7 @@ def quant_post_static(
weight_quantize_type
=
'channel_wise_abs_max'
,
weight_quantize_type
=
'channel_wise_abs_max'
,
optimize_model
=
False
,
optimize_model
=
False
,
onnx_format
=
False
,
onnx_format
=
False
,
skip_tensor_list
=
None
,
is_use_cache_file
=
False
,
is_use_cache_file
=
False
,
cache_dir
=
"./temp_post_training"
):
cache_dir
=
"./temp_post_training"
):
"""
"""
...
@@ -444,6 +445,8 @@ def quant_post_static(
...
@@ -444,6 +445,8 @@ def quant_post_static(
optimize_model(bool, optional): If set optimize_model as True, it applies some
optimize_model(bool, optional): If set optimize_model as True, it applies some
passes to optimize the model before quantization. So far, the place of
passes to optimize the model before quantization. So far, the place of
executor must be cpu it supports fusing batch_norm into convs.
executor must be cpu it supports fusing batch_norm into convs.
onnx_format(bool): Whether to export the quantized model with format of ONNX. Default is False.
skip_tensor_list(list): List of skip quant tensor name.
is_use_cache_file(bool): This param is deprecated.
is_use_cache_file(bool): This param is deprecated.
cache_dir(str): This param is deprecated.
cache_dir(str): This param is deprecated.
...
@@ -472,6 +475,7 @@ def quant_post_static(
...
@@ -472,6 +475,7 @@ def quant_post_static(
activation_quantize_type
=
activation_quantize_type
,
activation_quantize_type
=
activation_quantize_type
,
weight_quantize_type
=
weight_quantize_type
,
weight_quantize_type
=
weight_quantize_type
,
onnx_format
=
onnx_format
,
onnx_format
=
onnx_format
,
skip_tensor_list
=
skip_tensor_list
,
optimize_model
=
optimize_model
)
optimize_model
=
optimize_model
)
post_training_quantization
.
quantize
()
post_training_quantization
.
quantize
()
post_training_quantization
.
save_quantized_model
(
post_training_quantization
.
save_quantized_model
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录