Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSlim
提交
9c214906
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看板
未验证
提交
9c214906
编写于
5月 17, 2022
作者:
C
ceci3
提交者:
GitHub
5月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix when params_filename is None (#1106)
上级
410d90ef
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
9 deletion
+27
-9
paddleslim/auto_compression/auto_strategy.py
paddleslim/auto_compression/auto_strategy.py
+18
-6
paddleslim/auto_compression/compressor.py
paddleslim/auto_compression/compressor.py
+4
-0
paddleslim/auto_compression/create_compressed_program.py
paddleslim/auto_compression/create_compressed_program.py
+2
-1
paddleslim/auto_compression/strategy_config.py
paddleslim/auto_compression/strategy_config.py
+3
-2
未找到文件。
paddleslim/auto_compression/auto_strategy.py
浏览文件 @
9c214906
...
...
@@ -71,14 +71,26 @@ def create_strategy_config(strategy_str, model_type):
dis_config
=
Distillation
()
if
len
(
tmp_s
)
==
3
:
### TODO(ceci3): choose prune algo automatically
if
'prune'
in
tmp_s
[
0
]:
### default prune config
default_prune_config
=
{
'pruned_ratio'
:
float
(
tmp_s
[
1
]),
'prune_algo'
:
'prune'
,
'criterion'
:
'l1_norm'
}
else
:
### default unstruture prune config
default_prune_config
=
{
'prune_strategy'
:
'gmp'
,
### default unstruture prune strategy is gmp
'prune_mode'
:
'ratio'
,
'pruned_ratio'
:
float
(
tmp_s
[
1
]),
'local_sparsity'
:
True
,
'prune_params_type'
:
'conv1x1_only'
}
tmp_s
[
0
]
=
tmp_s
[
0
].
replace
(
'prune'
,
'Prune'
)
tmp_s
[
0
]
=
tmp_s
[
0
].
replace
(
'sparse'
,
'UnstructurePrune'
)
### TODO(ceci3): auto choose prune algo
default_prune_config
=
{
'pruned_ratio'
:
float
(
tmp_s
[
1
]),
'prune_algo'
:
'prune'
,
'criterion'
:
'l1_norm'
}
if
model_type
==
'transformer'
and
tmp_s
[
0
]
==
'Prune'
:
default_prune_config
[
'prune_algo'
]
=
'transformer_pruner'
prune_config
=
eval
(
tmp_s
[
0
])(
**
default_prune_config
)
...
...
paddleslim/auto_compression/compressor.py
浏览文件 @
9c214906
...
...
@@ -97,7 +97,11 @@ class AutoCompression:
deploy_hardware(str, optional): The hardware you want to deploy. Default: 'gpu'.
"""
self
.
model_dir
=
model_dir
if
model_filename
==
'None'
:
model_filename
=
None
self
.
model_filename
=
model_filename
if
params_filename
==
'None'
:
params_filename
=
None
self
.
params_filename
=
params_filename
base_path
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
save_dir
))
parent_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
save_dir
,
os
.
pardir
))
...
...
paddleslim/auto_compression/create_compressed_program.py
浏览文件 @
9c214906
...
...
@@ -100,7 +100,8 @@ def _load_program_and_merge(executor,
feed_target_names
=
None
):
scope
=
paddle
.
static
.
global_scope
()
new_scope
=
paddle
.
static
.
Scope
()
print
(
model_dir
,
model_filename
,
params_filename
)
if
params_filename
==
'None'
:
params_filename
=
None
try
:
with
paddle
.
static
.
scope_guard
(
new_scope
):
[
teacher_program
,
teacher_feed_target_names
,
teacher_fetch_targets
]
=
paddle
.
fluid
.
io
.
load_inference_model
(
\
...
...
paddleslim/auto_compression/strategy_config.py
浏览文件 @
9c214906
...
...
@@ -34,8 +34,9 @@ Quantization = namedtuple(
"weight_quantize_type"
])
Quantization
.
__new__
.
__defaults__
=
(
None
,
)
*
(
len
(
Quantization
.
_fields
)
-
1
)
+
(
False
,
)
Quantization
.
__new__
.
__defaults__
=
(
None
,
)
*
(
len
(
Quantization
.
_fields
)
-
3
)
+
(
False
,
'moving_average_abs_max'
,
'channel_wise_abs_max'
)
### Distillation:
Distillation
=
namedtuple
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录