Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
b7285438
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b7285438
编写于
9月 25, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix (According to the review)
上级
b0a47b14
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
87 addition
and
62 deletion
+87
-62
paddle/operators/math/pooling.cc
paddle/operators/math/pooling.cc
+20
-12
paddle/operators/math/pooling.cu
paddle/operators/math/pooling.cu
+20
-12
paddle/operators/math/pooling.h
paddle/operators/math/pooling.h
+13
-4
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+4
-4
paddle/operators/pool_op.h
paddle/operators/pool_op.h
+16
-16
python/paddle/v2/framework/tests/test_pool2d_op.py
python/paddle/v2/framework/tests/test_pool2d_op.py
+7
-7
python/paddle/v2/framework/tests/test_pool3d_op.py
python/paddle/v2/framework/tests/test_pool3d_op.py
+7
-7
未找到文件。
paddle/operators/math/pooling.cc
浏览文件 @
b7285438
...
@@ -137,19 +137,23 @@ class Pool2dBackwardFunctor<platform::CPUPlace, PoolProcess, T> {
...
@@ -137,19 +137,23 @@ class Pool2dBackwardFunctor<platform::CPUPlace, PoolProcess, T> {
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
float
>,
float
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
float
>,
float
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
float
>,
float
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
double
>,
double
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
double
>,
double
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
double
>,
double
>
;
template
<
typename
PoolProcess
,
class
T
>
template
<
typename
PoolProcess
,
class
T
>
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
PoolProcess
,
T
>
{
...
@@ -302,19 +306,23 @@ class Pool3dBackwardFunctor<platform::CPUPlace, PoolProcess, T> {
...
@@ -302,19 +306,23 @@ class Pool3dBackwardFunctor<platform::CPUPlace, PoolProcess, T> {
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
float
>,
float
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
float
>,
float
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
float
>,
float
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
float
>,
float
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
double
>,
double
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
double
>,
double
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
double
>,
double
>
;
platform
::
CPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
double
>,
double
>
;
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
}
// namespace paddle
}
// namespace paddle
paddle/operators/math/pooling.cu
浏览文件 @
b7285438
...
@@ -190,19 +190,23 @@ class Pool2dBackwardFunctor<platform::GPUPlace, PoolProcess, T> {
...
@@ -190,19 +190,23 @@ class Pool2dBackwardFunctor<platform::GPUPlace, PoolProcess, T> {
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
float
>,
float
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
float
>,
float
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
float
>,
float
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
template
class
Pool2dForwardFunctor
<
template
class
Pool2dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
double
>,
double
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
double
>,
double
>
;
template
class
Pool2dBackwardFunctor
<
template
class
Pool2dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
double
>,
double
>
;
template
<
typename
PoolProcess
,
typename
T
>
template
<
typename
PoolProcess
,
typename
T
>
__global__
void
KernelPool3DForward
(
__global__
void
KernelPool3DForward
(
...
@@ -414,19 +418,23 @@ class Pool3dBackwardFunctor<platform::GPUPlace, PoolProcess, T> {
...
@@ -414,19 +418,23 @@ class Pool3dBackwardFunctor<platform::GPUPlace, PoolProcess, T> {
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
float
>,
float
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
float
>,
float
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
float
>,
float
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
float
>,
float
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
template
class
Pool3dForwardFunctor
<
template
class
Pool3dForwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
double
>,
double
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
maxPoolGrad
<
double
>,
double
>
;
template
class
Pool3dBackwardFunctor
<
template
class
Pool3dBackwardFunctor
<
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avePool
<
double
>,
double
>
;
platform
::
GPUPlace
,
paddle
::
operators
::
math
::
pool
::
avgPoolGrad
<
double
>,
double
>
;
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
...
...
paddle/operators/math/pooling.h
浏览文件 @
b7285438
...
@@ -33,6 +33,18 @@ class maxPool {
...
@@ -33,6 +33,18 @@ class maxPool {
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
-
FLT_MAX
);
}
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
-
FLT_MAX
);
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
=
y
>
x
?
y
:
x
;
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
=
y
>
x
?
y
:
x
;
}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{}
};
template
<
class
T
>
class
avgPool
{
public:
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
0
);
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
+=
x
;
}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{
y
/=
poo_size
;
}
};
template
<
class
T
>
class
maxPoolGrad
{
public:
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
T
scale
)
{
dx
+=
dy
*
(
x
==
y
);
dx
+=
dy
*
(
x
==
y
);
...
@@ -40,11 +52,8 @@ class maxPool {
...
@@ -40,11 +52,8 @@ class maxPool {
};
};
template
<
class
T
>
template
<
class
T
>
class
av
ePool
{
class
av
gPoolGrad
{
public:
public:
DEVICE
inline
T
initial
()
{
return
static_cast
<
T
>
(
0
);
}
DEVICE
inline
void
process
(
T
&
y
,
const
T
&
x
)
{
y
+=
x
;
}
DEVICE
inline
void
finalize
(
T
&
y
,
const
T
&
poo_size
)
{
y
/=
poo_size
;
}
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
DEVICE
inline
void
gradProcess
(
const
T
&
x
,
const
T
&
y
,
const
T
&
dy
,
T
&
dx
,
T
scale
)
{
T
scale
)
{
dx
+=
(
scale
*
dy
);
dx
+=
(
scale
*
dy
);
...
...
paddle/operators/pool_op.cc
浏览文件 @
b7285438
...
@@ -41,8 +41,8 @@ class PoolOp : public framework::OperatorWithKernel {
...
@@ -41,8 +41,8 @@ class PoolOp : public framework::OperatorWithKernel {
std
::
vector
<
int
>
strides
=
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
strides
=
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
std
::
vector
<
int
>
paddings
=
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
PADDLE_ENFORCE
(
pooling_type
==
"max"
||
pooling_type
==
"av
e
"
,
PADDLE_ENFORCE
(
pooling_type
==
"max"
||
pooling_type
==
"av
g
"
,
"pooling_type should be 'max' or 'av
e
'"
);
"pooling_type should be 'max' or 'av
g
'"
);
PADDLE_ENFORCE
(
in_X
->
dims
().
size
()
==
4
||
in_X
->
dims
().
size
()
==
5
,
PADDLE_ENFORCE
(
in_X
->
dims
().
size
()
==
4
||
in_X
->
dims
().
size
()
==
5
,
"Pooling intput should be 4-D or 5-D"
);
"Pooling intput should be 4-D or 5-D"
);
...
@@ -99,7 +99,7 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -99,7 +99,7 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
std
::
string
>
(
"poolingType"
,
AddAttr
<
std
::
string
>
(
"poolingType"
,
"poolingType of pooling operator."
"poolingType of pooling operator."
"str constant equal to 'max' or 'av
e
'"
);
"str constant equal to 'max' or 'av
g
'"
);
AddAttr
<
std
::
vector
<
int
>>
(
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"pooling size(height, width) of pooling operator."
);
"ksize"
,
"pooling size(height, width) of pooling operator."
);
AddAttr
<
int
>
(
AddAttr
<
int
>
(
...
@@ -140,7 +140,7 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -140,7 +140,7 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
std
::
string
>
(
"poolingType"
,
AddAttr
<
std
::
string
>
(
"poolingType"
,
"poolingType of pooling operator."
"poolingType of pooling operator."
"str constant equal to 'max' or 'av
e
'"
);
"str constant equal to 'max' or 'av
g
'"
);
AddAttr
<
std
::
vector
<
int
>>
(
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"pooling size(depth, height, width) of pooling operator."
);
"ksize"
,
"pooling size(depth, height, width) of pooling operator."
);
AddAttr
<
int
>
(
AddAttr
<
int
>
(
...
...
paddle/operators/pool_op.h
浏览文件 @
b7285438
...
@@ -52,11 +52,11 @@ class PoolKernel : public framework::OpKernel {
...
@@ -52,11 +52,11 @@ class PoolKernel : public framework::OpKernel {
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
paddings
,
pool_process
);
paddings
,
pool_process
);
}
else
if
(
pooling_type
==
"av
e
"
)
{
}
else
if
(
pooling_type
==
"av
g
"
)
{
paddle
::
operators
::
math
::
Pool2dForwardFunctor
<
paddle
::
operators
::
math
::
Pool2dForwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
T
>
,
T
>
pool2d_forward
;
pool2d_forward
;
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
T
>
pool_process
;
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
pool2d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
paddings
,
pool_process
);
paddings
,
pool_process
);
}
}
...
@@ -69,11 +69,11 @@ class PoolKernel : public framework::OpKernel {
...
@@ -69,11 +69,11 @@ class PoolKernel : public framework::OpKernel {
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
paddings
,
pool_process
);
paddings
,
pool_process
);
}
else
if
(
pooling_type
==
"av
e
"
)
{
}
else
if
(
pooling_type
==
"av
g
"
)
{
paddle
::
operators
::
math
::
Pool3dForwardFunctor
<
paddle
::
operators
::
math
::
Pool3dForwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
T
>
,
T
>
pool3d_forward
;
pool3d_forward
;
paddle
::
operators
::
math
::
pool
::
av
e
Pool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
av
g
Pool
<
T
>
pool_process
;
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
pool3d_forward
(
context
.
device_context
(),
*
in_X
,
*
out
,
ksize
,
strides
,
paddings
,
pool_process
);
paddings
,
pool_process
);
}
}
...
@@ -112,16 +112,16 @@ class PoolGradKernel : public framework::OpKernel {
...
@@ -112,16 +112,16 @@ class PoolGradKernel : public framework::OpKernel {
case
2
:
{
case
2
:
{
if
(
pooling_type
==
"max"
)
{
if
(
pooling_type
==
"max"
)
{
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
Grad
<
T
>
,
T
>
pool2d_backward
;
pool2d_backward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
Grad
<
T
>
pool_process
;
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
}
else
if
(
pooling_type
==
"av
e
"
)
{
}
else
if
(
pooling_type
==
"av
g
"
)
{
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool2dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
av
ePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
av
gPoolGrad
<
T
>
,
T
>
pool2d_backward
;
pool2d_backward
;
paddle
::
operators
::
math
::
pool
::
av
ePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
av
gPoolGrad
<
T
>
pool_process
;
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
pool2d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
}
}
...
@@ -129,16 +129,16 @@ class PoolGradKernel : public framework::OpKernel {
...
@@ -129,16 +129,16 @@ class PoolGradKernel : public framework::OpKernel {
case
3
:
{
case
3
:
{
if
(
pooling_type
==
"max"
)
{
if
(
pooling_type
==
"max"
)
{
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
maxPool
Grad
<
T
>
,
T
>
pool3d_backward
;
pool3d_backward
;
paddle
::
operators
::
math
::
pool
::
maxPool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
maxPool
Grad
<
T
>
pool_process
;
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
}
else
if
(
pooling_type
==
"av
e
"
)
{
}
else
if
(
pooling_type
==
"av
g
"
)
{
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
paddle
::
operators
::
math
::
Pool3dBackwardFunctor
<
Place
,
paddle
::
operators
::
math
::
pool
::
av
ePool
<
T
>
,
T
>
Place
,
paddle
::
operators
::
math
::
pool
::
av
gPoolGrad
<
T
>
,
T
>
pool3d_backward
;
pool3d_backward
;
paddle
::
operators
::
math
::
pool
::
av
ePool
<
T
>
pool_process
;
paddle
::
operators
::
math
::
pool
::
av
gPoolGrad
<
T
>
pool_process
;
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
pool3d_backward
(
context
.
device_context
(),
*
in_X
,
*
in_X_grad
,
*
out
,
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
*
out_grad
,
ksize
,
strides
,
paddings
,
pool_process
);
}
}
...
...
python/paddle/v2/framework/tests/test_pool2d_op.py
浏览文件 @
b7285438
...
@@ -23,7 +23,7 @@ def max_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
...
@@ -23,7 +23,7 @@ def max_pool2D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
return
out
return
out
def
av
e
_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
def
av
g
_pool2D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
N
,
C
,
H
,
W
=
x
.
shape
N
,
C
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
if
global_pool
==
1
:
...
@@ -72,8 +72,8 @@ class TestPool2d_Op(OpTest):
...
@@ -72,8 +72,8 @@ class TestPool2d_Op(OpTest):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
0
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool2D_forward_naive
=
av
e
_pool2D_forward_naive
self
.
pool2D_forward_naive
=
av
g
_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
...
@@ -84,8 +84,8 @@ class TestCase1(TestPool2d_Op):
...
@@ -84,8 +84,8 @@ class TestCase1(TestPool2d_Op):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
0
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool2D_forward_naive
=
av
e
_pool2D_forward_naive
self
.
pool2D_forward_naive
=
av
g
_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
...
@@ -96,8 +96,8 @@ class TestCase2(TestPool2d_Op):
...
@@ -96,8 +96,8 @@ class TestCase2(TestPool2d_Op):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
1
self
.
op_type
=
"pool2d"
self
.
op_type
=
"pool2d"
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool2D_forward_naive
=
av
e
_pool2D_forward_naive
self
.
pool2D_forward_naive
=
av
g
_pool2D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
]
self
.
ksize
=
[
3
,
3
]
self
.
ksize
=
[
3
,
3
]
self
.
strides
=
[
1
,
1
]
self
.
strides
=
[
1
,
1
]
...
...
python/paddle/v2/framework/tests/test_pool3d_op.py
浏览文件 @
b7285438
...
@@ -27,7 +27,7 @@ def max_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
...
@@ -27,7 +27,7 @@ def max_pool3D_forward_naive(x, ksize, strides, paddings=[0, 0], global_pool=0):
return
out
return
out
def
av
e
_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
def
av
g
_pool3D_forward_naive
(
x
,
ksize
,
strides
,
paddings
=
[
0
,
0
],
global_pool
=
0
):
N
,
C
,
D
,
H
,
W
=
x
.
shape
N
,
C
,
D
,
H
,
W
=
x
.
shape
if
global_pool
==
1
:
if
global_pool
==
1
:
...
@@ -80,8 +80,8 @@ class TestPool3d_Op(OpTest):
...
@@ -80,8 +80,8 @@ class TestPool3d_Op(OpTest):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
0
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool3D_forward_naive
=
av
e
_pool3D_forward_naive
self
.
pool3D_forward_naive
=
av
g
_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
shape
=
[
2
,
3
,
5
,
5
,
5
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
...
@@ -92,8 +92,8 @@ class TestCase1(TestPool3d_Op):
...
@@ -92,8 +92,8 @@ class TestCase1(TestPool3d_Op):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
0
self
.
global_pool
=
0
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool3D_forward_naive
=
av
e
_pool3D_forward_naive
self
.
pool3D_forward_naive
=
av
g
_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
...
@@ -104,8 +104,8 @@ class TestCase2(TestPool3d_Op):
...
@@ -104,8 +104,8 @@ class TestCase2(TestPool3d_Op):
def
initTestCase
(
self
):
def
initTestCase
(
self
):
self
.
global_pool
=
1
self
.
global_pool
=
1
self
.
op_type
=
"pool3d"
self
.
op_type
=
"pool3d"
self
.
pool_type
=
"av
e
"
self
.
pool_type
=
"av
g
"
self
.
pool3D_forward_naive
=
av
e
_pool3D_forward_naive
self
.
pool3D_forward_naive
=
av
g
_pool3D_forward_naive
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
shape
=
[
2
,
3
,
7
,
7
,
7
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
ksize
=
[
3
,
3
,
3
]
self
.
strides
=
[
1
,
1
,
1
]
self
.
strides
=
[
1
,
1
,
1
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录