Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
shiyivei
Paddle
提交
c42e2049
P
Paddle
项目概览
shiyivei
/
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,发现更多精彩内容 >>
提交
c42e2049
编写于
9月 21, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine code.
上级
bb546cf1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
38 addition
and
33 deletion
+38
-33
paddle/operators/gemm_conv2d_op.h
paddle/operators/gemm_conv2d_op.h
+6
-6
paddle/operators/math/im2col.cc
paddle/operators/math/im2col.cc
+12
-10
paddle/operators/math/im2col.cu
paddle/operators/math/im2col.cu
+12
-10
paddle/operators/math/im2col.h
paddle/operators/math/im2col.h
+6
-5
paddle/operators/math/im2col_test.cc
paddle/operators/math/im2col_test.cc
+2
-2
未找到文件。
paddle/operators/gemm_conv2d_op.h
浏览文件 @
c42e2049
...
...
@@ -84,8 +84,8 @@ class GemmConv2DKernel : public framework::OpKernel {
for
(
int
g
=
0
;
g
<
groups
;
g
++
)
{
// im2col
Tensor
in_slice
=
in_batch
.
Slice
<
T
>
(
g
*
in_step
,
(
g
+
1
)
*
in_step
);
im2col
(
in_slice
,
col
,
strides
[
0
],
strides
[
1
],
paddings
[
0
],
padding
s
[
1
],
context
.
device_context
()
);
im2col
(
context
.
device_context
(),
in_slice
,
col
,
strides
[
0
],
stride
s
[
1
],
paddings
[
0
],
paddings
[
1
]
);
// gemm
Tensor
out_slice
=
out_batch
.
Slice
<
T
>
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
...
...
@@ -185,8 +185,8 @@ class GemmConvGrad2DKernel : public framework::OpKernel {
// col2im
Tensor
in_grad_slice
=
in_grad_batch
.
Slice
<
T
>
(
g
*
in_step
,
(
g
+
1
)
*
in_step
);
col2im
(
in_grad_slice
,
col
,
strides
[
0
],
strides
[
1
],
padding
s
[
0
],
paddings
[
1
],
context
.
device_context
()
);
col2im
(
context
.
device_context
(),
in_grad_slice
,
col
,
stride
s
[
0
],
strides
[
1
],
paddings
[
0
],
paddings
[
1
]
);
}
}
}
...
...
@@ -207,8 +207,8 @@ class GemmConvGrad2DKernel : public framework::OpKernel {
Tensor
out_grad_slice
=
out_grad_batch
.
Slice
<
T
>
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
Tensor
in_slice
=
in_batch
.
Slice
<
T
>
(
g
*
in_step
,
(
g
+
1
)
*
in_step
);
im2col
(
in_slice
,
col
,
strides
[
0
],
strides
[
1
],
padding
s
[
0
],
paddings
[
1
],
context
.
device_context
()
);
im2col
(
context
.
device_context
(),
in_slice
,
col
,
stride
s
[
0
],
strides
[
1
],
paddings
[
0
],
paddings
[
1
]
);
// gemm
Tensor
filter_grad_slice
=
...
...
paddle/operators/math/im2col.cc
浏览文件 @
c42e2049
...
...
@@ -27,9 +27,10 @@ template <class T>
class
Im2ColFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kCFO
,
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
...
...
@@ -79,9 +80,9 @@ template <class T>
class
Col2ImFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kCFO
,
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding
_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride
_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
int
input_channels
=
im
.
dims
()[
0
];
...
...
@@ -137,9 +138,10 @@ template <class T>
class
Im2ColFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kOCF
,
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
int
input_channels
=
im
.
dims
()[
0
];
...
...
@@ -197,9 +199,9 @@ template <class T>
class
Col2ImFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kOCF
,
platform
::
CPUPlace
,
T
>
{
public:
void
operator
()(
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding
_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride
_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
int
input_channels
=
im
.
dims
()[
0
];
...
...
paddle/operators/math/im2col.cu
浏览文件 @
c42e2049
...
...
@@ -64,9 +64,10 @@ template <class T>
class
Im2ColFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kCFO
,
platform
::
GPUPlace
,
T
>
{
public:
void
operator
()(
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
...
...
@@ -149,9 +150,9 @@ template <class T>
class
Col2ImFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kCFO
,
platform
::
GPUPlace
,
T
>
{
public:
void
operator
()(
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding
_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride
_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
...
...
@@ -235,9 +236,10 @@ template <class T>
class
Im2ColFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kOCF
,
platform
::
GPUPlace
,
T
>
{
public:
void
operator
()(
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
int
input_channels
=
im
.
dims
()[
0
];
...
...
@@ -318,9 +320,9 @@ template <class T>
class
Col2ImFunctor
<
paddle
::
operators
::
math
::
ColFormat
::
kOCF
,
platform
::
GPUPlace
,
T
>
{
public:
void
operator
()(
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding
_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
)
{
void
operator
()(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride
_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
)
{
PADDLE_ENFORCE
(
im
.
dims
().
size
()
==
3
);
PADDLE_ENFORCE
(
col
.
dims
().
size
()
==
5
);
int
input_channels
=
im
.
dims
()[
0
];
...
...
paddle/operators/math/im2col.h
浏览文件 @
c42e2049
...
...
@@ -72,17 +72,18 @@ enum class ColFormat { kCFO = 0, kOCF = 1 };
template
<
ColFormat
Format
,
typename
Place
,
typename
T
>
class
Im2ColFunctor
{
public:
void
operator
()(
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
void
operator
()(
const
platform
::
DeviceContext
&
context
,
const
framework
::
Tensor
&
im
,
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
);
int
padding_width
);
};
template
<
ColFormat
Format
,
typename
Place
,
typename
T
>
class
Col2ImFunctor
{
public:
void
operator
()(
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride_height
,
int
stride_width
,
int
padding
_height
,
int
padding_width
,
const
platform
::
DeviceContext
&
context
);
void
operator
()(
const
platform
::
DeviceContext
&
context
,
framework
::
Tensor
&
im
,
const
framework
::
Tensor
&
col
,
int
stride
_height
,
int
stride_width
,
int
padding_height
,
int
padding_width
);
};
}
// namespace math
...
...
paddle/operators/math/im2col_test.cc
浏览文件 @
c42e2049
...
...
@@ -78,8 +78,8 @@ void testIm2col() {
PADDLE_THROW
(
"no GPU support"
);
#endif // PADDLE_ONLY_CPU
}
im2col
(
input
,
output_cfo
,
stride
,
stride
,
padding
,
padding
,
*
context
);
im2col_ocf
(
input
,
output_ocf
,
stride
,
stride
,
padding
,
padding
,
*
context
);
im2col
(
*
context
,
input
,
output_cfo
,
stride
,
stride
,
padding
,
padding
);
im2col_ocf
(
*
context
,
input
,
output_ocf
,
stride
,
stride
,
padding
,
padding
);
float
*
out_cfo_ptr
;
if
(
paddle
::
platform
::
is_cpu_place
(
*
place
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录