Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f9420e83
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
f9420e83
编写于
6月 23, 2021
作者:
王
王明冬
提交者:
GitHub
6月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add compat precondition for delete_quant_dequant_filter_op_pass, test=develop (#33705)
上级
d55f3b6f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
3 deletion
+121
-3
paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc
...fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc
+36
-0
paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.h
.../fluid/framework/ir/delete_quant_dequant_filter_op_pass.h
+1
-3
paddle/fluid/operators/compat/fake_channel_wise_quantize_dequantize_abs_max.pbtxt
...ompat/fake_channel_wise_quantize_dequantize_abs_max.pbtxt
+46
-0
paddle/fluid/operators/compat/fake_quantize_dequantize_abs_max.pbtxt
...d/operators/compat/fake_quantize_dequantize_abs_max.pbtxt
+38
-0
未找到文件。
paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc
浏览文件 @
f9420e83
...
...
@@ -32,6 +32,37 @@ namespace ir {
GET_IR_NODE(quant_dequant_op_outscale); \
GET_IR_NODE(any_op2);
DeleteQuantDequantFilterOpPass
::
DeleteQuantDequantFilterOpPass
()
{
AddOpCompat
(
OpCompat
(
"fake_quantize_dequantize_abs_max"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"OutScale"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"bit_length"
)
.
IsIntIn
({
8
,
16
})
.
End
();
AddOpCompat
(
OpCompat
(
"fake_channel_wise_quantize_dequantize_abs_max"
))
.
AddInput
(
"X"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"Out"
)
.
IsTensor
()
.
End
()
.
AddOutput
(
"OutScale"
)
.
IsTensor
()
.
End
()
.
AddAttr
(
"bit_length"
)
.
IsIntIn
({
8
,
16
})
.
End
()
.
AddAttr
(
"quant_axis"
)
.
IsIntIn
({
0
,
1
})
.
End
();
}
// Delete quant_dequant_op, then quantize and dequantize weight
void
DeleteQuantDequantFilterOpPass
::
ApplyImpl
(
ir
::
Graph
*
graph
)
const
{
const
std
::
string
pattern_name
=
"delete_quantdequant_filter_op_pattern"
;
...
...
@@ -50,6 +81,11 @@ void DeleteQuantDequantFilterOpPass::ApplyImpl(ir::Graph* graph) const {
Graph
*
g
)
{
GET_NODES
;
if
(
!
IsCompat
(
*
quant_dequant_op
->
Op
()))
{
LOG
(
WARNING
)
<<
"quant_dequant_op in delete_quant_dequant_filter_op_pass "
"compat check failed."
;
return
;
}
std
::
unordered_set
<
const
Node
*>
nodes2rm
=
{};
int
bit_length
=
BOOST_GET_CONST
(
int
,
quant_dequant_op
->
Op
()
->
GetAttr
(
"bit_length"
));
...
...
paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.h
浏览文件 @
f9420e83
...
...
@@ -16,16 +16,14 @@
#include <vector>
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
namespace
paddle
{
namespace
framework
{
namespace
ir
{
class
Graph
;
class
DeleteQuantDequantFilterOpPass
:
public
FusePassBase
{
public:
DeleteQuantDequantFilterOpPass
();
virtual
~
DeleteQuantDequantFilterOpPass
()
{}
protected:
...
...
paddle/fluid/operators/compat/fake_channel_wise_quantize_dequantize_abs_max.pbtxt
0 → 100644
浏览文件 @
f9420e83
type: "fake_channel_wise_quantize_dequantize_abs_max"
def {
inputs {
name: "X"
}
outputs {
name: "Out"
}
outputs {
name: "OutScale"
}
attrs {
name: "quant_axis"
type: INT
}
attrs {
name: "bit_length"
type: INT
}
}
extra {
attrs {
name: "is_test"
type: BOOLEAN
}
attrs {
name: "op_role"
type: INT
}
attrs {
name: "op_role_var"
type: STRINGS
}
attrs {
name: "op_namescope"
type: STRING
}
attrs {
name: "op_callstack"
type: STRINGS
}
attrs {
name: "op_device"
type: STRING
}
}
paddle/fluid/operators/compat/fake_quantize_dequantize_abs_max.pbtxt
0 → 100644
浏览文件 @
f9420e83
type: "fake_quantize_dequantize_abs_max"
def {
inputs {
name: "X"
}
outputs {
name: "Out"
}
outputs {
name: "OutScale"
}
attrs {
name: "bit_length"
type: INT
}
}
extra {
attrs {
name: "op_role"
type: INT
}
attrs {
name: "op_role_var"
type: STRINGS
}
attrs {
name: "op_namescope"
type: STRING
}
attrs {
name: "op_callstack"
type: STRINGS
}
attrs {
name: "op_device"
type: STRING
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录