Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
c85d777f
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c85d777f
编写于
10月 10, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
3db3a106
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
16 addition
and
34 deletion
+16
-34
paddle/operators/math/CMakeLists.txt
paddle/operators/math/CMakeLists.txt
+5
-3
paddle/operators/math/vol2col.cc
paddle/operators/math/vol2col.cc
+1
-1
paddle/operators/math/vol2col_test.cc
paddle/operators/math/vol2col_test.cc
+10
-30
未找到文件。
paddle/operators/math/CMakeLists.txt
浏览文件 @
c85d777f
if
(
WITH_GPU
)
nv_library
(
math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu
vol2col.cc vol2col.cu
pooling.cc pooling.cu DEPS cblas device_context operator
)
nv_library
(
math_function SRCS math_function.cc math_function.cu im2col.cc im2col.cu pooling.cc pooling.cu DEPS cblas device_context operator
)
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
(
cross_entropy SRCS cross_entropy.cc cross_entropy.cu DEPS operator
)
nv_library
(
vol2col SRCS vol2col.cc vol2col.cu DEPS cblas device_context operator
)
else
()
cc_library
(
math_function SRCS math_function.cc im2col.cc
vol2col.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_library
(
softmax SRCS softmax.cc DEPS operator
)
cc_library
(
cross_entropy SRCS cross_entropy.cc DEPS operator
)
cc_library
(
vol2col SRCS vol2col.cc DEPS cblas device_context operator
)
endif
()
cc_test
(
im2col_test SRCS im2col_test.cc DEPS math_function tensor
)
cc_test
(
vol2col_test SRCS vol2col_test.cc DEPS
math_function
tensor
)
cc_test
(
vol2col_test SRCS vol2col_test.cc DEPS
vol2col
tensor
)
paddle/operators/math/vol2col.cc
浏览文件 @
c85d777f
...
...
@@ -67,7 +67,7 @@ class Vol2ColFunctor<platform::CPUPlace, T> {
((
c
*
output_depth
+
d
)
*
output_height
+
h
)
*
output_width
+
w
;
if
(
h_pad
<
0
||
h_pad
>=
input_height
||
w_pad
<
0
||
w_pad
>=
input_width
||
d_pad
<
0
||
d_pad
>=
input_depth
)
{
col_data
[
col_idx
]
=
T
(
0
);
col_data
[
col_idx
]
=
static_cast
<
T
>
(
0
);
}
else
{
int
vol_idx
=
((
c_in
*
input_depth
+
d_pad
)
*
input_height
+
h_pad
)
*
...
...
paddle/operators/math/vol2col_test.cc
浏览文件 @
c85d777f
...
...
@@ -30,12 +30,12 @@ void testVol2col() {
context
=
new
paddle
::
platform
::
CPUDeviceContext
(
paddle
::
platform
::
CPUPlace
());
}
else
{
#if
ndef PADDLE_ONLY_CPU
#if
def PADDLE_WITH_CUDA
context
=
new
paddle
::
platform
::
CUDADeviceContext
(
paddle
::
platform
::
GPUPlace
());
#else
PADDLE_THROW
(
"no GPU support"
);
#endif // PADDLE_
ONLY_CPU
#endif // PADDLE_
WITH_CUDA
}
/**
...
...
@@ -89,6 +89,7 @@ void testVol2col() {
vol2col
(
*
context
,
input
,
output_cfo
,
stride
,
stride
,
stride
,
padding
,
padding
,
padding
);
float
vol_2_col
[]
=
{
0
,
1
,
1
,
2
,
3
,
4
,
4
,
5
,
6
,
7
,
7
,
8
,
9
,
10
,
10
,
11
};
float
*
out_cfo_ptr
;
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
out_cfo_ptr
=
output_cfo
.
data
<
float
>
();
...
...
@@ -97,24 +98,12 @@ void testVol2col() {
out_cfo_ptr
=
output_tmp
.
data
<
float
>
();
}
EXPECT_EQ
(
out_cfo_ptr
[
0
],
0
);
EXPECT_EQ
(
out_cfo_ptr
[
1
],
1
);
EXPECT_EQ
(
out_cfo_ptr
[
2
],
1
);
EXPECT_EQ
(
out_cfo_ptr
[
3
],
2
);
EXPECT_EQ
(
out_cfo_ptr
[
4
],
3
);
EXPECT_EQ
(
out_cfo_ptr
[
5
],
4
);
EXPECT_EQ
(
out_cfo_ptr
[
6
],
4
);
EXPECT_EQ
(
out_cfo_ptr
[
7
],
5
);
EXPECT_EQ
(
out_cfo_ptr
[
8
],
6
);
EXPECT_EQ
(
out_cfo_ptr
[
9
],
7
);
EXPECT_EQ
(
out_cfo_ptr
[
10
],
7
);
EXPECT_EQ
(
out_cfo_ptr
[
11
],
8
);
EXPECT_EQ
(
out_cfo_ptr
[
12
],
9
);
EXPECT_EQ
(
out_cfo_ptr
[
13
],
10
);
EXPECT_EQ
(
out_cfo_ptr
[
14
],
10
);
EXPECT_EQ
(
out_cfo_ptr
[
15
],
11
);
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
EXPECT_EQ
(
out_cfo_ptr
[
i
],
vol_2_col
[
i
]);
}
// Col2Vol test
float
col_2_vol
[]
=
{
0
,
2
,
2
,
3
,
8
,
5
,
6
,
14
,
8
,
9
,
20
,
11
};
memset
(
input_ptr
,
0
,
12
*
sizeof
(
float
));
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
input
=
input_tmp
;
...
...
@@ -134,18 +123,9 @@ void testVol2col() {
in_cfo_ptr
=
input_tmp
.
data
<
float
>
();
}
EXPECT_EQ
(
in_cfo_ptr
[
0
],
0
);
EXPECT_EQ
(
in_cfo_ptr
[
1
],
2
);
EXPECT_EQ
(
in_cfo_ptr
[
2
],
2
);
EXPECT_EQ
(
in_cfo_ptr
[
3
],
3
);
EXPECT_EQ
(
in_cfo_ptr
[
4
],
8
);
EXPECT_EQ
(
in_cfo_ptr
[
5
],
5
);
EXPECT_EQ
(
in_cfo_ptr
[
6
],
6
);
EXPECT_EQ
(
in_cfo_ptr
[
7
],
14
);
EXPECT_EQ
(
in_cfo_ptr
[
8
],
8
);
EXPECT_EQ
(
in_cfo_ptr
[
9
],
9
);
EXPECT_EQ
(
in_cfo_ptr
[
10
],
20
);
EXPECT_EQ
(
in_cfo_ptr
[
11
],
11
);
for
(
int
i
=
0
;
i
<
12
;
++
i
)
{
EXPECT_EQ
(
in_cfo_ptr
[
i
],
col_2_vol
[
i
]);
}
}
TEST
(
math
,
vol2col
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录