Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
b5a448f3
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b5a448f3
编写于
9月 18, 2017
作者:
T
Tao Luo
提交者:
GitHub
9月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4154 from luotao1/avg_pool
refine avg-pooling, which is exclusive. refine related code.
上级
d59295f2
780e2682
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
159 addition
and
188 deletion
+159
-188
paddle/cuda/include/hl_cuda_cudnn.h
paddle/cuda/include/hl_cuda_cudnn.h
+3
-3
paddle/cuda/src/hl_cuda_cnn.cu
paddle/cuda/src/hl_cuda_cnn.cu
+20
-20
paddle/cuda/src/hl_cuda_cudnn.cc
paddle/cuda/src/hl_cuda_cudnn.cc
+3
-3
paddle/gserver/layers/CudnnPoolLayer.cpp
paddle/gserver/layers/CudnnPoolLayer.cpp
+2
-2
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+127
-154
paddle/math/tests/test_matrixCompare.cpp
paddle/math/tests/test_matrixCompare.cpp
+4
-6
未找到文件。
paddle/cuda/include/hl_cuda_cudnn.h
浏览文件 @
b5a448f3
...
...
@@ -22,10 +22,10 @@ limitations under the License. */
*/
typedef
enum
{
HL_POOLING_MAX
=
0
,
// average includes padded values
HL_POOLING_AVERAGE
=
1
,
// average does not include padded values
HL_POOLING_AVERAGE_EXCLUDE_PADDING
=
2
,
HL_POOLING_AVERAGE
=
1
,
// average includes padded values
HL_POOLING_AVERAGE_INCLUDE_PADDING
=
2
,
HL_POOLING_END
}
hl_pooling_mode_t
;
...
...
paddle/cuda/src/hl_cuda_cnn.cu
浏览文件 @
b5a448f3
...
...
@@ -211,13 +211,11 @@ __global__ void KeAvgPoolForward(const int nthreads,
int
hstart
=
ph
*
strideH
-
padH
;
int
wstart
=
pw
*
strideW
-
padW
;
int
hend
=
min
(
hstart
+
sizeY
,
height
+
padH
);
int
wend
=
min
(
wstart
+
sizeX
,
width
+
padW
);
int
pool_size
=
(
hend
-
hstart
)
*
(
wend
-
wstart
);
int
hend
=
min
(
hstart
+
sizeY
,
height
);
int
wend
=
min
(
wstart
+
sizeX
,
width
);
hstart
=
max
(
hstart
,
0
);
wstart
=
max
(
wstart
,
0
);
hend
=
min
(
hend
,
height
);
wend
=
min
(
wend
,
width
);
int
pool_size
=
(
hend
-
hstart
)
*
(
wend
-
wstart
);
real
aveval
=
0
;
inputData
+=
(
frameNum
*
channels
+
c
)
*
height
*
width
;
...
...
@@ -299,12 +297,14 @@ __global__ void KeAvgPoolBackward(const int nthreads,
outGrad
+=
(
frameNum
*
outStride
+
offsetC
*
pooledH
*
pooledW
);
for
(
int
ph
=
phstart
;
ph
<
phend
;
++
ph
)
{
int
hstart
=
ph
*
strideH
-
padH
;
int
hend
=
min
(
hstart
+
sizeY
,
height
);
hstart
=
max
(
hstart
,
0
);
for
(
int
pw
=
pwstart
;
pw
<
pwend
;
++
pw
)
{
// figure out the pooling size
int
hstart
=
ph
*
strideH
-
padH
;
int
wstart
=
pw
*
strideW
-
padW
;
int
hend
=
min
(
hstart
+
sizeY
,
height
+
padH
);
int
wend
=
min
(
wstart
+
sizeX
,
width
+
padW
);
int
wend
=
min
(
wstart
+
sizeX
,
width
);
wstart
=
max
(
wstart
,
0
);
int
poolsize
=
(
hend
-
hstart
)
*
(
wend
-
wstart
);
gradient
+=
outGrad
[
ph
*
pooledW
+
pw
]
/
poolsize
;
}
...
...
@@ -600,16 +600,13 @@ __global__ void KeAvgPool3DForward(const int nthreads,
int
dstart
=
pd
*
strideD
-
padD
;
int
hstart
=
ph
*
strideH
-
padH
;
int
wstart
=
pw
*
strideW
-
padW
;
int
dend
=
min
(
dstart
+
sizeZ
,
depth
+
padD
);
int
hend
=
min
(
hstart
+
sizeY
,
height
+
padH
);
int
wend
=
min
(
wstart
+
sizeX
,
width
+
padW
);
int
pool_size
=
(
dend
-
dstart
)
*
(
hend
-
hstart
)
*
(
wend
-
wstart
);
int
dend
=
min
(
dstart
+
sizeZ
,
depth
);
int
hend
=
min
(
hstart
+
sizeY
,
height
);
int
wend
=
min
(
wstart
+
sizeX
,
width
);
dstart
=
max
(
dstart
,
0
);
hstart
=
max
(
hstart
,
0
);
wstart
=
max
(
wstart
,
0
);
dend
=
min
(
dend
,
depth
);
hend
=
min
(
hend
,
height
);
wend
=
min
(
wend
,
width
);
int
pool_size
=
(
dend
-
dstart
)
*
(
hend
-
hstart
)
*
(
wend
-
wstart
);
real
aveval
=
0
;
inputData
+=
(
frameNum
*
channels
+
c
)
*
depth
*
height
*
width
;
...
...
@@ -712,15 +709,18 @@ __global__ void KeAvgPool3DBackward(const int nthreads,
outGrad
+=
(
frameNum
*
channels
+
offsetC
)
*
pooledD
*
pooledH
*
pooledW
;
for
(
int
pd
=
pdstart
;
pd
<
pdend
;
++
pd
)
{
int
dstart
=
pd
*
strideD
-
padD
;
int
dend
=
min
(
dstart
+
sizeZ
,
depth
);
dstart
=
max
(
dstart
,
0
);
for
(
int
ph
=
phstart
;
ph
<
phend
;
++
ph
)
{
int
hstart
=
ph
*
strideH
-
padH
;
int
hend
=
min
(
hstart
+
sizeY
,
height
);
hstart
=
max
(
hstart
,
0
);
for
(
int
pw
=
pwstart
;
pw
<
pwend
;
++
pw
)
{
// figure out the pooling size
int
dstart
=
pd
*
strideD
-
padD
;
int
hstart
=
ph
*
strideH
-
padH
;
int
wstart
=
pw
*
strideW
-
padW
;
int
dend
=
min
(
dstart
+
sizeZ
,
depth
+
padD
);
int
hend
=
min
(
hstart
+
sizeY
,
height
+
padH
);
int
wend
=
min
(
wstart
+
sizeX
,
width
+
padW
);
int
wend
=
min
(
wstart
+
sizeX
,
width
);
wstart
=
max
(
wstart
,
0
);
int
poolsize
=
(
dend
-
dstart
)
*
(
hend
-
hstart
)
*
(
wend
-
wstart
);
gradient
+=
outGrad
[(
pd
*
pooledH
+
ph
)
*
pooledW
+
pw
]
/
poolsize
;
}
...
...
paddle/cuda/src/hl_cuda_cudnn.cc
浏览文件 @
b5a448f3
...
...
@@ -432,11 +432,11 @@ void hl_create_pooling_descriptor(hl_pooling_descriptor* pooling_desc,
cudnn_mode
=
CUDNN_POOLING_MAX
;
break
;
case
HL_POOLING_AVERAGE
:
cudnn_mode
=
CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING
;
break
;
case
HL_POOLING_AVERAGE_EXCLUDE_PADDING
:
cudnn_mode
=
CUDNN_POOLING_AVERAGE_COUNT_EXCLUDE_PADDING
;
break
;
case
HL_POOLING_AVERAGE_INCLUDE_PADDING
:
cudnn_mode
=
CUDNN_POOLING_AVERAGE_COUNT_INCLUDE_PADDING
;
break
;
default:
LOG
(
FATAL
)
<<
"parameter mode error"
;
}
...
...
paddle/gserver/layers/CudnnPoolLayer.cpp
浏览文件 @
b5a448f3
...
...
@@ -29,9 +29,9 @@ bool CudnnPoolLayer::typeCheck(const std::string &poolType,
if
(
mode
)
{
*
mode
=
HL_POOLING_AVERAGE
;
}
}
else
if
(
poolType
==
"cudnn-avg-
ex
cl-pad-pool"
)
{
}
else
if
(
poolType
==
"cudnn-avg-
in
cl-pad-pool"
)
{
if
(
mode
)
{
*
mode
=
HL_POOLING_AVERAGE_
EX
CLUDE_PADDING
;
*
mode
=
HL_POOLING_AVERAGE_
IN
CLUDE_PADDING
;
}
}
else
{
return
false
;
...
...
paddle/math/Matrix.cpp
浏览文件 @
b5a448f3
此差异已折叠。
点击以展开。
paddle/math/tests/test_matrixCompare.cpp
浏览文件 @
b5a448f3
...
...
@@ -825,9 +825,8 @@ void testMaxPoolFwdBwd(int numSamples,
int
strideW
,
int
padH
,
int
padW
)
{
int
outH
=
0
,
outW
=
0
;
outH
=
(
imgSizeH
-
ksizeH
+
2
*
padH
+
strideH
-
1
)
/
strideH
+
1
;
outW
=
(
imgSizeW
-
ksizeW
+
2
*
padW
+
strideW
-
1
)
/
strideW
+
1
;
int
outH
=
outputSize
(
imgSizeH
,
ksizeH
,
padH
,
strideH
,
true
);
int
outW
=
outputSize
(
imgSizeW
,
ksizeW
,
padW
,
strideW
,
true
);
int
inWidth
=
imgSizeH
*
imgSizeW
*
channels
;
MatrixPtr
input
=
CpuMatrix
::
create
(
numSamples
,
inWidth
,
false
,
false
);
...
...
@@ -927,9 +926,8 @@ void testAvgPoolFwdBwd(int numSamples,
int
strideW
,
int
padH
,
int
padW
)
{
int
outH
=
0
,
outW
=
0
;
outH
=
(
imgSizeH
-
ksizeH
+
2
*
padH
+
strideH
-
1
)
/
strideH
+
1
;
outW
=
(
imgSizeW
-
ksizeW
+
2
*
padW
+
strideW
-
1
)
/
strideW
+
1
;
int
outH
=
outputSize
(
imgSizeH
,
ksizeH
,
padH
,
strideH
,
true
);
int
outW
=
outputSize
(
imgSizeW
,
ksizeW
,
padW
,
strideW
,
true
);
int
inWidth
=
imgSizeH
*
imgSizeW
*
channels
;
MatrixPtr
input
=
CpuMatrix
::
create
(
numSamples
,
inWidth
,
false
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录