Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
42189be6
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
42189be6
编写于
7月 29, 2020
作者:
C
cc
提交者:
GitHub
7月 29, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Quant] Remove the output for moving_average_abs_max_scale op (#25697)
* Remove the output for moving_average_abs_max_scale op, test=develop
上级
521e7015
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
1 addition
and
13 deletion
+1
-13
paddle/fluid/operators/fake_quantize_op.cc
paddle/fluid/operators/fake_quantize_op.cc
+0
-6
paddle/fluid/operators/fake_quantize_op.h
paddle/fluid/operators/fake_quantize_op.h
+0
-3
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
...ddle/fluid/contrib/slim/quantization/quantization_pass.py
+1
-3
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
+0
-1
未找到文件。
paddle/fluid/operators/fake_quantize_op.cc
浏览文件 @
42189be6
...
...
@@ -447,8 +447,6 @@ class MovingAverageAbsMaxScaleOp : public framework::OperatorWithKernel {
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"X"
),
"Input"
,
"X"
,
"MovingAverageAbsMaxScale"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"MovingAverageAbsMaxScale"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"OutScale"
),
"Output"
,
"OutScale"
,
"MovingAverageAbsMaxScale"
);
if
(
ctx
->
HasOutput
(
"OutState"
))
{
...
...
@@ -457,9 +455,7 @@ class MovingAverageAbsMaxScaleOp : public framework::OperatorWithKernel {
if
(
ctx
->
HasOutput
(
"OutAccum"
))
{
ctx
->
SetOutputDim
(
"OutAccum"
,
{
1
});
}
ctx
->
SetOutputDim
(
"Out"
,
ctx
->
GetInputDim
(
"X"
));
ctx
->
SetOutputDim
(
"OutScale"
,
{
1
});
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
}
protected:
...
...
@@ -477,8 +473,6 @@ class MovingAverageAbsMaxScaleOpMaker
AddInput
(
"X"
,
"(Tensor) Input is float data type."
);
AddInput
(
"InAccum"
,
"Last accum."
).
AsDispensable
();
AddInput
(
"InState"
,
"Last state."
).
AsDispensable
();
AddOutput
(
"Out"
,
"(Tensor) Output tensor is just equivalent to the input tensor."
);
AddOutput
(
"OutScale"
,
" Current scale"
);
AddOutput
(
"OutState"
,
"(Tensor) state buffer."
).
AsDispensable
();
AddOutput
(
"OutAccum"
,
"(Tensor) accum buffer."
).
AsDispensable
();
...
...
paddle/fluid/operators/fake_quantize_op.h
浏览文件 @
42189be6
...
...
@@ -277,10 +277,7 @@ class MovingAverageAbsMaxScaleKernel : public framework::OpKernel<T> {
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
auto
*
in
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
out
->
mutable_data
<
T
>
(
context
.
GetPlace
());
auto
&
dev_ctx
=
context
.
template
device_context
<
DeviceContext
>();
framework
::
TensorCopy
(
*
in
,
context
.
GetPlace
(),
dev_ctx
,
out
);
bool
is_test
=
context
.
Attr
<
bool
>
(
"is_test"
);
// testing
...
...
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
浏览文件 @
42189be6
...
...
@@ -1449,7 +1449,6 @@ class OutScaleForTrainingPass(object):
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
()),
var_type
=
core
.
VarDesc
.
VarType
.
LOD_TENSOR
,
...
...
@@ -1464,7 +1463,7 @@ class OutScaleForTrainingPass(object):
self
.
_scope
,
self
.
_place
)
ins
=
{
'X'
:
in_node
}
outs
=
{
'Out
'
:
out_node
,
'Out
Scale'
:
scale_node
}
outs
=
{
'OutScale'
:
scale_node
}
if
not
self
.
_is_test
:
state_in_node
=
graph
.
create_persistable_node
(
name
=
unique_name
.
generate
(
'scale_state@'
),
...
...
@@ -1509,7 +1508,6 @@ class OutScaleForTrainingPass(object):
inputs
=
ins
,
outputs
=
outs
)
graph
.
link_to
(
in_node
,
scale_op_node
)
graph
.
link_to
(
scale_op_node
,
out_node
)
graph
.
link_to
(
scale_op_node
,
scale_node
)
if
not
self
.
_is_test
:
graph
.
link_to
(
state_in_node
,
scale_op_node
)
...
...
python/paddle/fluid/tests/unittests/test_fake_quantize_op.py
浏览文件 @
42189be6
...
...
@@ -146,7 +146,6 @@ class TestMovingAverageAbsMaxScaleOp(OpTest):
out_state
[
0
]
=
self
.
attrs
[
'moving_rate'
]
*
state
[
0
]
+
1
out_scale
=
out_accum
/
out_state
self
.
outputs
=
{
'Out'
:
self
.
inputs
[
'X'
],
'OutAccum'
:
out_accum
,
'OutState'
:
out_state
,
'OutScale'
:
out_scale
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录