Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DS小龙哥
Paddle
提交
1cf64e00
P
Paddle
项目概览
DS小龙哥
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cf64e00
编写于
4月 09, 2020
作者:
Z
Zhen Wang
提交者:
GitHub
4月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve error messages of fake_dequantize_op. test=develop (#23556)
上级
467ce0bc
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
24 addition
and
22 deletion
+24
-22
paddle/fluid/operators/fake_dequantize_op.cc
paddle/fluid/operators/fake_dequantize_op.cc
+9
-13
paddle/fluid/operators/fake_dequantize_op.h
paddle/fluid/operators/fake_dequantize_op.h
+15
-9
未找到文件。
paddle/fluid/operators/fake_dequantize_op.cc
浏览文件 @
1cf64e00
...
@@ -88,10 +88,9 @@ class FakeDequantizeMaxAbsOp : public framework::OperatorWithKernel {
...
@@ -88,10 +88,9 @@ class FakeDequantizeMaxAbsOp : public framework::OperatorWithKernel {
:
OperatorWithKernel
(
type
,
inputs
,
outputs
,
attrs
)
{}
:
OperatorWithKernel
(
type
,
inputs
,
outputs
,
attrs
)
{}
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"X"
),
"Input"
,
"X"
,
"FakeDequantizeMaxAbs"
);
"Input(X) of FakeDequantizeMaxAbsOp should not be null."
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"FakeDequantizeMaxAbs"
);
"Output(Out) of FakeDequantizeMaxAbsOp should not be null."
);
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
...
@@ -125,15 +124,12 @@ class FakeChannelWiseDequantizeMaxAbsOp : public framework::OperatorWithKernel {
...
@@ -125,15 +124,12 @@ class FakeChannelWiseDequantizeMaxAbsOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"X"
),
"Input"
,
"X"
,
ctx
->
HasInput
(
"X"
),
"FakeChannelWiseDequantizeMaxAbs"
);
"Input(X) of FakeChannelWiseDequantizeMaxAbsOp should not be null."
);
OP_INOUT_CHECK
(
ctx
->
HasInputs
(
"Scales"
),
"Input"
,
"Scales"
,
PADDLE_ENFORCE
(
ctx
->
HasInputs
(
"Scales"
),
"FakeChannelWiseDequantizeMaxAbs"
);
"Input(Scales) of FakeChannelWiseDequantizeMaxAbsOp "
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"should not be null."
);
"FakeChannelWiseDequantizeMaxAbs"
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"Output(Out) of FakeChannelWiseDequantizeMaxAbsOp should not be null."
);
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
...
...
paddle/fluid/operators/fake_dequantize_op.h
浏览文件 @
1cf64e00
...
@@ -71,19 +71,25 @@ class FakeChannelWiseDequantizeMaxAbsKernel : public framework::OpKernel<T> {
...
@@ -71,19 +71,25 @@ class FakeChannelWiseDequantizeMaxAbsKernel : public framework::OpKernel<T> {
if
(
scale_num
==
1
)
{
if
(
scale_num
==
1
)
{
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
scales
[
0
]
->
numel
(),
in
->
dims
()[
0
],
scales
[
0
]
->
numel
(),
in
->
dims
()[
0
],
platform
::
errors
::
PreconditionNotMet
(
"The number of first scale values must be the same with "
"The number of first scale values must be the same with "
"first dimension value of Input(X) when the `Scales` has only one "
"first dimension value of Input(X) when the `Scales` has only "
"element."
);
"one element, but %ld != %ld here."
,
scales
[
0
]
->
numel
(),
in
->
dims
()[
0
]));
max_range
*=
(
std
::
pow
(
2
,
quant_bits
[
0
]
-
1
)
-
1
);
max_range
*=
(
std
::
pow
(
2
,
quant_bits
[
0
]
-
1
)
-
1
);
}
else
if
(
scale_num
==
2
)
{
}
else
if
(
scale_num
==
2
)
{
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
scales
[
0
]
->
numel
(),
in
->
dims
()[
1
],
scales
[
0
]
->
numel
(),
in
->
dims
()[
1
],
platform
::
errors
::
PreconditionNotMet
(
"The number of first scale values must be the same with "
"The number of first scale values must be the same with "
"second dimension value of Input(X) when the `Scales` has two "
"second dimension value of Input(X) when the `Scales` has two "
"elements."
);
"elements, but %ld != %ld here."
,
PADDLE_ENFORCE_EQ
(
scales
[
0
]
->
numel
(),
in
->
dims
()[
1
]));
scales
[
1
]
->
numel
(),
1
,
PADDLE_ENFORCE_EQ
(
scales
[
1
]
->
numel
(),
1
,
"The second scale tensor should only have one value at now."
);
platform
::
errors
::
PreconditionNotMet
(
"The second scale tensor should only have one "
"value at now, but it has %ld values here."
,
scales
[
1
]
->
numel
()));
max_range
*=
(
std
::
pow
(
2
,
quant_bits
[
0
]
-
1
)
-
1
)
*
max_range
*=
(
std
::
pow
(
2
,
quant_bits
[
0
]
-
1
)
-
1
)
*
(
std
::
pow
(
2
,
quant_bits
[
1
]
-
1
)
-
1
);
(
std
::
pow
(
2
,
quant_bits
[
1
]
-
1
)
-
1
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录