Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1d04e021
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1d04e021
编写于
9月 23, 2022
作者:
Z
zyfncg
提交者:
GitHub
9月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set flag of clip_extra in save_inference_model to true (#46151)
上级
60a3929a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
10 addition
and
12 deletion
+10
-12
python/paddle/fluid/dygraph/jit.py
python/paddle/fluid/dygraph/jit.py
+1
-1
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+8
-10
python/paddle/fluid/io.py
python/paddle/fluid/io.py
+1
-1
未找到文件。
python/paddle/fluid/dygraph/jit.py
浏览文件 @
1d04e021
...
@@ -397,7 +397,7 @@ def _parse_save_configs(configs):
...
@@ -397,7 +397,7 @@ def _parse_save_configs(configs):
inner_config
.
output_spec
=
configs
.
get
(
'output_spec'
,
None
)
inner_config
.
output_spec
=
configs
.
get
(
'output_spec'
,
None
)
inner_config
.
with_hook
=
configs
.
get
(
'with_hook'
,
False
)
inner_config
.
with_hook
=
configs
.
get
(
'with_hook'
,
False
)
inner_config
.
combine_params
=
configs
.
get
(
"combine_params"
,
False
)
inner_config
.
combine_params
=
configs
.
get
(
"combine_params"
,
False
)
inner_config
.
clip_extra
=
configs
.
get
(
"clip_extra"
,
Fals
e
)
inner_config
.
clip_extra
=
configs
.
get
(
"clip_extra"
,
Tru
e
)
inner_config
.
skip_forward
=
configs
.
get
(
"skip_forward"
,
False
)
inner_config
.
skip_forward
=
configs
.
get
(
"skip_forward"
,
False
)
return
inner_config
return
inner_config
...
...
python/paddle/fluid/framework.py
浏览文件 @
1d04e021
...
@@ -5873,9 +5873,7 @@ class Program(object):
...
@@ -5873,9 +5873,7 @@ class Program(object):
# Note: The op_role and op_role_var cann't be deleted currently,
# Note: The op_role and op_role_var cann't be deleted currently,
# and we will try to remove them in the future.
# and we will try to remove them in the future.
common_clipped_attrs_list
=
[
common_clipped_attrs_list
=
[
'op_callstack'
,
'with_quant_attr'
]
'op_namescope'
,
'op_callstack'
,
'op_device'
,
'with_quant_attr'
]
for
i
in
six
.
moves
.
range
(
res
.
desc
.
num_blocks
()):
for
i
in
six
.
moves
.
range
(
res
.
desc
.
num_blocks
()):
block
=
res
.
desc
.
block
(
i
)
block
=
res
.
desc
.
block
(
i
)
...
@@ -5904,8 +5902,9 @@ class Program(object):
...
@@ -5904,8 +5902,9 @@ class Program(object):
break
break
if
not
find
:
if
not
find
:
remove_input_list
.
append
(
name
)
remove_input_list
.
append
(
name
)
for
name
in
remove_input_list
:
# The extra input of op will be removed in the future
op
.
remove_input
(
name
)
# for name in remove_input_list:
# op.remove_input(name)
remove_output_list
=
[]
remove_output_list
=
[]
for
name
in
op
.
output_names
():
for
name
in
op
.
output_names
():
...
@@ -5919,10 +5918,10 @@ class Program(object):
...
@@ -5919,10 +5918,10 @@ class Program(object):
break
break
if
not
find
:
if
not
find
:
remove_output_list
.
append
(
name
)
remove_output_list
.
append
(
name
)
for
name
in
remove_output_list
:
# The extra output of op will be removed in the future
op
.
remove_output
(
name
)
# for name in remove_output_list:
# op.remove_output(name)
remove_attr_list
=
[]
op_quant_name
=
core
.
op_proto_and_checker_maker
.
kOpWithQuantAttrName
(
op_quant_name
=
core
.
op_proto_and_checker_maker
.
kOpWithQuantAttrName
(
)
)
quant
=
bool
(
op
.
attr
(
op_quant_name
)
quant
=
bool
(
op
.
attr
(
op_quant_name
)
...
@@ -5932,6 +5931,7 @@ class Program(object):
...
@@ -5932,6 +5931,7 @@ class Program(object):
"activation_bits"
,
"bit_length"
,
"quantize_weight_bits"
,
"activation_bits"
,
"bit_length"
,
"quantize_weight_bits"
,
"weight_quant_scale"
"weight_quant_scale"
]
]
remove_attr_list
=
[]
for
name
in
op
.
attr_names
():
for
name
in
op
.
attr_names
():
if
quant
:
if
quant
:
if
name
in
quant_attrs
:
if
name
in
quant_attrs
:
...
@@ -5946,8 +5946,6 @@ class Program(object):
...
@@ -5946,8 +5946,6 @@ class Program(object):
for
attr_proto
in
proto
.
attrs
:
for
attr_proto
in
proto
.
attrs
:
if
attr_proto
.
name
!=
name
:
if
attr_proto
.
name
!=
name
:
continue
continue
if
attr_proto
.
extra
:
remove_attr_list
.
append
(
name
)
find
=
True
find
=
True
break
break
if
not
find
:
if
not
find
:
...
...
python/paddle/fluid/io.py
浏览文件 @
1d04e021
...
@@ -1232,7 +1232,7 @@ def save_inference_model(dirname,
...
@@ -1232,7 +1232,7 @@ def save_inference_model(dirname,
params_filename
=
None
,
params_filename
=
None
,
export_for_deployment
=
True
,
export_for_deployment
=
True
,
program_only
=
False
,
program_only
=
False
,
clip_extra
=
Fals
e
):
clip_extra
=
Tru
e
):
"""
"""
Prune the given `main_program` to build a new program especially for inference,
Prune the given `main_program` to build a new program especially for inference,
and then save it and all related parameters to given `dirname` .
and then save it and all related parameters to given `dirname` .
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录