Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f5ac3350
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f5ac3350
编写于
10月 11, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
1d41a6d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
27 deletion
+25
-27
paddle/operators/math/CMakeLists.txt
paddle/operators/math/CMakeLists.txt
+2
-3
paddle/operators/math/vol2col_test.cc
paddle/operators/math/vol2col_test.cc
+23
-24
未找到文件。
paddle/operators/math/CMakeLists.txt
浏览文件 @
f5ac3350
...
@@ -3,14 +3,13 @@ if(WITH_GPU)
...
@@ -3,14 +3,13 @@ if(WITH_GPU)
nv_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
nv_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
nv_library
(
softmax SRCS softmax.cc softmax.cu DEPS operator
)
nv_library
(
softmax SRCS softmax.cc softmax.cu DEPS operator
)
nv_library
(
cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator
)
nv_library
(
cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator
)
nv_library
(
vol2col SRCS vol2col.cc vol2col.cu DEPS device_context
operator
)
nv_library
(
vol2col SRCS vol2col.cc vol2col.cu DEPS device_context
)
else
()
else
()
cc_library
(
math_function SRCS math_function.cc im2col.cc pooling.cc DEPS cblas device_context operator
)
cc_library
(
math_function SRCS math_function.cc im2col.cc pooling.cc DEPS cblas device_context operator
)
cc_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
cc_test
(
math_function_test SRCS math_function_test.cc DEPS math_function tensor
)
cc_library
(
softmax SRCS softmax.cc DEPS operator
)
cc_library
(
softmax SRCS softmax.cc DEPS operator
)
cc_library
(
cross_entropy SRCS cross_entropy.cc DEPS operator
)
cc_library
(
cross_entropy SRCS cross_entropy.cc DEPS operator
)
cc_library
(
vol2col SRCS vol2col.cc DEPS device_context operator
)
cc_library
(
vol2col SRCS vol2col.cc DEPS device_context
)
endif
()
endif
()
cc_test
(
im2col_test SRCS im2col_test.cc DEPS math_function tensor
)
cc_test
(
im2col_test SRCS im2col_test.cc DEPS math_function tensor
)
...
...
paddle/operators/math/vol2col_test.cc
浏览文件 @
f5ac3350
...
@@ -18,10 +18,9 @@ limitations under the License. */
...
@@ -18,10 +18,9 @@ limitations under the License. */
template
<
typename
Place
>
template
<
typename
Place
>
void
testVol2col
()
{
void
testVol2col
()
{
paddle
::
framework
::
Tensor
input_tmp
;
paddle
::
framework
::
Tensor
input
;
paddle
::
framework
::
Tensor
input
;
paddle
::
framework
::
Tensor
output_cfo
;
paddle
::
framework
::
Tensor
input_tmp
;
paddle
::
framework
::
Tensor
output
_ocf
;
paddle
::
framework
::
Tensor
output
;
paddle
::
framework
::
Tensor
output_tmp
;
paddle
::
framework
::
Tensor
output_tmp
;
auto
*
place
=
new
Place
();
auto
*
place
=
new
Place
();
...
@@ -44,14 +43,14 @@ void testVol2col() {
...
@@ -44,14 +43,14 @@ void testVol2col() {
* [6, 7, 8,
* [6, 7, 8,
* 9, 10, 11]]
* 9, 10, 11]]
*
*
* output
_cfo
= [0, 1
* output = [0, 1
*
1, 2
* 1, 2
*
3, 4
* 3, 4
*
4, 5
* 4, 5
*
6, 7
* 6, 7
*
7, 8
* 7, 8
*
9, 10
* 9, 10
*
10, 11]
* 10, 11]
*
*
* col2vol = [[0, 2, 2,
* col2vol = [[0, 2, 2,
* 3, 8, 5]
* 3, 8, 5]
...
@@ -81,20 +80,20 @@ void testVol2col() {
...
@@ -81,20 +80,20 @@ void testVol2col() {
}
else
{
}
else
{
input
.
CopyFrom
<
float
>
(
input_tmp
,
*
place
);
input
.
CopyFrom
<
float
>
(
input_tmp
,
*
place
);
}
}
output
_cfo
.
mutable_data
<
float
>
({
1
,
filter_size
,
filter_size
,
filter_size
,
output
.
mutable_data
<
float
>
({
1
,
filter_size
,
filter_size
,
filter_size
,
output_depth
,
output_height
,
output_width
},
output_depth
,
output_height
,
output_width
},
*
place
);
*
place
);
paddle
::
operators
::
math
::
Vol2ColFunctor
<
Place
,
float
>
vol2col
;
paddle
::
operators
::
math
::
Vol2ColFunctor
<
Place
,
float
>
vol2col
;
vol2col
(
*
context
,
input
,
output
_cfo
,
stride
,
stride
,
stride
,
padding
,
padding
,
vol2col
(
*
context
,
input
,
output
,
stride
,
stride
,
stride
,
padding
,
padding
,
padding
);
padding
);
float
vol_2_col
[]
=
{
0
,
1
,
1
,
2
,
3
,
4
,
4
,
5
,
6
,
7
,
7
,
8
,
9
,
10
,
10
,
11
};
float
vol_2_col
[]
=
{
0
,
1
,
1
,
2
,
3
,
4
,
4
,
5
,
6
,
7
,
7
,
8
,
9
,
10
,
10
,
11
};
float
*
out_cfo_ptr
;
float
*
out_cfo_ptr
;
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
out_cfo_ptr
=
output
_cfo
.
data
<
float
>
();
out_cfo_ptr
=
output
.
data
<
float
>
();
}
else
{
}
else
{
output_tmp
.
CopyFrom
<
float
>
(
output
_cfo
,
paddle
::
platform
::
CPUPlace
());
output_tmp
.
CopyFrom
<
float
>
(
output
,
paddle
::
platform
::
CPUPlace
());
out_cfo_ptr
=
output_tmp
.
data
<
float
>
();
out_cfo_ptr
=
output_tmp
.
data
<
float
>
();
}
}
...
@@ -112,25 +111,25 @@ void testVol2col() {
...
@@ -112,25 +111,25 @@ void testVol2col() {
}
}
paddle
::
operators
::
math
::
Col2VolFunctor
<
Place
,
float
>
col2vol
;
paddle
::
operators
::
math
::
Col2VolFunctor
<
Place
,
float
>
col2vol
;
col2vol
(
*
context
,
input
,
output
_cfo
,
stride
,
stride
,
stride
,
padding
,
padding
,
col2vol
(
*
context
,
input
,
output
,
stride
,
stride
,
stride
,
padding
,
padding
,
padding
);
padding
);
float
*
in_
cfo_
ptr
;
float
*
in_ptr
;
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
in_
cfo_
ptr
=
input
.
data
<
float
>
();
in_ptr
=
input
.
data
<
float
>
();
}
else
{
}
else
{
input_tmp
.
CopyFrom
<
float
>
(
input
,
paddle
::
platform
::
CPUPlace
());
input_tmp
.
CopyFrom
<
float
>
(
input
,
paddle
::
platform
::
CPUPlace
());
in_
cfo_
ptr
=
input_tmp
.
data
<
float
>
();
in_ptr
=
input_tmp
.
data
<
float
>
();
}
}
for
(
int
i
=
0
;
i
<
12
;
++
i
)
{
for
(
int
i
=
0
;
i
<
12
;
++
i
)
{
EXPECT_EQ
(
in_
cfo_
ptr
[
i
],
col_2_vol
[
i
]);
EXPECT_EQ
(
in_ptr
[
i
],
col_2_vol
[
i
]);
}
}
}
}
TEST
(
math
,
vol2col
)
{
TEST
(
math
,
vol2col
)
{
testVol2col
<
paddle
::
platform
::
CPUPlace
>
();
testVol2col
<
paddle
::
platform
::
CPUPlace
>
();
#if
ndef PADDLE_ONLY_CPU
#if
def PADDLE_WITH_CUDA
testVol2col
<
paddle
::
platform
::
GPUPlace
>
();
testVol2col
<
paddle
::
platform
::
GPUPlace
>
();
#endif
#endif
// PADDLE_WITH_CUDA
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录