Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
e9011d3e
P
PaddleSlim
项目概览
PaddlePaddle
/
PaddleSlim
大约 1 年 前同步成功
通知
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看板
未验证
提交
e9011d3e
编写于
8月 21, 2023
作者:
C
Chang Xu
提交者:
GitHub
8月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support Load scales from quant model (#1790)
上级
cafd9859
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
16 addition
and
3 deletion
+16
-3
paddleslim/quant/advanced/piecewise_search.py
paddleslim/quant/advanced/piecewise_search.py
+2
-2
paddleslim/quant/observers/abs_max.py
paddleslim/quant/observers/abs_max.py
+3
-0
paddleslim/quant/observers/abs_max_weight.py
paddleslim/quant/observers/abs_max_weight.py
+2
-1
paddleslim/quant/observers/avg.py
paddleslim/quant/observers/avg.py
+3
-0
paddleslim/quant/observers/emd.py
paddleslim/quant/observers/emd.py
+3
-0
paddleslim/quant/observers/mse.py
paddleslim/quant/observers/mse.py
+3
-0
未找到文件。
paddleslim/quant/advanced/piecewise_search.py
浏览文件 @
e9011d3e
...
@@ -153,8 +153,8 @@ class PieceWiseSearch():
...
@@ -153,8 +153,8 @@ class PieceWiseSearch():
else
:
else
:
smooth_scale_out
+=
final_smooth_scale
smooth_scale_out
+=
final_smooth_scale
if
c
ur
_loss
<
global_loss
:
if
c
alibration
_loss
<
global_loss
:
global_loss
=
c
ur
_loss
global_loss
=
c
alibration
_loss
best_scale
=
smooth_scale_out
best_scale
=
smooth_scale_out
if
self
.
search_piece
:
if
self
.
search_piece
:
print
(
'Find Better K-Piece {}'
.
format
(
k_piece
))
print
(
'Find Better K-Piece {}'
.
format
(
k_piece
))
...
...
paddleslim/quant/observers/abs_max.py
浏览文件 @
e9011d3e
...
@@ -69,6 +69,9 @@ class AbsmaxObserverLayer(UniformObserver):
...
@@ -69,6 +69,9 @@ class AbsmaxObserverLayer(UniformObserver):
def
cal_thresholds
(
self
):
def
cal_thresholds
(
self
):
""" Compute thresholds for MAX function.
""" Compute thresholds for MAX function.
"""
"""
if
self
.
_scale
is
not
None
:
self
.
_zero_point
=
0
return
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
def
min_value
(
self
)
->
float
:
def
min_value
(
self
)
->
float
:
...
...
paddleslim/quant/observers/abs_max_weight.py
浏览文件 @
e9011d3e
...
@@ -81,7 +81,8 @@ class AbsMaxChannelWiseWeightObserverLayer(ChannelWiseObserver):
...
@@ -81,7 +81,8 @@ class AbsMaxChannelWiseWeightObserverLayer(ChannelWiseObserver):
def
cal_thresholds
(
self
):
def
cal_thresholds
(
self
):
""" Compute thresholds for MAX function.
""" Compute thresholds for MAX function.
"""
"""
self
.
_scale
=
self
.
_max
if
self
.
_scale
is
None
:
self
.
_scale
=
self
.
_max
self
.
_zero_point
=
paddle
.
zeros_like
(
self
.
_scale
)
self
.
_zero_point
=
paddle
.
zeros_like
(
self
.
_scale
)
def
scales
(
self
):
def
scales
(
self
):
...
...
paddleslim/quant/observers/avg.py
浏览文件 @
e9011d3e
...
@@ -70,6 +70,9 @@ class AVGObserverLayer(UniformObserver):
...
@@ -70,6 +70,9 @@ class AVGObserverLayer(UniformObserver):
def
cal_thresholds
(
self
):
def
cal_thresholds
(
self
):
""" Compute thresholds for MAX function.
""" Compute thresholds for MAX function.
"""
"""
if
self
.
_scale
is
not
None
:
self
.
_zero_point
=
0
return
self
.
_min
,
self
.
_max
=
self
.
_avg_min
,
paddle
.
mean
(
self
.
_min
,
self
.
_max
=
self
.
_avg_min
,
paddle
.
mean
(
paddle
.
to_tensor
(
self
.
_avg_list
))
paddle
.
to_tensor
(
self
.
_avg_list
))
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
...
...
paddleslim/quant/observers/emd.py
浏览文件 @
e9011d3e
...
@@ -85,6 +85,9 @@ class EMDObserverLayer(UniformObserver):
...
@@ -85,6 +85,9 @@ class EMDObserverLayer(UniformObserver):
def
cal_thresholds
(
self
):
def
cal_thresholds
(
self
):
""" Compute thresholds for MAX function.
""" Compute thresholds for MAX function.
"""
"""
if
self
.
_scale
is
not
None
:
self
.
_zero_point
=
0
return
self
.
_min
,
self
.
_max
=
self
.
_emd_min
,
self
.
_emd_max
self
.
_min
,
self
.
_max
=
self
.
_emd_min
,
self
.
_emd_max
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
...
...
paddleslim/quant/observers/mse.py
浏览文件 @
e9011d3e
...
@@ -82,6 +82,9 @@ class MSEObserverLayer(UniformObserver):
...
@@ -82,6 +82,9 @@ class MSEObserverLayer(UniformObserver):
def
cal_thresholds
(
self
):
def
cal_thresholds
(
self
):
""" Compute thresholds for MAX function.
""" Compute thresholds for MAX function.
"""
"""
if
self
.
_scale
is
not
None
:
self
.
_zero_point
=
0
return
self
.
_min
,
self
.
_max
=
self
.
_mse_min
,
self
.
_mse_max
self
.
_min
,
self
.
_max
=
self
.
_mse_min
,
self
.
_mse_max
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
self
.
_scale
,
self
.
_zero_point
=
self
.
cal_scales_zero_points
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录