Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
56e2a6a6
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看板
未验证
提交
56e2a6a6
编写于
12月 22, 2021
作者:
J
joanna.wozna.intel
提交者:
GitHub
12月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add nearest_interp/v2 int8 and uint8 support (#37985)
上级
abb07f35
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
10 deletion
+87
-10
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
+6
-2
python/paddle/fluid/tests/unittests/mkldnn/test_nearest_interp_mkldnn_op.py
...d/tests/unittests/mkldnn/test_nearest_interp_mkldnn_op.py
+41
-4
python/paddle/fluid/tests/unittests/mkldnn/test_nearest_interp_v2_mkldnn_op.py
...ests/unittests/mkldnn/test_nearest_interp_v2_mkldnn_op.py
+40
-4
未找到文件。
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
浏览文件 @
56e2a6a6
...
...
@@ -176,11 +176,15 @@ class InterpolateMKLDNNKernel : public framework::OpKernel<T> {
namespace
ops
=
paddle
::
operators
;
REGISTER_OP_KERNEL
(
nearest_interp
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
InterpolateMKLDNNKernel
<
float
>
);
ops
::
InterpolateMKLDNNKernel
<
float
>
,
ops
::
InterpolateMKLDNNKernel
<
int8_t
>
,
ops
::
InterpolateMKLDNNKernel
<
uint8_t
>
);
REGISTER_OP_KERNEL
(
bilinear_interp
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
InterpolateMKLDNNKernel
<
float
>
);
REGISTER_OP_KERNEL
(
nearest_interp_v2
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
InterpolateMKLDNNKernel
<
float
>
);
ops
::
InterpolateMKLDNNKernel
<
float
>
,
ops
::
InterpolateMKLDNNKernel
<
int8_t
>
,
ops
::
InterpolateMKLDNNKernel
<
uint8_t
>
);
REGISTER_OP_KERNEL
(
bilinear_interp_v2
,
MKLDNN
,
::
paddle
::
platform
::
CPUPlace
,
ops
::
InterpolateMKLDNNKernel
<
float
>
);
python/paddle/fluid/tests/unittests/mkldnn/test_nearest_interp_mkldnn_op.py
浏览文件 @
56e2a6a6
...
...
@@ -16,9 +16,6 @@ from __future__ import print_function
import
unittest
import
numpy
as
np
import
paddle
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
from
paddle.fluid.tests.unittests.op_test
import
OpTest
from
paddle.fluid.tests.unittests.op_test
import
skip_check_grad_ci
...
...
@@ -66,6 +63,9 @@ class TestNearestInterpMKLDNNOp(OpTest):
def
init_test_case
(
self
):
pass
def
init_data_type
(
self
):
pass
def
setUp
(
self
):
self
.
op_type
=
"nearest_interp"
self
.
interp_method
=
'nearest'
...
...
@@ -73,6 +73,7 @@ class TestNearestInterpMKLDNNOp(OpTest):
self
.
use_mkldnn
=
True
self
.
input_shape
=
[
1
,
1
,
2
,
2
]
self
.
data_layout
=
'NCHW'
self
.
dtype
=
np
.
float32
# priority: actual_shape > out_size > scale > out_h & out_w
self
.
out_h
=
1
self
.
out_w
=
1
...
...
@@ -81,8 +82,15 @@ class TestNearestInterpMKLDNNOp(OpTest):
self
.
actual_shape
=
None
self
.
init_test_case
()
self
.
init_data_type
()
if
self
.
dtype
==
np
.
float32
:
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
self
.
dtype
)
else
:
init_low
,
init_high
=
(
-
5
,
5
)
if
self
.
dtype
==
np
.
int8
else
(
0
,
10
)
input_np
=
np
.
random
.
randint
(
init_low
,
init_high
,
self
.
input_shape
).
astype
(
self
.
dtype
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float32"
)
if
self
.
data_layout
==
"NCHW"
:
in_h
=
self
.
input_shape
[
2
]
in_w
=
self
.
input_shape
[
3
]
...
...
@@ -162,6 +170,35 @@ class TestNearestNeighborInterpSame(TestNearestInterpMKLDNNOp):
self
.
scale
=
0.
def
create_test_class
(
parent
):
class
TestFp32Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
float32
class
TestInt8Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
int8
class
TestUint8Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
uint8
TestFp32Case
.
__name__
=
parent
.
__name__
TestInt8Case
.
__name__
=
parent
.
__name__
TestUint8Case
.
__name__
=
parent
.
__name__
globals
()[
parent
.
__name__
]
=
TestFp32Case
globals
()[
parent
.
__name__
]
=
TestInt8Case
globals
()[
parent
.
__name__
]
=
TestUint8Case
create_test_class
(
TestNearestInterpMKLDNNOp
)
create_test_class
(
TestNearestInterpOpMKLDNNNHWC
)
create_test_class
(
TestNearestNeighborInterpMKLDNNCase2
)
create_test_class
(
TestNearestNeighborInterpCase3
)
create_test_class
(
TestNearestNeighborInterpCase4
)
create_test_class
(
TestNearestInterpOpMKLDNNNHWC
)
create_test_class
(
TestNearestNeighborInterpSame
)
if
__name__
==
"__main__"
:
from
paddle
import
enable_static
enable_static
()
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_nearest_interp_v2_mkldnn_op.py
浏览文件 @
56e2a6a6
...
...
@@ -16,9 +16,6 @@ from __future__ import print_function
import
unittest
import
numpy
as
np
import
paddle
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
from
paddle.fluid.tests.unittests.op_test
import
OpTest
from
paddle.fluid.tests.unittests.op_test
import
skip_check_grad_ci
...
...
@@ -66,6 +63,9 @@ class TestNearestInterpV2MKLDNNOp(OpTest):
def
init_test_case
(
self
):
pass
def
init_data_type
(
self
):
pass
def
setUp
(
self
):
self
.
op_type
=
"nearest_interp_v2"
self
.
interp_method
=
'nearest'
...
...
@@ -73,6 +73,7 @@ class TestNearestInterpV2MKLDNNOp(OpTest):
self
.
use_mkldnn
=
True
self
.
input_shape
=
[
1
,
1
,
2
,
2
]
self
.
data_layout
=
'NCHW'
self
.
dtype
=
np
.
float32
# priority: actual_shape > out_size > scale > out_h & out_w
self
.
out_h
=
1
self
.
out_w
=
1
...
...
@@ -81,8 +82,15 @@ class TestNearestInterpV2MKLDNNOp(OpTest):
self
.
actual_shape
=
None
self
.
init_test_case
()
self
.
init_data_type
()
if
self
.
dtype
==
np
.
float32
:
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
self
.
dtype
)
else
:
init_low
,
init_high
=
(
-
5
,
5
)
if
self
.
dtype
==
np
.
int8
else
(
0
,
10
)
input_np
=
np
.
random
.
randint
(
init_low
,
init_high
,
self
.
input_shape
).
astype
(
self
.
dtype
)
input_np
=
np
.
random
.
random
(
self
.
input_shape
).
astype
(
"float32"
)
if
self
.
data_layout
==
"NCHW"
:
in_h
=
self
.
input_shape
[
2
]
in_w
=
self
.
input_shape
[
3
]
...
...
@@ -178,6 +186,34 @@ class TestNearestNeighborInterpV2MKLDNNSame(TestNearestInterpV2MKLDNNOp):
self
.
out_size
=
np
.
array
([
65
,
129
]).
astype
(
"int32"
)
def
create_test_class
(
parent
):
class
TestFp32Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
float32
class
TestInt8Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
int8
class
TestUint8Case
(
parent
):
def
init_data_type
(
self
):
self
.
dtype
=
np
.
uint8
TestFp32Case
.
__name__
=
parent
.
__name__
TestInt8Case
.
__name__
=
parent
.
__name__
TestUint8Case
.
__name__
=
parent
.
__name__
globals
()[
parent
.
__name__
]
=
TestFp32Case
globals
()[
parent
.
__name__
]
=
TestInt8Case
globals
()[
parent
.
__name__
]
=
TestUint8Case
create_test_class
(
TestNearestInterpV2MKLDNNOp
)
create_test_class
(
TestNearestInterpOpV2MKLDNNNHWC
)
create_test_class
(
TestNearestNeighborInterpV2MKLDNNCase2
)
create_test_class
(
TestNearestNeighborInterpV2MKLDNNCase3
)
create_test_class
(
TestNearestNeighborInterpV2MKLDNNCase4
)
create_test_class
(
TestNearestNeighborInterpV2MKLDNNSame
)
if
__name__
==
"__main__"
:
from
paddle
import
enable_static
enable_static
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录