Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
790379f1
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看板
提交
790379f1
编写于
8月 23, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix above comments
上级
2377d719
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
208 addition
and
339 deletion
+208
-339
paddle/cuda/include/hl_cnn.h
paddle/cuda/include/hl_cnn.h
+0
-106
paddle/cuda/include/stub/hl_cnn_stub.h
paddle/cuda/include/stub/hl_cnn_stub.h
+3
-3
paddle/gserver/layers/Pool3DLayer.cpp
paddle/gserver/layers/Pool3DLayer.cpp
+25
-46
paddle/gserver/layers/Pool3DLayer.h
paddle/gserver/layers/Pool3DLayer.h
+1
-0
paddle/math/Matrix.cpp
paddle/math/Matrix.cpp
+66
-65
paddle/math/Matrix.h
paddle/math/Matrix.h
+67
-68
paddle/math/tests/test_matrixCompare.cpp
paddle/math/tests/test_matrixCompare.cpp
+46
-51
未找到文件。
paddle/cuda/include/hl_cnn.h
浏览文件 @
790379f1
...
...
@@ -173,31 +173,6 @@ extern void hl_avgpool_backward(const int frameCnt,
real
*
backGrad
,
const
int
outStride
);
/**
* @brief Maximum pool forward.
*
* @param[in] frameCnt batch size of input image.
* @param[in] inputData input data.
* @param[in] channels number of channel.
* @param[in] depth image depth.
* @param[in] height image height.
* @param[in] width image width.
* @param[in] pooledD output image depth.
* @param[in] pooledH output image height.
* @param[in] pooledW output image width.
* @param[in] sizeZ depth of pooling window.
* @param[in] sizeY height of pooling window.
* @param[in] sizeX width of pooling window.
* @param[in] strideD pooling stride depth.
* @param[in] strideH pooling stride height.
* @param[in] strideW pooling stride width.
* @param[in] paddingD padding depth.
* @param[in] paddingH padding height.
* @param[in] paddingW padding width.
* @param[out] tgtData output data.
* @param[in] tgtStride stride between output data samples.
*
*/
extern
void
hl_maxpool3D_forward
(
const
int
frameCnt
,
const
real
*
inputData
,
const
int
channels
,
...
...
@@ -219,35 +194,6 @@ extern void hl_maxpool3D_forward(const int frameCnt,
real
*
tgtData
,
const
int
tgtStride
);
/**
* @brief Maximum pool backward.
*
* @param[in] frameCnt batch size of input image.
* @param[in] inputData input data.
* @param[out] outData output data.
* @param[out] outGrad output grad data.
* @param[in] channels number of channel.
* @param[in] depth image depth.
* @param[in] height image height.
* @param[in] width image width.
* @param[in] pooledD output image depth.
* @param[in] pooledH output image height.
* @param[in] pooledW output image width.
* @param[in] sizeZ depth of pooling window.
* @param[in] sizeY height of pooling window.
* @param[in] sizeX width of pooling window.
* @param[in] strideD pooling stride depth.
* @param[in] strideH pooling stride height.
* @param[in] strideW pooling stride width.
* @param[in] scaleA scale.
* @param[in] scaleB scale.
* @param[in] paddingD padding depth.
* @param[in] paddingH padding height.
* @param[in] paddingW padding width.
* @param[out] targetGrad output grad.
* @param[in] outStride stride between output data samples.
*
*/
extern
void
hl_maxpool3D_backward
(
const
int
frameCnt
,
const
real
*
inputData
,
const
real
*
outData
,
...
...
@@ -273,31 +219,6 @@ extern void hl_maxpool3D_backward(const int frameCnt,
real
*
targetGrad
,
const
int
outStride
);
/**
* @brief Averge pool forward.
*
* @param[in] frameCnt batch size of input image.
* @param[in] inputData input data.
* @param[in] channels number of channel.
* @param[in] depth image depth.
* @param[in] height image height.
* @param[in] width image width.
* @param[in] pooledD output image depth.
* @param[in] pooledH output image height.
* @param[in] pooledW output image width.
* @param[in] sizeZ depth of pooling window.
* @param[in] sizeY height of pooling window.
* @param[in] sizeX width of pooling window.
* @param[in] strideD pooling stride depth.
* @param[in] strideH pooling stride height.
* @param[in] strideW pooling stride width.
* @param[in] paddingD padding depth.
* @param[in] paddingH padding height.
* @param[in] paddingW padding width.
* @param[out] tgtData output data.
* @param[in] tgtStride stride between output data samples.
*
*/
extern
void
hl_avgpool3D_forward
(
const
int
frameCnt
,
const
real
*
inputData
,
const
int
channels
,
...
...
@@ -319,33 +240,6 @@ extern void hl_avgpool3D_forward(const int frameCnt,
real
*
tgtData
,
const
int
tgtStride
);
/**
* @brief Maximum pool backward.
*
* @param[in] frameCnt batch size of input image.
* @param[in] outGrad output grad data.
* @param[in] channels number of channel.
* @param[in] depth image depth.
* @param[in] height image height.
* @param[in] width image width.
* @param[in] pooledD output image depth.
* @param[in] pooledH output image height.
* @param[in] pooledW output image width.
* @param[in] sizeZ depth of pooling window.
* @param[in] sizeY height of pooling window.
* @param[in] sizeX width of pooling window.
* @param[in] strideD pooling stride depth.
* @param[in] strideH pooling stride height.
* @param[in] strideW pooling stride width.
* @param[in] paddingD padding depth.
* @param[in] paddingH padding height.
* @param[in] paddingW padding width.
* @param[in] scaleA scale.
* @param[in] scaleB scale.
* @param[out] backGrad output grad.
* @param[in] outStride stride between output data samples.
*
*/
extern
void
hl_avgpool3D_backward
(
const
int
frameCnt
,
const
real
*
outGrad
,
const
int
channels
,
...
...
paddle/cuda/include/stub/hl_cnn_stub.h
浏览文件 @
790379f1
...
...
@@ -169,9 +169,9 @@ inline void hl_avgpool3D_backward(const int frameCnt,
const
int
strideD
,
const
int
strideH
,
const
int
strideW
,
int
paddingD
,
int
paddingH
,
int
paddingW
,
const
int
paddingD
,
const
int
paddingH
,
const
int
paddingW
,
real
scaleA
,
real
scaleB
,
real
*
backGrad
,
...
...
paddle/gserver/layers/Pool3DLayer.cpp
浏览文件 @
790379f1
...
...
@@ -58,30 +58,9 @@ size_t Pool3DLayer::getSize() {
CHECK_EQ
(
inputLayers_
.
size
(),
1UL
);
size_t
layerSize
=
0
;
// imgSizeD_ = inputLayers_[0]->getOutput().getFrameDepth();
// imgSizeH_ = inputLayers_[0]->getOutput().getFrameHeight();
// imgSizeW_ = inputLayers_[0]->getOutput().getFrameWidth();
if
(
imgSizeH_
==
0
)
{
// imgSizeH_ = imgSizeY_;
}
if
(
imgSizeW_
==
0
)
{
// imgSizeW_ = imgSize_;
}
outputD_
=
outputSize
(
imgSizeD_
,
sizeZ_
,
paddingD_
,
strideD_
,
/* caffeMode */
false
);
outputH_
=
outputSize
(
imgSizeH_
,
sizeY_
,
paddingH_
,
strideH_
,
/* caffeMode */
false
);
outputW_
=
outputSize
(
imgSizeW_
,
sizeX_
,
paddingW_
,
strideW_
,
/* caffeMode */
false
);
outputD_
=
outputSize
(
imgSizeD_
,
sizeZ_
,
paddingD_
,
strideD_
,
false
);
outputH_
=
outputSize
(
imgSizeH_
,
sizeY_
,
paddingH_
,
strideH_
,
false
);
outputW_
=
outputSize
(
imgSizeW_
,
sizeX_
,
paddingW_
,
strideW_
,
false
);
layerSize
=
outputD_
*
outputH_
*
outputW_
*
channels_
;
getOutput
().
setFrameHeight
(
outputH_
);
...
...
@@ -100,37 +79,37 @@ void Pool3DLayer::forward(PassType passType) {
if
(
poolType_
==
"avg"
)
{
outMat
->
avgPool3DForward
(
*
inMat
,
channels_
,
imgSizeD_
,
imgSizeH_
,
imgSizeW_
,
channels_
,
outputD_
,
outputH_
,
outputW_
,
sizeZ_
,
sizeY_
,
sizeX_
,
strideD_
,
strideH_
,
strideW_
,
outputD_
,
outputH_
,
outputW_
,
paddingD_
,
paddingH_
,
paddingW_
);
}
else
if
(
poolType_
==
"max"
)
{
outMat
->
maxPool3DForward
(
*
inMat
,
channels_
,
imgSizeD_
,
imgSizeH_
,
imgSizeW_
,
channels_
,
outputD_
,
outputH_
,
outputW_
,
sizeZ_
,
sizeY_
,
sizeX_
,
strideD_
,
strideH_
,
strideW_
,
outputD_
,
outputH_
,
outputW_
,
paddingD_
,
paddingH_
,
paddingW_
);
...
...
@@ -155,41 +134,41 @@ void Pool3DLayer::backward(const UpdateCallback& callback) {
imgSizeD_
,
imgSizeH_
,
imgSizeW_
,
outputD_
,
outputH_
,
outputW_
,
sizeZ_
,
sizeY_
,
sizeZ_
,
strideD_
,
strideH_
,
strideW_
,
outputD_
,
outputH_
,
outputW_
,
1
,
1
,
paddingD_
,
paddingH_
,
paddingW_
);
paddingW_
,
1.0
,
1.0
);
}
else
if
(
poolType_
==
"max"
)
{
inGradMat
->
maxPool3DBackward
(
*
inMat
,
*
outGradMat
,
*
outMat
,
imgSizeD_
,
imgSizeH_
,
imgSizeW_
,
*
outGradMat
,
*
outMat
,
outputD_
,
outputH_
,
outputW_
,
sizeZ_
,
sizeY_
,
sizeZ_
,
strideD_
,
strideH_
,
strideW_
,
outputD_
,
outputH_
,
outputW_
,
1
,
1
,
paddingD_
,
paddingH_
,
paddingW_
);
paddingW_
,
1.0
,
1.0
);
}
else
{
LOG
(
FATAL
)
<<
"Unknown pool type: "
<<
poolType_
;
}
...
...
paddle/gserver/layers/Pool3DLayer.h
浏览文件 @
790379f1
...
...
@@ -44,5 +44,6 @@ protected:
int
imgSizeW_
,
imgSizeH_
,
imgSizeD_
;
int
outputW_
,
outputH_
,
outputD_
;
std
::
string
poolType_
;
MatrixPtr
maxPoolIdx_
;
};
}
// namespace paddle
paddle/math/Matrix.cpp
浏览文件 @
790379f1
...
...
@@ -1191,23 +1191,23 @@ void GpuMatrix::avgPoolBackward(Matrix& outGrad,
}
void
GpuMatrix
::
maxPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
CHECK
(
inputMat
.
useGpu_
==
true
)
<<
"Matrix type are not equal
"
;
CHECK
(
inputMat
.
useGpu_
)
<<
"Matrix type are not correct
"
;
real
*
inputData
=
inputMat
.
getData
();
size_t
num
=
inputMat
.
getHeight
();
...
...
@@ -1236,32 +1236,31 @@ void GpuMatrix::maxPool3DForward(Matrix& inputMat,
paddingD
,
paddingH
,
paddingW
,
data_
,
getData
()
,
getStride
());
}
void
GpuMatrix
::
maxPool3DBackward
(
Matrix
&
inputMat
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
CHECK
(
inputMat
.
useGpu_
==
true
&&
outGrad
.
useGpu_
==
true
&&
outV
.
useGpu_
==
true
)
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
CHECK
(
inputMat
.
useGpu_
&&
outGrad
.
useGpu_
&&
outV
.
useGpu_
)
<<
"Matrix type are not equal"
;
real
*
inputData
=
inputMat
.
getData
();
...
...
@@ -1300,28 +1299,28 @@ void GpuMatrix::maxPool3DBackward(Matrix& inputMat,
paddingW
,
scaleTargets
,
scaleOutput
,
data_
,
getData
()
,
outGrad
.
getStride
());
}
void
GpuMatrix
::
avgPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
CHECK
(
inputMat
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
CHECK
(
inputMat
.
useGpu_
)
<<
"Matrix type are not equal"
;
real
*
inputData
=
inputMat
.
getData
();
size_t
frameNum
=
inputMat
.
getHeight
();
...
...
@@ -1350,7 +1349,7 @@ void GpuMatrix::avgPool3DForward(Matrix& inputMat,
paddingD
,
paddingH
,
paddingW
,
data_
,
getData
()
,
getStride
());
}
...
...
@@ -1358,21 +1357,21 @@ void GpuMatrix::avgPool3DBackward(Matrix& outGrad,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
CHECK
(
outGrad
.
useGpu_
==
true
)
<<
"Matrix type are not equal"
;
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
CHECK
(
outGrad
.
useGpu_
)
<<
"Matrix type are not equal"
;
real
*
outDiff
=
outGrad
.
getData
();
size_t
frameNum
=
outGrad
.
getHeight
();
...
...
@@ -1404,7 +1403,7 @@ void GpuMatrix::avgPool3DBackward(Matrix& outGrad,
paddingW
,
scaleTargets
,
scaleOutput
,
data_
,
getData
()
,
outGrad
.
getStride
());
}
...
...
@@ -2149,24 +2148,24 @@ void CpuMatrix::avgPoolBackward(Matrix& input,
}
void
CpuMatrix
::
maxPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
real
*
inputData
=
inputMat
.
getData
();
real
*
outData
=
data_
;
real
*
outData
=
getData
()
;
size_t
num
=
inputMat
.
getHeight
();
size_t
inWidth
=
imgSizeW
;
size_t
inHeight
=
imgSizeH
;
...
...
@@ -2186,7 +2185,7 @@ void CpuMatrix::maxPool3DForward(Matrix& inputMat,
/* pool max one by one */
for
(
size_t
n
=
0
;
n
<
num
;
++
n
)
{
// frame by frame
if
(
!
isContiguous
())
{
outData
=
data_
+
n
*
outStride
;
outData
=
getData
()
+
n
*
outStride
;
}
for
(
size_t
c
=
0
;
c
<
channels
;
++
c
)
{
// channel by channel
for
(
size_t
pd
=
0
;
pd
<
outputD
;
++
pd
)
{
...
...
@@ -2201,15 +2200,18 @@ void CpuMatrix::maxPool3DForward(Matrix& inputMat,
dstart
=
std
::
max
(
dstart
,
0
);
hstart
=
std
::
max
(
hstart
,
0
);
wstart
=
std
::
max
(
wstart
,
0
);
real
maxOutData
=
outData
[(
pd
*
outputH
+
ph
)
*
outputW
+
pw
];
for
(
int
d
=
dstart
;
d
<
dend
;
++
d
)
{
for
(
int
h
=
hstart
;
h
<
hend
;
++
h
)
{
for
(
int
w
=
wstart
;
w
<
wend
;
++
w
)
{
outData
[(
pd
*
outputH
+
ph
)
*
outputW
+
pw
]
=
std
::
max
(
outData
[(
pd
*
outputH
+
ph
)
*
outputW
+
pw
],
inputData
[(
d
*
inHeight
+
h
)
*
inWidth
+
w
]);
if
(
maxOutData
<
inputData
[(
d
*
inHeight
+
h
)
*
inWidth
+
w
])
{
maxOutData
=
inputData
[(
d
*
inHeight
+
h
)
*
inWidth
+
w
];
}
}
}
}
outData
[(
pd
*
outputH
+
ph
)
*
outputW
+
pw
]
=
maxOutData
;
}
}
}
...
...
@@ -2221,25 +2223,25 @@ void CpuMatrix::maxPool3DForward(Matrix& inputMat,
}
void
CpuMatrix
::
maxPool3DBackward
(
Matrix
&
image
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
size_t
num
=
image
.
getHeight
();
size_t
channels
=
size_t
(
width_
/
imgSizeD
/
imgSizeH
/
imgSizeW
);
CHECK
(
image
.
getWidth
()
==
imgSizeD
*
imgSizeH
*
imgSizeW
*
channels
);
...
...
@@ -2247,19 +2249,18 @@ void CpuMatrix::maxPool3DBackward(Matrix& image,
CHECK
(
outV
.
getHeight
()
==
outGrad
.
getHeight
()
&&
outV
.
getWidth
()
==
outGrad
.
getWidth
());
real
*
tgtGrad
=
data_
;
real
*
tgtGrad
=
getData
()
;
real
*
inData
=
image
.
getData
();
real
*
otData
=
outV
.
getData
();
real
*
otGrad
=
outGrad
.
getData
();
size_t
outStride
=
outV
.
getStride
();
real
*
origOutData
=
otData
;
real
*
origOutGrad
=
otGrad
;
;
for
(
size_t
n
=
0
;
n
<
num
;
++
n
)
{
if
(
!
outV
.
isContiguous
())
{
otData
=
o
rigOutData
+
n
*
outStride
;
otGrad
=
o
rigOutGrad
+
n
*
outStride
;
otData
=
o
utV
.
getData
()
+
n
*
outStride
;
otGrad
=
o
utGrad
.
getData
()
+
n
*
outStride
;
}
for
(
size_t
c
=
0
;
c
<
channels
;
++
c
)
{
for
(
size_t
pd
=
0
;
pd
<
outputD
;
++
pd
)
{
...
...
@@ -2274,7 +2275,7 @@ void CpuMatrix::maxPool3DBackward(Matrix& image,
dstart
=
std
::
max
(
dstart
,
0
);
hstart
=
std
::
max
(
hstart
,
0
);
wstart
=
std
::
max
(
wstart
,
0
);
for
(
int
d
=
0
;
d
<
dend
;
++
d
)
{
for
(
int
d
=
dstart
;
d
<
dend
;
++
d
)
{
for
(
int
h
=
hstart
;
h
<
hend
;
++
h
)
{
for
(
int
w
=
wstart
;
w
<
wend
;
++
w
)
{
tgtGrad
[(
d
*
imgSizeH
+
h
)
*
imgSizeW
+
w
]
=
...
...
@@ -2299,19 +2300,19 @@ void CpuMatrix::maxPool3DBackward(Matrix& image,
}
void
CpuMatrix
::
avgPool3DForward
(
Matrix
&
input
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
...
...
@@ -2322,7 +2323,7 @@ void CpuMatrix::avgPool3DForward(Matrix& input,
size_t
inWidth
=
imgSizeW
;
CHECK
(
inDepth
*
inHeight
*
inWidth
*
channels
==
input
.
getWidth
());
CHECK
(
outputD
*
outputH
*
outputW
*
channels
*
num
==
height_
*
width_
);
real
*
tgtData
=
data_
;
real
*
tgtData
=
getData
()
;
real
*
inData
=
input
.
getData
();
for
(
size_t
n
=
0
;
n
<
num
;
++
n
)
{
...
...
@@ -2372,20 +2373,20 @@ void CpuMatrix::avgPool3DBackward(Matrix& input,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
size_t
num
=
input
.
getHeight
();
size_t
channels
=
input
.
getWidth
()
/
outputD
/
outputH
/
outputW
;
CHECK
(
imgSizeD
*
imgSizeH
*
imgSizeW
*
channels
==
getWidth
());
...
...
paddle/math/Matrix.h
浏览文件 @
790379f1
...
...
@@ -933,19 +933,19 @@ public:
* in the sizeX of value
*/
virtual
void
maxPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
...
...
@@ -953,42 +953,42 @@ public:
}
virtual
void
maxPool3DBackward
(
Matrix
&
image
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
LOG
(
FATAL
)
<<
"Not implemeted"
;
}
virtual
void
avgPool3DForward
(
Matrix
&
input
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
...
...
@@ -999,20 +999,20 @@ public:
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
)
{
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
)
{
LOG
(
FATAL
)
<<
"Not implemeted"
;
}
...
...
@@ -1435,60 +1435,59 @@ public:
size_t
paddingH
,
size_t
paddingW
);
/////////////////////////
void
maxPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
void
maxPool3DBackward
(
Matrix
&
image
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
);
void
avgPool3DForward
(
Matrix
&
input
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
...
...
@@ -1497,20 +1496,20 @@ public:
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
);
void
maxSequenceForward
(
Matrix
&
input
,
const
IVector
&
sequence
,
...
...
@@ -1670,60 +1669,60 @@ public:
real
scaleOutput
,
size_t
paddingH
,
size_t
paddingW
);
//////////////////////
void
maxPool3DForward
(
Matrix
&
inputMat
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
void
maxPool3DBackward
(
Matrix
&
image
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
Matrix
&
outGrad
,
Matrix
&
outV
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
);
void
avgPool3DForward
(
Matrix
&
input
,
size_t
channels
,
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
channels
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
...
...
@@ -1732,20 +1731,20 @@ public:
size_t
imgSizeD
,
size_t
imgSizeH
,
size_t
imgSizeW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
size_t
sizeZ
,
size_t
sizeY
,
size_t
sizeX
,
size_t
strideD
,
size_t
strideH
,
size_t
strideW
,
size_t
outputD
,
size_t
outputH
,
size_t
outputW
,
real
scaleTargets
,
real
scaleOutput
,
size_t
paddingD
,
size_t
paddingH
,
size_t
paddingW
);
size_t
paddingW
,
real
scaleTargets
,
real
scaleOutput
);
void
maxSequenceForward
(
Matrix
&
input
,
const
IVector
&
sequence
,
...
...
paddle/math/tests/test_matrixCompare.cpp
浏览文件 @
790379f1
...
...
@@ -1204,7 +1204,6 @@ TEST(Matrix, warpCTC) {
}
}
/////
void
testMatrixPool3D
(
int
depth
,
int
height
,
int
width
)
{
int
channel
=
3
;
int
filterX
=
3
,
filterY
=
4
,
filterZ
=
5
;
...
...
@@ -1226,38 +1225,37 @@ void testMatrixPool3D(int depth, int height, int width) {
cpuImage
->
randomizeUniform
();
gpuImage
->
copyFrom
(
*
cpuImage
);
// std::cout << "test maxPool3DForward...\n";
cpuOutput
->
maxPool3DForward
(
*
cpuImage
,
channel
,
depth
,
height
,
width
,
channel
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
padZ
,
padY
,
padX
);
gpuOutput
->
maxPool3DForward
(
*
gpuImage
,
channel
,
depth
,
height
,
width
,
channel
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
padZ
,
padY
,
padX
);
...
...
@@ -1265,39 +1263,38 @@ void testMatrixPool3D(int depth, int height, int width) {
cpuImage
->
randomizeUniform
();
gpuImage
->
copyFrom
(
*
cpuImage
);
// std::cout << "test avgPool3DForward...\n";
cpuOutput
->
avgPool3DForward
(
*
cpuImage
,
channel
,
depth
,
height
,
width
,
channel
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
padZ
,
padY
,
padX
);
gpuOutput
->
avgPool3DForward
(
*
gpuImage
,
channel
,
depth
,
height
,
width
,
channel
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
padZ
,
padY
,
padX
);
...
...
@@ -1306,98 +1303,96 @@ void testMatrixPool3D(int depth, int height, int width) {
gpuImage
->
copyFrom
(
*
cpuImage
);
cpuOutput
->
randomizeUniform
();
gpuOutput
->
copyFrom
(
*
cpuOutput
);
// std::cout << "test avgPool3DBackward...\n";
cpuImage
->
avgPool3DBackward
(
*
cpuOutput
,
depth
,
height
,
width
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
1
,
1
,
padZ
,
padY
,
padX
);
padX
,
1.0
,
1.0
);
gpuImage
->
avgPool3DBackward
(
*
gpuOutput
,
depth
,
height
,
width
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
1
,
1
,
padZ
,
padY
,
padX
);
padX
,
1.0
,
1.0
);
TensorCheckErr
(
*
cpuImage
,
*
gpuImage
);
cpuImage
->
randomizeUniform
();
gpuImage
->
copyFrom
(
*
cpuImage
);
cpuOutput
->
randomizeUniform
();
gpuOutput
->
copyFrom
(
*
cpuOutput
);
// std::cout << "test maxPool3DBackward...\n";
cpuImage
->
maxPool3DBackward
(
*
cpuImage
,
*
cpuOutput
,
*
cpuOutput
,
depth
,
height
,
width
,
*
cpuOutput
,
*
cpuOutput
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
1
,
1
,
padZ
,
padY
,
padX
);
padX
,
1.0
,
1.0
);
gpuImage
->
maxPool3DBackward
(
*
gpuImage
,
*
gpuOutput
,
*
gpuOutput
,
depth
,
height
,
width
,
*
gpuOutput
,
*
gpuOutput
,
outD
,
outH
,
outW
,
filterZ
,
filterY
,
filterX
,
strideZ
,
strideY
,
strideX
,
outD
,
outH
,
outW
,
1
,
1
,
padZ
,
padY
,
padX
);
padX
,
1.0
,
1.0
);
TensorCheckErr
(
*
cpuImage
,
*
gpuImage
);
}
TEST
(
Matrix
,
Pool3D
)
{
for
(
auto
depth
:
{
9
,
16
,
64
,
128
})
{
for
(
auto
height
:
{
9
,
11
,
128
,
256
})
{
for
(
auto
depth
:
{
9
,
16
,
64
})
{
for
(
auto
height
:
{
9
,
11
,
128
})
{
for
(
auto
width
:
{
9
,
32
,
128
})
{
VLOG
(
3
)
<<
"depth="
<<
depth
<<
" height="
<<
height
<<
" width="
<<
width
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录