Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
60bf1a47
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
60bf1a47
编写于
11月 22, 2016
作者:
W
wangyang59
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modifed ExpandConvBaseLayer to unify paras between expand and cudnn
上级
fd925943
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
8 deletion
+41
-8
paddle/gserver/layers/ExpandConvBaseLayer.cpp
paddle/gserver/layers/ExpandConvBaseLayer.cpp
+6
-6
paddle/gserver/tests/test_ConvUnify.cpp
paddle/gserver/tests/test_ConvUnify.cpp
+35
-2
未找到文件。
paddle/gserver/layers/ExpandConvBaseLayer.cpp
浏览文件 @
60bf1a47
...
@@ -145,7 +145,7 @@ void ExpandConvBaseLayer::expandFwdOnce(MatrixPtr image,
...
@@ -145,7 +145,7 @@ void ExpandConvBaseLayer::expandFwdOnce(MatrixPtr image,
real
*
expInData
=
expandInput_
->
getData
();
real
*
expInData
=
expandInput_
->
getData
();
for
(
int
g
=
0
;
g
<
groups_
[
inIdx
];
++
g
)
{
for
(
int
g
=
0
;
g
<
groups_
[
inIdx
];
++
g
)
{
MatrixPtr
A
=
MatrixPtr
A
=
Matrix
::
create
(
wgtData
,
sub
K
,
subM
,
tru
e
,
useGpu_
);
// mark transpose
Matrix
::
create
(
wgtData
,
sub
M
,
subK
,
fals
e
,
useGpu_
);
// mark transpose
MatrixPtr
B
=
Matrix
::
create
(
expInData
,
subK
,
subN
,
false
,
useGpu_
);
MatrixPtr
B
=
Matrix
::
create
(
expInData
,
subK
,
subN
,
false
,
useGpu_
);
MatrixPtr
C
=
Matrix
::
create
(
outData
,
subM
,
subN
,
false
,
useGpu_
);
MatrixPtr
C
=
Matrix
::
create
(
outData
,
subM
,
subN
,
false
,
useGpu_
);
C
->
mul
(
A
,
B
,
1
,
1
);
C
->
mul
(
A
,
B
,
1
,
1
);
...
@@ -182,7 +182,7 @@ void ExpandConvBaseLayer::bpropActs(MatrixPtr out,
...
@@ -182,7 +182,7 @@ void ExpandConvBaseLayer::bpropActs(MatrixPtr out,
// create temporary matrix
// create temporary matrix
MatrixPtr
C
=
Matrix
::
create
(
expandInData
,
subK
,
subN
,
false
,
useGpu_
);
MatrixPtr
C
=
Matrix
::
create
(
expandInData
,
subK
,
subN
,
false
,
useGpu_
);
MatrixPtr
B
=
Matrix
::
create
(
localGradData
,
subM
,
subN
,
false
,
useGpu_
);
MatrixPtr
B
=
Matrix
::
create
(
localGradData
,
subM
,
subN
,
false
,
useGpu_
);
MatrixPtr
A
=
Matrix
::
create
(
wgtData
,
sub
K
,
subM
,
fals
e
,
useGpu_
);
MatrixPtr
A
=
Matrix
::
create
(
wgtData
,
sub
M
,
subK
,
tru
e
,
useGpu_
);
C
->
mul
(
A
,
B
);
// mul
C
->
mul
(
A
,
B
);
// mul
// clear the temporary matrix
// clear the temporary matrix
...
@@ -247,10 +247,10 @@ void ExpandConvBaseLayer::bpropWeights(MatrixPtr image,
...
@@ -247,10 +247,10 @@ void ExpandConvBaseLayer::bpropWeights(MatrixPtr image,
// expand-mul one-group by one
// expand-mul one-group by one
for
(
int
g
=
0
;
g
<
groups_
[
inpIdx
];
g
++
)
{
for
(
int
g
=
0
;
g
<
groups_
[
inpIdx
];
g
++
)
{
MatrixPtr
A
=
Matrix
::
create
(
expandInData
,
subK
,
subN
,
fals
e
,
useGpu_
);
MatrixPtr
A
=
Matrix
::
create
(
expandInData
,
subK
,
subN
,
tru
e
,
useGpu_
);
MatrixPtr
B
=
Matrix
::
create
(
gradData
,
subM
,
subN
,
tru
e
,
useGpu_
);
MatrixPtr
B
=
Matrix
::
create
(
gradData
,
subM
,
subN
,
fals
e
,
useGpu_
);
MatrixPtr
C
=
Matrix
::
create
(
wGradData
,
sub
K
,
subM
,
false
,
useGpu_
);
MatrixPtr
C
=
Matrix
::
create
(
wGradData
,
sub
M
,
subK
,
false
,
useGpu_
);
C
->
mul
(
A
,
B
,
1
,
1
);
C
->
mul
(
B
,
A
,
1
,
1
);
A
->
clear
();
A
->
clear
();
B
->
clear
();
B
->
clear
();
...
...
paddle/gserver/tests/test_ConvUnify.cpp
浏览文件 @
60bf1a47
...
@@ -86,13 +86,14 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride,
...
@@ -86,13 +86,14 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride,
initTestLayer
(
config
,
&
layerMap
,
&
parameters
,
&
convLayer
);
initTestLayer
(
config
,
&
layerMap
,
&
parameters
,
&
convLayer
);
convLayer
->
getBiasParameter
()
->
zeroMem
();
convLayer
->
getBiasParameter
()
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
getBuf
(
PARAMETER_VALUE
)
->
copyFrom
(
param
,
18
);
convLayer
->
getParameters
()[
0
]
->
getBuf
(
PARAMETER_VALUE
)
->
copyFrom
(
param
,
channel
*
filter_size
*
filter_size
*
config
.
layerConfig
.
num_filters
());
convLayer
->
forward
(
PASS_GC
);
convLayer
->
forward
(
PASS_GC
);
return
convLayer
->
getOutputValue
();
return
convLayer
->
getOutputValue
();
}
}
TEST
(
Layer
,
conv
TransLayerFwd2
)
{
TEST
(
Layer
,
conv
ParaUnified
)
{
MatrixPtr
input
,
resultCpu
,
resultGpu
;
MatrixPtr
input
,
resultCpu
,
resultGpu
;
input
=
Matrix
::
create
(
1
,
4
*
4
,
false
,
false
);
input
=
Matrix
::
create
(
1
,
4
*
4
,
false
,
false
);
float
inputData
[]
=
{
1
,
2
,
3
,
4
,
float
inputData
[]
=
{
1
,
2
,
3
,
4
,
...
@@ -122,6 +123,38 @@ TEST(Layer, convTransLayerFwd2) {
...
@@ -122,6 +123,38 @@ TEST(Layer, convTransLayerFwd2) {
/*numfilters*/
2
,
/*numfilters*/
2
,
input
,
param
,
true
);
input
,
param
,
true
);
checkMatrixEqual
(
resultCpu
,
resultGpu
);
checkMatrixEqual
(
resultCpu
,
resultGpu
);
input
=
Matrix
::
create
(
1
,
3
*
3
*
2
,
false
,
false
);
float
inputData2
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
};
float
param2
[]
=
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
};
input
->
setData
(
inputData2
);
resultCpu
=
doOneConvTest
(
/* imgSize */
3
,
/* output_x */
2
,
/* stride */
1
,
/* padding */
0
,
/* filter_size */
2
,
/*channel*/
2
,
/*numfilters*/
2
,
input
,
param2
,
false
);
resultGpu
=
doOneConvTest
(
/* imgSize */
3
,
/* output_x */
2
,
/* stride */
1
,
/* padding */
0
,
/* filter_size */
2
,
/*channel*/
2
,
/*numfilters*/
2
,
input
,
param2
,
true
);
checkMatrixEqual
(
resultCpu
,
resultGpu
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录