Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b60124e8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
b60124e8
编写于
12月 04, 2018
作者:
Z
Zhang, Guoming
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'prv-calibration'
上级
782954b4
9a5b560f
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
437 addition
and
370 deletion
+437
-370
paddle/fluid/operators/conv_mkldnn_op.cc
paddle/fluid/operators/conv_mkldnn_op.cc
+406
-346
paddle/fluid/operators/conv_op.cc
paddle/fluid/operators/conv_op.cc
+24
-15
paddle/fluid/operators/dequantize_op.cc
paddle/fluid/operators/dequantize_op.cc
+3
-4
paddle/fluid/operators/quantize_op.cc
paddle/fluid/operators/quantize_op.cc
+4
-5
未找到文件。
paddle/fluid/operators/conv_mkldnn_op.cc
浏览文件 @
b60124e8
此差异已折叠。
点击以展开。
paddle/fluid/operators/conv_op.cc
浏览文件 @
b60124e8
...
...
@@ -131,21 +131,14 @@ void Conv2DOpMaker::Make() {
"The format of output tensor is X (one-dimensional) of size equal"
"to the number of output channels. Only used with MKL-DNN."
)
.
AsDispensable
();
AddInput
(
"Scale_in"
,
"(Tensor) Scale_in to be used for int8 input data."
"Only used with INT8."
)
.
AsDispensable
();
AddInput
(
"Scale_in_eltwise"
,
"(Tensor) Scale_in_eltwise to be used for int8 eltwise input data."
"Only used with MKL-DNN."
)
.
AsDispensable
();
AddInput
(
"Scale_weights"
,
"(Tensor) Scale_weights to be used for int8 weights data."
"Only used with MKL-DNN."
)
.
AsDispensable
();
AddInput
(
"Scale_out"
,
"(Tensor) Scale_out to be used for int8 output data."
"Only used with MKL-DNN."
)
AddOutput
(
"Output"
,
"(Tensor) The output tensor of convolution operator. "
"The format of output tensor is also NCHW."
);
AddInput
(
"ResidualData"
,
"(Tensor) Tensor with residual data "
"to which convolution output will be added."
"Used with fuse_residual_connection fusion."
)
.
AsDispensable
();
AddOutput
(
"Output"
,
"(Tensor) The output tensor of convolution operator. "
...
...
@@ -193,6 +186,22 @@ void Conv2DOpMaker::Make() {
"whenever convolution output is as an input to residual "
"connection."
)
.
SetDefault
(
false
);
AddAttr
<
float
>
(
"Scale_in"
,
"Scale_in to be used for int8 input data."
"Only used with INT8."
)
.
SetDefault
(
1.0
f
);
AddAttr
<
float
>
(
"Scale_out"
,
"Scale_out to be used for int8 output data."
"Only used with MKL-DNN."
)
.
SetDefault
(
1.0
f
);
AddAttr
<
float
>
(
"Scale_in_eltwise"
,
"Scale_in_eltwise to be used for int8 eltwise input data."
"Only used with MKL-DNN."
)
.
SetDefault
(
1.0
f
);
AddAttr
<
std
::
vector
<
float
>>
(
"Scale_weights"
,
"Scale_weights to be used for int8 weights data."
"Only used with MKL-DNN."
)
.
SetDefault
({
1.0
f
});
AddAttr
<
bool
>
(
"force_fp32_output"
,
"(bool, default false) Force INT8 kernel output FP32, only used in mkldnn kernel"
)
.
SetDefault
(
false
);
AddAttr
<
std
::
string
>
(
...
...
paddle/fluid/operators/dequantize_op.cc
浏览文件 @
b60124e8
...
...
@@ -37,7 +37,7 @@ class DeQuantOpKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
*
input
=
ctx
.
Input
<
Tensor
>
(
"Input"
);
auto
*
scale
=
ctx
.
Input
<
Tensor
>
(
"Scale"
);
auto
scale_data
=
ctx
.
Attr
<
float
>
(
"Scale"
);
auto
*
output
=
ctx
.
Output
<
Tensor
>
(
"Output"
);
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
MKLDNNDeviceContext
>();
...
...
@@ -45,8 +45,7 @@ class DeQuantOpKernel : public framework::OpKernel<T> {
const
T
*
input_data
=
input
->
data
<
T
>
();
float
*
output_data
=
output
->
mutable_data
<
float
>
(
ctx
.
GetPlace
());
std
::
vector
<
float
>
scale_data
=
{
*
(
scale
->
data
<
float
>
())};
std
::
vector
<
float
>
reorder_scale
=
{
1.0
f
/
scale_data
[
0
]};
std
::
vector
<
float
>
reorder_scale
=
{
1.0
f
/
scale_data
};
std
::
vector
<
primitive
>
pipeline
;
std
::
vector
<
int
>
src_tz
=
paddle
::
framework
::
vectorize2int
(
input
->
dims
());
...
...
@@ -99,8 +98,8 @@ framework::OpKernelType DeQuantOp::GetExpectedKernelType(const framework::Execut
void
DeQuantOpMaker
::
Make
()
{
AddInput
(
"Input"
,
"input data"
);
AddInput
(
"Scale"
,
"scale data"
);
AddOutput
(
"Output"
,
"output data"
);
AddAttr
<
float
>
(
"Scale"
,
"scale data"
).
SetDefault
({
1.0
f
});
AddComment
(
R"DOC(This op will quantize data from INT8 to FP32)DOC"
);
}
...
...
paddle/fluid/operators/quantize_op.cc
浏览文件 @
b60124e8
...
...
@@ -35,7 +35,7 @@ class QuantOpKernel : public framework::OpKernel<T> {
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
*
input
=
ctx
.
Input
<
Tensor
>
(
"Input"
);
auto
*
scale
=
ctx
.
Input
<
Tensor
>
(
"Scale"
);
auto
scale_data
=
ctx
.
Attr
<
float
>
(
"Scale"
);
auto
*
output
=
ctx
.
Output
<
Tensor
>
(
"Output"
);
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
MKLDNNDeviceContext
>();
...
...
@@ -47,11 +47,9 @@ class QuantOpKernel : public framework::OpKernel<T> {
const
T
*
input_data
=
input
->
data
<
T
>
();
std
::
vector
<
T
>
scale_data
=
{
*
(
scale
->
data
<
T
>
())};
mkldnn
::
primitive_attr
attri
;
int
mask
=
0
;
attri
.
set_output_scales
(
mask
,
scale_data
);
attri
.
set_output_scales
(
mask
,
{
scale_data
}
);
auto
src_md
=
platform
::
MKLDNNMemDesc
(
{
src_tz
},
memory
::
data_type
::
f32
,
input
->
format
());
...
...
@@ -108,11 +106,12 @@ framework::OpKernelType QuantOp::GetExpectedKernelType(const framework::Executio
void
QuantOpMaker
::
Make
()
{
AddInput
(
"Input"
,
"input data"
);
AddInput
(
"Scale"
,
"scale data"
);
AddOutput
(
"Output"
,
"output data"
);
AddAttr
<
bool
>
(
"is_negative_input"
,
"(bool, default false) Only used in mkldnn INT8 kernel"
)
.
SetDefault
(
false
);
AddAttr
<
float
>
(
"Scale"
,
"scale data"
)
.
SetDefault
({
1.0
f
});
AddComment
(
R"DOC(This op will quantize data from FP32 to INT8)DOC"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录