Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
8ae19458
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看板
未验证
提交
8ae19458
编写于
10月 21, 2022
作者:
C
ceci3
提交者:
GitHub
10月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix ptq hpo in ac (#1423)
上级
f481cb92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
13 deletion
+15
-13
paddleslim/auto_compression/compressor.py
paddleslim/auto_compression/compressor.py
+12
-12
paddleslim/auto_compression/create_compressed_program.py
paddleslim/auto_compression/create_compressed_program.py
+3
-1
未找到文件。
paddleslim/auto_compression/compressor.py
浏览文件 @
8ae19458
...
...
@@ -597,17 +597,23 @@ class AutoCompression:
train_config
):
# start compress, including train/eval model
# TODO: add the emd loss of evaluation model.
if
self
.
updated_model_dir
!=
self
.
model_dir
:
if
strategy_idx
==
0
:
model_dir
=
self
.
model_dir
else
:
model_dir
=
os
.
path
.
join
(
self
.
tmp_dir
,
'strategy_{}'
.
format
(
str
(
strategy_idx
)))
if
self
.
updated_model_dir
!=
model_dir
:
# If model is ONNX, convert it to inference model firstly.
load_inference_model
(
self
.
model_dir
,
model_dir
,
model_filename
=
self
.
model_filename
,
params_filename
=
self
.
params_filename
,
executor
=
self
.
_exe
)
if
strategy
==
'quant_post'
:
quant_post
(
self
.
_exe
,
model_dir
=
self
.
updated_
model_dir
,
model_dir
=
model_dir
,
quantize_model_path
=
os
.
path
.
join
(
self
.
tmp_dir
,
'strategy_{}'
.
format
(
str
(
strategy_idx
+
1
))),
data_loader
=
self
.
train_dataloader
,
...
...
@@ -633,10 +639,10 @@ class AutoCompression:
if
platform
.
system
().
lower
()
!=
'linux'
:
raise
NotImplementedError
(
"post-quant-hpo is not support in system other than linux"
)
if
self
.
updated_model_dir
!=
self
.
model_dir
:
if
self
.
updated_model_dir
!=
model_dir
:
# If model is ONNX, convert it to inference model firstly.
load_inference_model
(
self
.
model_dir
,
model_dir
,
model_filename
=
self
.
model_filename
,
params_filename
=
self
.
params_filename
,
executor
=
self
.
_exe
)
...
...
@@ -648,7 +654,7 @@ class AutoCompression:
post_quant_hpo
.
quant_post_hpo
(
self
.
_exe
,
self
.
_places
,
model_dir
=
self
.
updated_
model_dir
,
model_dir
=
model_dir
,
quantize_model_path
=
os
.
path
.
join
(
self
.
tmp_dir
,
'strategy_{}'
.
format
(
str
(
strategy_idx
+
1
))),
train_dataloader
=
self
.
train_dataloader
,
...
...
@@ -673,12 +679,6 @@ class AutoCompression:
else
:
assert
'dis'
in
strategy
,
"Only support optimizer compressed model by distillation loss."
if
strategy_idx
==
0
:
model_dir
=
self
.
model_dir
else
:
model_dir
=
os
.
path
.
join
(
self
.
tmp_dir
,
'strategy_{}'
.
format
(
str
(
strategy_idx
)))
[
inference_program
,
feed_target_names
,
fetch_targets
]
=
load_inference_model
(
\
model_dir
,
\
model_filename
=
self
.
model_filename
,
params_filename
=
self
.
params_filename
,
...
...
paddleslim/auto_compression/create_compressed_program.py
浏览文件 @
8ae19458
...
...
@@ -385,7 +385,9 @@ def build_quant_program(executor, place, config, train_program_info,
def
_get_label_info
(
dataloader
,
feed_target_names
):
label_info
=
{}
for
data
in
dataloader
():
for
key
,
value
in
data
[
0
].
items
():
if
isinstance
(
data
,
list
)
or
isinstance
(
data
,
tuple
):
data
=
data
[
0
]
for
key
,
value
in
data
.
items
():
if
key
in
feed_target_names
:
continue
label_info
[
'name'
]
=
key
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录