Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
ec1e2fc9
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
ec1e2fc9
编写于
11月 13, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cudnn_pool3d unit test
上级
7ba3d1e4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
106 addition
and
143 deletion
+106
-143
paddle/operators/pool_cudnn_op.cu
paddle/operators/pool_cudnn_op.cu
+1
-1
paddle/platform/cudnn_helper.h
paddle/platform/cudnn_helper.h
+1
-1
python/paddle/v2/framework/tests/test_pool2d_op.py
python/paddle/v2/framework/tests/test_pool2d_op.py
+26
-108
python/paddle/v2/framework/tests/test_pool3d_op.py
python/paddle/v2/framework/tests/test_pool3d_op.py
+78
-33
未找到文件。
paddle/operators/pool_cudnn_op.cu
浏览文件 @
ec1e2fc9
...
...
@@ -155,4 +155,4 @@ REGISTER_OP_GPU_KERNEL(pool2d_cudnn, ops::PoolCudnnOpKernel<float>);
REGISTER_OP_GPU_KERNEL
(
pool2d_cudnn_grad
,
ops
::
PoolCudnnGradOpKernel
<
float
>
);
REGISTER_OP_GPU_KERNEL
(
pool3d_cudnn
,
ops
::
PoolCudnnOpKernel
<
float
>
);
REGISTER_OP_GPU_KERNEL
(
pool3d_cudnn_grad
,
ops
::
PoolCudnnGradOpKernel
<
float
>
);
\ No newline at end of file
REGISTER_OP_GPU_KERNEL
(
pool3d_cudnn_grad
,
ops
::
PoolCudnnGradOpKernel
<
float
>
);
paddle/platform/cudnn_helper.h
浏览文件 @
ec1e2fc9
...
...
@@ -143,7 +143,7 @@ class ScopedTensorDescriptor {
strides
[
i
]
=
dims
[
i
+
1
]
*
strides
[
i
+
1
];
}
// Update tensor descriptor dims setting if groups > 1
// FIXME(typhoonzero): Assume using NCHW order
// FIXME(typhoonzero): Assume using NCHW or
NCDHW or
der
std
::
vector
<
int
>
dims_with_group
(
dims
.
begin
(),
dims
.
end
());
// copy
if
(
groups
>
1
)
{
dims_with_group
[
1
]
=
dims_with_group
[
1
]
/
groups
;
...
...
python/paddle/v2/framework/tests/test_pool2d_op.py
浏览文件 @
ec1e2fc9
...
...
@@ -3,8 +3,7 @@ import numpy as np
from
op_test
import
OpTest
def
max_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
def
max_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
,
global_pool
=
0
):
N
,
C
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
ksize
=
[
H
,
W
]
...
...
@@ -23,8 +22,7 @@ def max_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
return
out
def
avg_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
def
avg_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
,
global_pool
=
0
):
N
,
C
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
ksize
=
[
H
,
W
]
...
...
@@ -47,6 +45,7 @@ def avg_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class
TestPool2d_Op
(
OpTest
):
def
setUp
(
self
):
self
.
init_test_case
()
self
.
init_global_pool
()
self
.
init_op_type
()
self
.
init_pool_type
()
if
self
.
global_pool
:
...
...
@@ -75,8 +74,6 @@ class TestPool2d_Op(OpTest):
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
def
init_test_case
(
self
):
self
.
global_pool
=
True
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
...
...
@@ -87,12 +84,14 @@ class TestPool2d_Op(OpTest):
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
True
class
TestCase1
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
...
...
@@ -103,12 +102,14 @@ class TestCase1(TestPool2d_Op):
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
False
class
TestCase2
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
...
...
@@ -119,152 +120,69 @@ class TestCase2(TestPool2d_Op):
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
False
class
TestCase3
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
True
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCase3
(
TestPool2d_Op
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
class
TestCase4
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCase4
(
TestCase1
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
class
TestCase5
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
class
TestCase5
(
TestCase2
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
#--------------------test pool2d_cudnn--------------------
class
TestCaseCudnn1
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
True
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCudnnCase1
(
TestPool2d_Op
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
class
TestCaseCudnn2
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCudnnCase2
(
TestCase1
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
class
TestCaseCudnn3
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
avg_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
class
TestCudnnCase3
(
TestCase2
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
class
TestCaseCudnn4
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
True
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCudnnCase4
(
TestCase3
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
class
TestCaseCudnn5
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
0
,
0
]
class
TestCudnnCase5
(
TestCase4
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
class
TestCaseCudnn6
(
TestPool2d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
pool2D_forward_naive
=
max_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
paddings
=
[
1
,
1
]
class
TestCudnnCase6
(
TestCase5
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool2d_cudnn"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/v2/framework/tests/test_pool3d_op.py
浏览文件 @
ec1e2fc9
...
...
@@ -3,7 +3,7 @@ import numpy as np
from
op_test
import
OpTest
def
max_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
]
,
global_pool
=
0
):
def
max_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
,
global_pool
=
0
):
N
,
C
,
D
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
...
...
@@ -27,7 +27,7 @@ def max_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
return
out
def
avg_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
]
,
global_pool
=
0
):
def
avg_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
,
global_pool
=
0
):
N
,
C
,
D
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
...
...
@@ -55,6 +55,10 @@ def avg_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
class
TestPool3d_Op
(
OpTest
):
def
setUp
(
self
):
self
.
init_test_case
()
self
.
init_global_pool
()
self
.
init_op_type
()
self
.
init_pool_type
()
if
self
.
global_pool
:
self
.
paddings
=
[
0
for
_
in
range
(
len
(
self
.
paddings
))]
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
...
...
@@ -81,74 +85,115 @@ class TestPool3d_Op(OpTest):
self
.
check_grad
(
set
([
'X'
]),
'Out'
,
max_relative_error
=
0.07
)
def
init_test_case
(
self
):
self
.
global_pool
=
True
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
True
class
TestCase1
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase2
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
False
class
TestCase2
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
self
.
pool3D_forward_naive
=
avg_pool3D_forward_naive
def
init_global_pool
(
self
):
self
.
global_pool
=
False
class
TestCase3
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
True
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase4
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
class
TestCase4
(
TestCase1
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
class
TestCase5
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
global_pool
=
False
class
TestCase5
(
TestCase2
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_pool_type
(
self
):
self
.
pool_type
=
"max"
self
.
pool3D_forward_naive
=
max_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
1
,
1
,
1
]
#--------------------test pool3d_cudnn--------------------
class
TestCudnnCase1
(
TestPool3d_Op
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
class
TestCudnnCase2
(
TestCase1
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
class
TestCudnnCase3
(
TestCase2
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
class
TestCudnnCase4
(
TestCase3
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
class
TestCudnnCase5
(
TestCase4
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
class
TestCudnnCase6
(
TestCase5
):
def
init_op_type
(
self
):
self
.
op_type
=
"pool3d_cudnn"
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录