Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
2ce6473f
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
提交
2ce6473f
编写于
8月 31, 2019
作者:
W
wozna
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test_transpose_int8_mkldnn
test=develop
上级
61403f87
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
10 deletion
+14
-10
paddle/fluid/inference/api/mkldnn_quantizer_config.cc
paddle/fluid/inference/api/mkldnn_quantizer_config.cc
+2
-2
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
+3
-2
python/paddle/fluid/tests/unittests/mkldnn/test_transpose_int8_mkldnn_op.py
...d/tests/unittests/mkldnn/test_transpose_int8_mkldnn_op.py
+9
-6
未找到文件。
paddle/fluid/inference/api/mkldnn_quantizer_config.cc
浏览文件 @
2ce6473f
...
@@ -35,8 +35,8 @@ MkldnnQuantizerConfig::MkldnnQuantizerConfig() {
...
@@ -35,8 +35,8 @@ MkldnnQuantizerConfig::MkldnnQuantizerConfig() {
rules_
[
"prior_box"
][
"Boxes"
]
=
ScaleAlgo
::
NONE
;
rules_
[
"prior_box"
][
"Boxes"
]
=
ScaleAlgo
::
NONE
;
rules_
[
"prior_box"
][
"Variances"
]
=
ScaleAlgo
::
NONE
;
rules_
[
"prior_box"
][
"Variances"
]
=
ScaleAlgo
::
NONE
;
rules_
[
"transpose"
][
"X"
]
=
ScaleAlgo
::
KL
;
rules_
[
"transpose
2
"
][
"X"
]
=
ScaleAlgo
::
KL
;
rules_
[
"transpose"
][
"Out"
]
=
ScaleAlgo
::
KL
;
rules_
[
"transpose
2
"
][
"Out"
]
=
ScaleAlgo
::
KL
;
}
}
ScaleAlgo
MkldnnQuantizerConfig
::
scale_algo
(
ScaleAlgo
MkldnnQuantizerConfig
::
scale_algo
(
...
...
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
浏览文件 @
2ce6473f
...
@@ -86,8 +86,9 @@ class DeQuantOpKernel : public framework::OpKernel<T> {
...
@@ -86,8 +86,9 @@ class DeQuantOpKernel : public framework::OpKernel<T> {
std
::
shared_ptr
<
primitive
::
at
>
src_memory_p
=
std
::
shared_ptr
<
primitive
::
at
>
src_memory_p
=
std
::
shared_ptr
<
primitive
::
at
>
(
new
primitive
::
at
(
*
src_memory
));
std
::
shared_ptr
<
primitive
::
at
>
(
new
primitive
::
at
(
*
src_memory
));
auto
dst_md
=
platform
::
MKLDNNMemDesc
({
dst_tz
},
memory
::
data_type
::
f32
,
auto
dst_md
=
platform
::
MKLDNNMemDesc
(
memory
::
format
::
nchw
);
{
dst_tz
},
memory
::
data_type
::
f32
,
platform
::
MKLDNNFormatForSize
(
dst_tz
.
size
(),
memory
::
format
::
nchw
));
auto
dst_pd
=
mkldnn
::
memory
::
primitive_desc
(
dst_md
,
engine
);
auto
dst_pd
=
mkldnn
::
memory
::
primitive_desc
(
dst_md
,
engine
);
dst_memory
=
std
::
make_shared
<
mkldnn
::
memory
>
(
dst_memory
=
std
::
make_shared
<
mkldnn
::
memory
>
(
dst_pd
,
to_void_cast
<
float
>
(
output_data
));
dst_pd
,
to_void_cast
<
float
>
(
output_data
));
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_transpose_int8_mkldnn_op.py
浏览文件 @
2ce6473f
...
@@ -16,6 +16,7 @@ from __future__ import print_function
...
@@ -16,6 +16,7 @@ from __future__ import print_function
import
unittest
import
unittest
import
numpy
as
np
import
numpy
as
np
import
paddle.fluid.core
as
core
from
paddle.fluid.tests.unittests.op_test
import
OpTest
from
paddle.fluid.tests.unittests.op_test
import
OpTest
from
mkldnn_op_test
import
format_reorder
from
mkldnn_op_test
import
format_reorder
...
@@ -26,10 +27,11 @@ class TestTransposeOp(OpTest):
...
@@ -26,10 +27,11 @@ class TestTransposeOp(OpTest):
self
.
initTestCase
()
self
.
initTestCase
()
self
.
initInputData
()
self
.
initInputData
()
self
.
use_mkldnn
=
True
self
.
use_mkldnn
=
True
self
.
_cpu_only
=
True
self
.
axis
=
(
0
,
2
,
3
,
1
)
self
.
axis
=
(
0
,
2
,
3
,
1
)
self
.
inputs
=
{
self
.
inputs
=
{
'X'
:
format_reorder
(
self
.
input_data
,
self
.
shape
)
'X'
:
format_reorder
(
self
.
input_data
,
self
.
shape
)
.
astype
(
np
.
int8
)
}
#transform data format to 'NHWC' for INT8 transpose specially.
}
#transform data format to 'NHWC' for INT8 transpose specially.
self
.
attrs
=
{
self
.
attrs
=
{
...
@@ -38,7 +40,7 @@ class TestTransposeOp(OpTest):
...
@@ -38,7 +40,7 @@ class TestTransposeOp(OpTest):
}
}
self
.
outputs
=
{
self
.
outputs
=
{
'XShape'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
'int8'
),
'XShape'
:
np
.
random
.
random
(
self
.
shape
).
astype
(
np
.
int8
),
'Out'
:
self
.
inputs
[
'X'
].
transpose
(
self
.
axis
)
'Out'
:
self
.
inputs
[
'X'
].
transpose
(
self
.
axis
)
}
}
...
@@ -46,14 +48,15 @@ class TestTransposeOp(OpTest):
...
@@ -46,14 +48,15 @@ class TestTransposeOp(OpTest):
self
.
op_type
=
"transpose2"
self
.
op_type
=
"transpose2"
def
test_check_output
(
self
):
def
test_check_output
(
self
):
self
.
check_output
(
no_check_set
=
[
'XShape'
])
self
.
check_output_with_place
(
core
.
CPUPlace
(),
1e-5
,
no_check_set
=
[
'XShape'
])
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
shape
=
(
2
,
3
,
4
,
5
)
self
.
shape
=
(
2
,
3
,
4
,
5
)
def
initInputData
(
self
):
def
initInputData
(
self
):
self
.
input_data
=
(
self
.
input_data
=
(
np
.
random
.
randint
(
0
,
100
,
self
.
shape
)
-
50
).
astype
(
'int8'
)
np
.
random
.
randint
(
0
,
100
,
self
.
shape
)
-
50
).
astype
(
np
.
int8
)
class
TestINT8Case
(
TestTransposeOp
):
class
TestINT8Case
(
TestTransposeOp
):
...
@@ -62,7 +65,7 @@ class TestINT8Case(TestTransposeOp):
...
@@ -62,7 +65,7 @@ class TestINT8Case(TestTransposeOp):
def
initInputData
(
self
):
def
initInputData
(
self
):
self
.
input_data
=
(
self
.
input_data
=
(
np
.
random
.
randint
(
0
,
100
,
self
.
shape
)
-
50
).
astype
(
'int8'
)
np
.
random
.
randint
(
0
,
100
,
self
.
shape
)
-
50
).
astype
(
np
.
int8
)
class
TestUINT8Case
(
TestTransposeOp
):
class
TestUINT8Case
(
TestTransposeOp
):
...
@@ -71,7 +74,7 @@ class TestUINT8Case(TestTransposeOp):
...
@@ -71,7 +74,7 @@ class TestUINT8Case(TestTransposeOp):
def
initDataType
(
self
):
def
initDataType
(
self
):
self
.
input_data
=
(
np
.
random
.
randint
(
0
,
100
,
self
.
input_data
=
(
np
.
random
.
randint
(
0
,
100
,
self
.
shape
)).
astype
(
'uint8'
)
self
.
shape
)).
astype
(
np
.
uint8
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录