Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
55e714e0
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看板
提交
55e714e0
编写于
5月 05, 2018
作者:
K
Kexin Zhao
提交者:
Kexin Zhao
5月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add float16 support to pool3d
上级
8b169272
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
91 addition
and
36 deletion
+91
-36
paddle/fluid/operators/pool_cudnn_op.cu.cc
paddle/fluid/operators/pool_cudnn_op.cu.cc
+2
-1
python/paddle/fluid/tests/unittests/test_pool3d_op.py
python/paddle/fluid/tests/unittests/test_pool3d_op.py
+89
-35
未找到文件。
paddle/fluid/operators/pool_cudnn_op.cu.cc
浏览文件 @
55e714e0
...
...
@@ -174,7 +174,8 @@ REGISTER_OP_KERNEL(pool2d_grad, CUDNN, plat::CUDAPlace,
REGISTER_OP_KERNEL
(
pool3d
,
CUDNN
,
plat
::
CUDAPlace
,
ops
::
PoolCUDNNOpKernel
<
float
>
,
ops
::
PoolCUDNNOpKernel
<
double
>
);
ops
::
PoolCUDNNOpKernel
<
double
>
,
ops
::
PoolCUDNNOpKernel
<
plat
::
float16
>
);
REGISTER_OP_KERNEL
(
pool3d_grad
,
CUDNN
,
plat
::
CUDAPlace
,
ops
::
PoolCUDNNGradOpKernel
<
float
>
,
ops
::
PoolCUDNNGradOpKernel
<
double
>
);
python/paddle/fluid/tests/unittests/test_pool3d_op.py
浏览文件 @
55e714e0
...
...
@@ -90,20 +90,22 @@ def avg_pool3D_forward_naive(x,
class
TestPool3d_Op
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"pool3d"
self
.
use_cudnn
=
False
self
.
dtype
=
np
.
float32
self
.
init_test_case
()
self
.
init_global_pool
()
self
.
init_
op
_type
()
self
.
init_
kernel
_type
()
self
.
init_pool_type
()
self
.
init_ceil_mode
()
if
self
.
global_pool
:
self
.
paddings
=
[
0
for
_
in
range
(
len
(
self
.
paddings
))]
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
"float32"
)
input
=
np
.
random
.
random
(
self
.
shape
).
astype
(
self
.
dtype
)
output
=
self
.
pool3D_forward_naive
(
input
,
self
.
ksize
,
self
.
strides
,
self
.
paddings
,
self
.
global_pool
,
self
.
ceil_mode
).
astype
(
"float32"
)
self
.
inputs
=
{
'X'
:
input
}
self
.
ceil_mode
).
astype
(
self
.
dtype
)
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
input
)
}
self
.
attrs
=
{
'strides'
:
self
.
strides
,
...
...
@@ -116,7 +118,7 @@ class TestPool3d_Op(OpTest):
'data_format'
:
'AnyLayout'
# TODO(dzhwinter) : should be fix latter
}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float32'
)
}
self
.
outputs
=
{
'Out'
:
output
}
def
testcudnn
(
self
):
return
core
.
is_compiled_with_cuda
()
and
self
.
use_cudnn
...
...
@@ -129,6 +131,8 @@ class TestPool3d_Op(OpTest):
self
.
check_output
()
def
test_check_grad
(
self
):
if
self
.
dtype
==
np
.
float16
:
return
if
self
.
testcudnn
()
and
self
.
pool_type
!=
"max"
:
place
=
core
.
CUDAPlace
(
0
)
self
.
check_grad_with_place
(
...
...
@@ -142,8 +146,8 @@ class TestPool3d_Op(OpTest):
self
.
strides
=
[
1
,
1
,
1
]
self
.
paddings
=
[
0
,
0
,
0
]
def
init_
op
_type
(
self
):
self
.
op_type
=
"pool3d"
def
init_
kernel
_type
(
self
):
pass
def
init_pool_type
(
self
):
self
.
pool_type
=
"avg"
...
...
@@ -158,15 +162,11 @@ class TestPool3d_Op(OpTest):
class
TestCase1
(
TestPool3d_Op
):
def
init_test_case
(
self
):
self
.
op_type
=
"pool3d"
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
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
...
...
@@ -182,9 +182,6 @@ class TestCase2(TestPool3d_Op):
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
...
...
@@ -194,27 +191,18 @@ class TestCase2(TestPool3d_Op):
class
TestCase3
(
TestPool3d_Op
):
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
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
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
...
...
@@ -222,39 +210,105 @@ class TestCase5(TestCase2):
#--------------------test pool3d--------------------
class
TestCUDNNCase1
(
TestPool3d_Op
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase1
(
TestPool3d_Op
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCUDNNCase2
(
TestCase1
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase2
(
TestCase1
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCUDNNCase3
(
TestCase2
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase3
(
TestCase2
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCUDNNCase4
(
TestCase3
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase4
(
TestCase3
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCUDNNCase5
(
TestCase4
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase5
(
TestCase4
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCUDNNCase6
(
TestCase5
):
def
init_
op
_type
(
self
):
def
init_
kernel
_type
(
self
):
self
.
use_cudnn
=
True
self
.
op_type
=
"pool3d"
class
TestFP16CUDNNCase6
(
TestCase5
):
def
init_kernel_type
(
self
):
self
.
use_cudnn
=
True
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
if
core
.
is_compiled_with_cuda
():
place
=
core
.
CUDAPlace
(
0
)
if
core
.
is_float16_supported
(
place
):
self
.
check_output_with_place
(
place
,
atol
=
1e-3
)
class
TestCeilModeCase1
(
TestCUDNNCase1
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录