Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
687b3749
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看板
提交
687b3749
编写于
7月 22, 2017
作者:
G
guosheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug on GPU test
上级
1c007677
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
11 deletion
+78
-11
paddle/gserver/layers/ROIPoolLayer.cpp
paddle/gserver/layers/ROIPoolLayer.cpp
+78
-11
未找到文件。
paddle/gserver/layers/ROIPoolLayer.cpp
浏览文件 @
687b3749
...
...
@@ -43,15 +43,46 @@ void ROIPoolLayer::forward(PassType passType) {
size_t
batchSize
=
getInput
(
0
).
getBatchSize
();
size_t
numROIs
=
getInput
(
1
).
getBatchSize
();
real
*
bottomData
=
getInputValue
(
0
)
->
getData
();
size_t
batchOffset
=
getInputValue
(
0
)
->
getWidth
();
MatrixPtr
dataValue
=
getInputValue
(
0
);
MatrixPtr
roiValue
=
getInputValue
(
1
);
resetOutput
(
numROIs
,
channels_
*
pooledHeight_
*
pooledWidth_
);
MatrixPtr
outputValue
=
getOutputValue
();
if
(
useGpu_
)
{
MatrixPtr
dataCpuBuffer
;
Matrix
::
resizeOrCreate
(
dataCpuBuffer
,
dataValue
->
getHeight
(),
dataValue
->
getWidth
(),
false
,
false
);
MatrixPtr
roiCpuBuffer
;
Matrix
::
resizeOrCreate
(
roiCpuBuffer
,
roiValue
->
getHeight
(),
roiValue
->
getWidth
(),
false
,
false
);
dataCpuBuffer
->
copyFrom
(
*
dataValue
);
roiCpuBuffer
->
copyFrom
(
*
roiValue
);
dataValue
=
dataCpuBuffer
;
roiValue
=
roiCpuBuffer
;
MatrixPtr
outputCpuBuffer
;
Matrix
::
resizeOrCreate
(
outputCpuBuffer
,
outputValue
->
getHeight
(),
outputValue
->
getWidth
(),
false
,
false
);
outputCpuBuffer
->
copyFrom
(
*
outputValue
);
outputValue
=
outputCpuBuffer
;
}
real
*
bottomData
=
dataValue
->
getData
();
size_t
batchOffset
=
dataValue
->
getWidth
();
size_t
channelOffset
=
height_
*
width_
;
real
*
bottomROIs
=
getInputValue
(
1
)
->
getData
();
size_t
roiOffset
=
getInputValue
(
1
)
->
getWidth
();
real
*
bottomROIs
=
roiValue
->
getData
();
size_t
roiOffset
=
roiValue
->
getWidth
();
size_t
poolChannelOffset
=
pooledHeight_
*
pooledWidth_
;
resetOutput
(
numROIs
,
channels_
*
pooledHeight_
*
pooledWidth_
);
real
*
outputData
=
getOutputValue
()
->
getData
();
real
*
outputData
=
outputValue
->
getData
();
Matrix
::
resizeOrCreate
(
maxIdxs_
,
numROIs
,
channels_
*
pooledHeight_
*
pooledWidth_
,
...
...
@@ -113,20 +144,52 @@ void ROIPoolLayer::forward(PassType passType) {
}
bottomROIs
+=
roiOffset
;
}
if
(
useGpu_
)
{
getOutputValue
()
->
copyFrom
(
*
outputValue
);
}
}
void
ROIPoolLayer
::
backward
(
const
UpdateCallback
&
callback
)
{
real
*
bottomROIs
=
getInputValue
(
1
)
->
getData
();
MatrixPtr
inGradValue
=
getInputGrad
(
0
);
MatrixPtr
outGradValue
=
getOutputGrad
();
MatrixPtr
roiValue
=
getInputValue
(
1
);
if
(
useGpu_
)
{
MatrixPtr
inGradCpuBuffer
;
Matrix
::
resizeOrCreate
(
inGradCpuBuffer
,
inGradValue
->
getHeight
(),
inGradValue
->
getWidth
(),
false
,
false
);
MatrixPtr
outGradCpuBuffer
;
Matrix
::
resizeOrCreate
(
outGradCpuBuffer
,
outGradValue
->
getHeight
(),
outGradValue
->
getWidth
(),
false
,
false
);
MatrixPtr
roiCpuBuffer
;
Matrix
::
resizeOrCreate
(
roiCpuBuffer
,
roiValue
->
getHeight
(),
roiValue
->
getWidth
(),
false
,
false
);
inGradCpuBuffer
->
copyFrom
(
*
inGradValue
);
outGradCpuBuffer
->
copyFrom
(
*
outGradValue
);
roiCpuBuffer
->
copyFrom
(
*
roiValue
);
inGradValue
=
inGradCpuBuffer
;
outGradValue
=
outGradCpuBuffer
;
roiValue
=
roiCpuBuffer
;
}
real
*
bottomROIs
=
roiValue
->
getData
();
size_t
numROIs
=
getInput
(
1
).
getBatchSize
();
size_t
roiOffset
=
getInputValue
(
1
)
->
getWidth
();
MatrixPtr
inGrad
=
getInputGrad
(
0
);
real
*
inDiffData
=
inGrad
->
getData
();
real
*
inDiffData
=
inGradValue
->
getData
();
size_t
batchOffset
=
getInputValue
(
0
)
->
getWidth
();
size_t
channelOffset
=
height_
*
width_
;
MatrixPtr
outGrad
=
getOutputGrad
();
real
*
outDiffData
=
outGrad
->
getData
();
real
*
outDiffData
=
outGradValue
->
getData
();
size_t
poolChannelOffset
=
pooledHeight_
*
pooledWidth_
;
real
*
argmaxData
=
maxIdxs_
->
getData
();
...
...
@@ -149,6 +212,10 @@ void ROIPoolLayer::backward(const UpdateCallback& callback) {
}
bottomROIs
+=
roiOffset
;
}
if
(
useGpu_
)
{
getInputGrad
(
0
)
->
copyFrom
(
*
inGradValue
);
}
}
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录