Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
55e63763
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看板
未验证
提交
55e63763
编写于
10月 12, 2020
作者:
J
Jacek Czaja
提交者:
GitHub
10月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[oneDNN] adaptive pool support (#27747)
上级
6335e6a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
0 deletion
+60
-0
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
+3
-0
paddle/fluid/platform/mkldnn_reuse.h
paddle/fluid/platform/mkldnn_reuse.h
+24
-0
python/paddle/fluid/tests/unittests/mkldnn/test_pool2d_mkldnn_op.py
...dle/fluid/tests/unittests/mkldnn/test_pool2d_mkldnn_op.py
+33
-0
未找到文件。
paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc
浏览文件 @
55e63763
...
...
@@ -126,6 +126,9 @@ class PoolMKLDNNGradOpKernel : public paddle::framework::OpKernel<T> {
UpdatePadding
(
&
paddings
,
global_pooling
,
0
,
padding_algorithm
,
data_dims
,
strides
,
ksize
);
platform
::
PoolingMKLDNNHandler
<
T
>::
ComputeAdaptivePoolParameters
(
ctx
,
paddle
::
framework
::
vectorize
(
in_x
->
dims
()),
ksize
,
strides
);
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
MKLDNNDeviceContext
>();
...
...
paddle/fluid/platform/mkldnn_reuse.h
浏览文件 @
55e63763
...
...
@@ -853,6 +853,9 @@ class PoolingMKLDNNHandler : public MKLDNNHandlerT<T, mkldnn::pooling_forward,
CorrectOutputSize
(
src_tz
,
dst_tz
,
ksize
,
paddings
,
strides
,
mkldnn_paddings
[
1
]);
}
ComputeAdaptivePoolParameters
(
ctx
,
src_tz
,
ksize
,
strides
);
this
->
AcquireForwardPrimitiveDescriptor
(
is_test
?
mkldnn
::
prop_kind
::
forward_inference
:
mkldnn
::
prop_kind
::
forward_training
,
...
...
@@ -919,6 +922,27 @@ class PoolingMKLDNNHandler : public MKLDNNHandlerT<T, mkldnn::pooling_forward,
return
mem_p
;
}
static
void
ComputeAdaptivePoolParameters
(
const
paddle
::
framework
::
ExecutionContext
&
ctx
,
const
std
::
vector
<
int64_t
>&
src_tz
,
std
::
vector
<
int64_t
>&
ksize
,
std
::
vector
<
int64_t
>&
strides
)
{
if
(
ctx
.
Attr
<
bool
>
(
"adaptive"
))
{
// (jczaja): oneDNN is supporting only unchangable in size pool window
PADDLE_ENFORCE_EQ
(
src_tz
[
src_tz
.
size
()
-
1
]
%
ksize
[
1
],
0
,
platform
::
errors
::
Unimplemented
(
"Input dim must be divisible by corressponding ksize dim."
));
PADDLE_ENFORCE_EQ
(
src_tz
[
src_tz
.
size
()
-
2
]
%
ksize
[
0
],
0
,
platform
::
errors
::
Unimplemented
(
"Input dim must be divisible by corressponding ksize dim."
));
ksize
[
0
]
=
src_tz
[
src_tz
.
size
()
-
2
]
/
ksize
[
0
];
ksize
[
1
]
=
src_tz
[
src_tz
.
size
()
-
1
]
/
ksize
[
1
];
strides
[
0
]
=
ksize
[
0
];
strides
[
1
]
=
ksize
[
1
];
}
}
private:
static
inline
int
ComputeCeiledOutput
(
int
input_size
,
int
kernel_size
,
int
padding
,
int
stride
)
{
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_pool2d_mkldnn_op.py
浏览文件 @
55e63763
...
...
@@ -61,6 +61,37 @@ create_test_mkldnn_class(TestCase4)
create_test_mkldnn_class
(
TestCase5
)
class
TestAvgPoolAdaptive
(
TestPool2D_Op
):
def
init_adaptive
(
self
):
self
.
adaptive
=
True
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
def
init_test_case
(
self
):
self
.
ksize
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
def
init_data_type
(
self
):
self
.
dtype
=
np
.
float32
def
init_global_pool
(
self
):
self
.
global_pool
=
False
class
TestAvgPoolAdaptive2
(
TestAvgPoolAdaptive
):
def
init_test_case
(
self
):
self
.
ksize
=
[
2
,
3
]
self
.
strides
=
[
1
,
1
]
def
init_shape
(
self
):
self
.
shape
=
[
2
,
3
,
6
,
6
]
class
TestAsymPad
(
TestPool2D_Op
):
def
init_test_case
(
self
):
self
.
ksize
=
[
3
,
3
]
...
...
@@ -160,4 +191,6 @@ class TestAsymPadValidNHWC(TestAsymPadValid):
if
__name__
==
'__main__'
:
from
paddle
import
enable_static
enable_static
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录