Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6c89ca21
P
Paddle
项目概览
PaddlePaddle
/
Paddle
10 个月 前同步成功
通知
2285
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6c89ca21
编写于
5月 26, 2020
作者:
C
cc
提交者:
GitHub
5月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add output threshold for ops that have several output activations, test=develop (#24726)
上级
dbe24977
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
15 deletion
+14
-15
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
...ddle/fluid/contrib/slim/quantization/quantization_pass.py
+14
-15
未找到文件。
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
浏览文件 @
6c89ca21
...
...
@@ -1156,14 +1156,13 @@ class OutScaleForTrainingPass(object):
assert
isinstance
(
graph
,
IrGraph
),
'graph must be the instance of IrGraph.'
self
.
_is_test
=
graph
.
is_test
()
ops
=
graph
.
all_op_nodes
()
for
op_node
in
ops
:
name
=
op_node
.
name
()
if
name
in
self
.
_teller_set
:
if
len
(
op_node
.
output_arg_names
())
!=
1
:
continue
in_node
=
graph
.
_find_node_by_name
(
op_node
.
outputs
,
op_node
.
output_arg_names
()[
0
])
target_ops
=
[]
for
op
in
graph
.
all_op_nodes
():
if
op
.
name
()
in
self
.
_teller_set
:
target_ops
.
append
(
op
)
for
op
in
target_ops
:
for
output_var_name
in
_get_op_output_var_names
(
op
):
in_node
=
graph
.
_find_node_by_name
(
op
.
outputs
,
output_var_name
)
out_node
=
graph
.
create_var_node_from_desc
(
in_node
.
var
())
scale_node
=
graph
.
create_persistable_node
(
name
=
self
.
_scale_name
(
in_node
.
name
()),
...
...
@@ -1263,13 +1262,13 @@ class OutScaleForInferencePass(object):
"""
assert
isinstance
(
graph
,
IrGraph
),
'graph must be the instance of IrGraph.'
ops
=
graph
.
all_op_nodes
()
for
op_node
in
ops
:
name
=
op_node
.
name
()
if
name
in
self
.
_teller_set
:
if
len
(
op_node
.
output_arg_names
())
!=
1
:
continue
scale_name
=
self
.
_scale_name
(
o
p_node
.
output_arg_names
()
[
0
])
op
_node
s
=
graph
.
all_op_nodes
()
for
op_node
in
op
_node
s
:
if
op_node
.
name
()
in
self
.
_teller_set
:
output_var_name
=
_get_op_output_var_names
(
op_node
)
assert
len
(
output_var_name
)
==
1
,
"Only support collecting "
\
"output for op that only has an activation output for now."
scale_name
=
self
.
_scale_name
(
o
utput_var_name
[
0
])
scale_v
=
np
.
array
(
self
.
_scope
.
find_var
(
scale_name
).
get_tensor
())[
0
]
op_node
.
op
().
_set_attr
(
"out_threshold"
,
float
(
scale_v
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录