Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
285f3a71
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看板
未验证
提交
285f3a71
编写于
5月 26, 2022
作者:
Z
zhouzj
提交者:
GitHub
5月 26, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[auto-compression] solve prediction problems and fix docs. (#1142)
* solve prediction problems. * fix docs.
上级
2695a087
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
19 addition
and
15 deletion
+19
-15
demo/auto_compression/detection/README.md
demo/auto_compression/detection/README.md
+2
-1
demo/auto_compression/image_classification/README.md
demo/auto_compression/image_classification/README.md
+2
-1
demo/auto_compression/nlp/README.md
demo/auto_compression/nlp/README.md
+2
-1
demo/auto_compression/semantic_segmentation/README.md
demo/auto_compression/semantic_segmentation/README.md
+2
-1
paddleslim/auto_compression/utils/predict.py
paddleslim/auto_compression/utils/predict.py
+10
-10
paddleslim/auto_compression/utils/prune_model.py
paddleslim/auto_compression/utils/prune_model.py
+1
-1
未找到文件。
demo/auto_compression/detection/README.md
浏览文件 @
285f3a71
...
...
@@ -45,7 +45,8 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
pip
install
paddleslim
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
```
安装paddledet:
...
...
demo/auto_compression/image_classification/README.md
浏览文件 @
285f3a71
...
...
@@ -43,7 +43,8 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
pip
install
paddleslim
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
```
#### 3.2 准备数据集
...
...
demo/auto_compression/nlp/README.md
浏览文件 @
285f3a71
...
...
@@ -56,7 +56,8 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
pip
install
paddleslim
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
```
安装paddlenlp:
...
...
demo/auto_compression/semantic_segmentation/README.md
浏览文件 @
285f3a71
...
...
@@ -48,7 +48,8 @@ pip install paddlepaddle-gpu
安装paddleslim:
```
shell
pip
install
paddleslim
https://github.com/PaddlePaddle/PaddleSlim.git
python setup.py
install
```
安装paddleseg
...
...
paddleslim/auto_compression/utils/predict.py
浏览文件 @
285f3a71
...
...
@@ -27,9 +27,9 @@ def predict_compressed_model(model_dir,
latency_dict(dict): The latency latency of the model under various compression strategies.
"""
local_rank
=
paddle
.
distributed
.
get_rank
()
quant_model_path
=
f
'quant_model
/rank_
{
local_rank
}
'
prune_model_path
=
f
'prune_model
/rank_
{
local_rank
}
'
sparse_model_path
=
f
'sparse_model
/rank_
{
local_rank
}
'
quant_model_path
=
f
'quant_model
_rank_
{
local_rank
}
_tmp
'
prune_model_path
=
f
'prune_model
_rank_
{
local_rank
}
_tmp
'
sparse_model_path
=
f
'sparse_model
_rank_
{
local_rank
}
_tmp
'
latency_dict
=
{}
...
...
@@ -116,7 +116,7 @@ def predict_compressed_model(model_dir,
model_dir
=
sparse_model_path
,
model_filename
=
model_filename
,
params_filename
=
params_filename
,
save_model_path
=
'quant_model'
,
save_model_path
=
quant_model_path
,
quantizable_op_type
=
[
"conv2d"
,
"depthwise_conv2d"
,
"mul"
],
is_full_quantize
=
False
,
activation_bits
=
8
,
...
...
@@ -131,10 +131,10 @@ def predict_compressed_model(model_dir,
latency_dict
.
update
({
f
'sparse_
{
sparse_ratio
}
_int8'
:
latency
})
# NOTE: Delete temporary model files
if
os
.
path
.
exists
(
'quant_model'
):
shutil
.
rmtree
(
'quant_model'
,
ignore_errors
=
True
)
if
os
.
path
.
exists
(
'prune_model'
):
shutil
.
rmtree
(
'prune_model'
,
ignore_errors
=
True
)
if
os
.
path
.
exists
(
'sparse_model'
):
shutil
.
rmtree
(
'sparse_model'
,
ignore_errors
=
True
)
if
os
.
path
.
exists
(
quant_model_path
):
shutil
.
rmtree
(
quant_model_path
,
ignore_errors
=
True
)
if
os
.
path
.
exists
(
prune_model_path
):
shutil
.
rmtree
(
prune_model_path
,
ignore_errors
=
True
)
if
os
.
path
.
exists
(
sparse_model_path
):
shutil
.
rmtree
(
sparse_model_path
,
ignore_errors
=
True
)
return
latency_dict
paddleslim/auto_compression/utils/prune_model.py
浏览文件 @
285f3a71
...
...
@@ -122,7 +122,7 @@ def get_prune_model(model_file, param_file, ratio, save_path):
main_prog
=
static
.
Program
()
startup_prog
=
static
.
Program
()
place
=
paddle
.
CPUPlace
()
exe
=
paddle
.
static
.
Executor
()
exe
=
paddle
.
static
.
Executor
(
place
)
scope
=
static
.
global_scope
()
exe
.
run
(
startup_prog
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录