Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1dfd857b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
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看板
未验证
提交
1dfd857b
编写于
7月 19, 2021
作者:
J
joanna.wozna.intel
提交者:
GitHub
7月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix format in requantize mkldnn op (#34137)
上级
9bc59673
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
6 deletion
+21
-6
paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc
paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc
+2
-4
python/paddle/fluid/tests/unittests/mkldnn/test_requantize_mkldnn_op.py
...fluid/tests/unittests/mkldnn/test_requantize_mkldnn_op.py
+19
-2
未找到文件。
paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc
浏览文件 @
1dfd857b
...
@@ -84,12 +84,10 @@ class ReQuantOpKernel : public framework::OpKernel<T> {
...
@@ -84,12 +84,10 @@ class ReQuantOpKernel : public framework::OpKernel<T> {
auto
src_dt
=
framework
::
ToMKLDNNDataType
(
input
->
type
());
auto
src_dt
=
framework
::
ToMKLDNNDataType
(
input
->
type
());
auto
dst_dt
=
with_shift
?
framework
::
MKLDNNDataType
::
u8
:
src_dt
;
auto
dst_dt
=
with_shift
?
framework
::
MKLDNNDataType
::
u8
:
src_dt
;
auto
src_md
=
auto
src_md
=
platform
::
MKLDNNMemDesc
({
src_tz
},
src_dt
,
input
->
format
());
platform
::
MKLDNNMemDesc
({
src_tz
},
src_dt
,
MKLDNNMemoryFormat
::
nhwc
);
src_memory
=
std
::
make_shared
<
dnnl
::
memory
>
(
src_md
,
engine
,
src_memory
=
std
::
make_shared
<
dnnl
::
memory
>
(
src_md
,
engine
,
to_void_cast
<
T
>
(
input_data
));
to_void_cast
<
T
>
(
input_data
));
auto
dst_md
=
auto
dst_md
=
platform
::
MKLDNNMemDesc
({
dst_tz
},
dst_dt
,
input
->
format
());
platform
::
MKLDNNMemDesc
({
dst_tz
},
dst_dt
,
MKLDNNMemoryFormat
::
nhwc
);
dnnl
::
primitive_attr
attri
;
dnnl
::
primitive_attr
attri
;
int
mask
=
0
;
int
mask
=
0
;
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_requantize_mkldnn_op.py
浏览文件 @
1dfd857b
...
@@ -23,14 +23,18 @@ from mkldnn_op_test import format_reorder
...
@@ -23,14 +23,18 @@ from mkldnn_op_test import format_reorder
class
TestReQuantizeOp
(
OpTest
):
class
TestReQuantizeOp
(
OpTest
):
def
set_input_size
(
self
):
self
.
input_size
=
[
1
,
1
,
10
,
10
]
self
.
format_reorder
=
format_reorder
def
setUp
(
self
):
def
setUp
(
self
):
self
.
op_type
=
'requantize'
self
.
op_type
=
'requantize'
self
.
scale_in
=
127.0
self
.
scale_in
=
127.0
self
.
shift_in
=
0.0
self
.
shift_in
=
0.0
self
.
scale_out
=
100.0
self
.
scale_out
=
100.0
self
.
shift_out
=
0.0
self
.
shift_out
=
0.0
self
.
input_size
=
[
1
,
1
,
10
,
10
]
self
.
input_data_type
=
'int8'
self
.
input_data_type
=
'int8'
self
.
set_input_size
()
self
.
set_scales
()
self
.
set_scales
()
self
.
set_shifts
()
self
.
set_shifts
()
self
.
set_input_data_type
()
self
.
set_input_data_type
()
...
@@ -76,7 +80,7 @@ class TestReQuantizeOp(OpTest):
...
@@ -76,7 +80,7 @@ class TestReQuantizeOp(OpTest):
np
.
rint
(
self
.
input
.
astype
(
'float32'
)
*
scale_ratio
+
new_shift
),
np
.
rint
(
self
.
input
.
astype
(
'float32'
)
*
scale_ratio
+
new_shift
),
type_min
,
type_max
).
astype
(
dst_type
)
type_min
,
type_max
).
astype
(
dst_type
)
self
.
output
=
format_reorder
(
output_tmp
,
self
.
input_size
)
self
.
output
=
self
.
format_reorder
(
output_tmp
,
self
.
input_size
)
self
.
outputs
=
{
'Output'
:
self
.
output
}
self
.
outputs
=
{
'Output'
:
self
.
output
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
...
@@ -266,6 +270,18 @@ class TestReQuantizeOp_U8_DifferentScales_2_DifferentShift_2(
...
@@ -266,6 +270,18 @@ class TestReQuantizeOp_U8_DifferentScales_2_DifferentShift_2(
self
.
shift_out
=
128.0
self
.
shift_out
=
128.0
# ---------------test non-four dimentional formats--------------------------
class
TestReQuantizeOp_2DimFormat
(
TestReQuantizeOp
):
def
format_reorder_2Dim
(
self
,
out
,
size
):
return
out
def
set_input_size
(
self
):
self
.
input_size
=
[
10
,
20
]
self
.
format_reorder
=
self
.
format_reorder_2Dim
# ---------------test reused requantize op, no shift------------------------
# ---------------test reused requantize op, no shift------------------------
...
@@ -274,6 +290,7 @@ class TestReQuantizeOpReused(TestReQuantizeOp):
...
@@ -274,6 +290,7 @@ class TestReQuantizeOpReused(TestReQuantizeOp):
# self.input_size = [1, 1, 10, 10]
# self.input_size = [1, 1, 10, 10]
self
.
input_size
=
[
1
,
1
,
2
,
2
]
self
.
input_size
=
[
1
,
1
,
2
,
2
]
self
.
input_data_type
=
'int8'
self
.
input_data_type
=
'int8'
self
.
format_reorder
=
format_reorder
self
.
set_scales
()
self
.
set_scales
()
self
.
set_shifts
()
self
.
set_shifts
()
self
.
set_input_data_type
()
self
.
set_input_data_type
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录