Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ba786b2e
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看板
提交
ba786b2e
编写于
11月 27, 2016
作者:
W
wangyang59
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
only do test_ConvUnify when there is a gpu
上级
60bf1a47
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
51 deletion
+53
-51
paddle/gserver/tests/test_ConvUnify.cpp
paddle/gserver/tests/test_ConvUnify.cpp
+53
-51
未找到文件。
paddle/gserver/tests/test_ConvUnify.cpp
浏览文件 @
ba786b2e
...
...
@@ -40,60 +40,61 @@ MatrixPtr doOneConvTest(size_t imgSize, size_t output_x, size_t stride,
size_t
padding
,
size_t
filter_size
,
size_t
channel
,
size_t
numfilters
,
MatrixPtr
&
inputData
,
real
*
param
,
bool
useGpu
)
{
TestConfig
config
;
config
.
biasSize
=
numfilters
;
if
(
useGpu
)
{
config
.
layerConfig
.
set_type
(
"cudnn_conv"
);
}
else
{
config
.
layerConfig
.
set_type
(
"exconv"
);
}
config
.
layerConfig
.
set_num_filters
(
numfilters
);
config
.
layerConfig
.
set_partial_sum
(
1
);
config
.
layerConfig
.
set_shared_biases
(
true
);
config
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_0"
,
imgSize
*
imgSize
*
channel
,
channel
*
filter_size
*
filter_size
*
config
.
layerConfig
.
num_filters
()});
LayerInputConfig
*
input
=
config
.
layerConfig
.
add_inputs
();
ConvConfig
*
conv
=
input
->
mutable_conv_conf
();
conv
->
set_filter_size
(
filter_size
);
conv
->
set_filter_size_y
(
filter_size
);
conv
->
set_channels
(
channel
);
conv
->
set_padding
(
padding
);
conv
->
set_padding_y
(
padding
);
conv
->
set_stride
(
stride
);
conv
->
set_stride_y
(
stride
);
conv
->
set_groups
(
1
);
conv
->
set_filter_channels
(
channel
);
conv
->
set_img_size
(
imgSize
);
conv
->
set_output_x
(
output_x
);
config
.
layerConfig
.
set_size
(
conv
->
output_x
()
*
conv
->
output_x
()
*
config
.
layerConfig
.
num_filters
());
config
.
layerConfig
.
set_name
(
"conv"
);
std
::
vector
<
DataLayerPtr
>
dataLayers
;
LayerMap
layerMap
;
vector
<
Argument
>
datas
;
initDataLayer
(
config
,
&
dataLayers
,
&
datas
,
&
layerMap
,
"conv"
,
1
,
false
,
useGpu
);
dataLayers
[
0
]
->
getOutputValue
()
->
zeroMem
();
dataLayers
[
0
]
->
getOutputValue
()
->
copyFrom
(
*
inputData
);
// test layer initialize
std
::
vector
<
ParameterPtr
>
parameters
;
LayerPtr
convLayer
;
initTestLayer
(
config
,
&
layerMap
,
&
parameters
,
&
convLayer
);
convLayer
->
getBiasParameter
()
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
getBuf
(
PARAMETER_VALUE
)
->
copyFrom
(
param
,
channel
*
filter_size
*
filter_size
*
config
.
layerConfig
.
num_filters
());
convLayer
->
forward
(
PASS_GC
);
return
convLayer
->
getOutputValue
();
TestConfig
config
;
config
.
biasSize
=
numfilters
;
if
(
useGpu
)
{
config
.
layerConfig
.
set_type
(
"cudnn_conv"
);
}
else
{
config
.
layerConfig
.
set_type
(
"exconv"
);
}
config
.
layerConfig
.
set_num_filters
(
numfilters
);
config
.
layerConfig
.
set_partial_sum
(
1
);
config
.
layerConfig
.
set_shared_biases
(
true
);
config
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_0"
,
imgSize
*
imgSize
*
channel
,
channel
*
filter_size
*
filter_size
*
config
.
layerConfig
.
num_filters
()});
LayerInputConfig
*
input
=
config
.
layerConfig
.
add_inputs
();
ConvConfig
*
conv
=
input
->
mutable_conv_conf
();
conv
->
set_filter_size
(
filter_size
);
conv
->
set_filter_size_y
(
filter_size
);
conv
->
set_channels
(
channel
);
conv
->
set_padding
(
padding
);
conv
->
set_padding_y
(
padding
);
conv
->
set_stride
(
stride
);
conv
->
set_stride_y
(
stride
);
conv
->
set_groups
(
1
);
conv
->
set_filter_channels
(
channel
);
conv
->
set_img_size
(
imgSize
);
conv
->
set_output_x
(
output_x
);
config
.
layerConfig
.
set_size
(
conv
->
output_x
()
*
conv
->
output_x
()
*
config
.
layerConfig
.
num_filters
());
config
.
layerConfig
.
set_name
(
"conv"
);
std
::
vector
<
DataLayerPtr
>
dataLayers
;
LayerMap
layerMap
;
vector
<
Argument
>
datas
;
initDataLayer
(
config
,
&
dataLayers
,
&
datas
,
&
layerMap
,
"conv"
,
1
,
false
,
useGpu
);
dataLayers
[
0
]
->
getOutputValue
()
->
zeroMem
();
dataLayers
[
0
]
->
getOutputValue
()
->
copyFrom
(
*
inputData
);
// test layer initialize
std
::
vector
<
ParameterPtr
>
parameters
;
LayerPtr
convLayer
;
initTestLayer
(
config
,
&
layerMap
,
&
parameters
,
&
convLayer
);
convLayer
->
getBiasParameter
()
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
zeroMem
();
convLayer
->
getParameters
()[
0
]
->
getBuf
(
PARAMETER_VALUE
)
->
copyFrom
(
param
,
channel
*
filter_size
*
filter_size
*
config
.
layerConfig
.
num_filters
());
convLayer
->
forward
(
PASS_GC
);
return
convLayer
->
getOutputValue
();
}
TEST
(
Layer
,
convParaUnified
)
{
#ifndef PADDLE_ONLY_CPU
MatrixPtr
input
,
resultCpu
,
resultGpu
;
input
=
Matrix
::
create
(
1
,
4
*
4
,
false
,
false
);
float
inputData
[]
=
{
1
,
2
,
3
,
4
,
...
...
@@ -155,6 +156,7 @@ TEST(Layer, convParaUnified) {
/*numfilters*/
2
,
input
,
param2
,
true
);
checkMatrixEqual
(
resultCpu
,
resultGpu
);
#endif
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录