Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6e17babe
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
6e17babe
编写于
1月 30, 2018
作者:
X
xzl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More efficient, add check on python side
上级
b5ea0483
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
30 deletion
+26
-30
paddle/operators/CMakeLists.txt
paddle/operators/CMakeLists.txt
+0
-1
paddle/operators/math/depthwise_conv.cu
paddle/operators/math/depthwise_conv.cu
+24
-28
python/paddle/v2/fluid/layers/nn.py
python/paddle/v2/fluid/layers/nn.py
+2
-1
未找到文件。
paddle/operators/CMakeLists.txt
浏览文件 @
6e17babe
...
...
@@ -159,7 +159,6 @@ if (WITH_GPU)
op_library
(
conv_op SRCS conv_op.cc conv_op.cu.cc conv_cudnn_op.cu.cc DEPS
vol2col depthwise_conv
)
# op_library(conv_op SRCS conv_op.cc conv_op.cu.cc conv_cudnn_op.cu.cc DEPS vol2col)
op_library
(
edit_distance_op SRCS edit_distance_op.cc edit_distance_op.cu DEPS math_function
)
op_library
(
pool_op SRCS pool_op.cc pool_op.cu.cc pool_cudnn_op.cu.cc DEPS pooling
)
op_library
(
conv_transpose_op SRCS conv_transpose_op.cc conv_transpose_op.cu.cc
...
...
paddle/operators/math/depthwise_conv.cu
浏览文件 @
6e17babe
...
...
@@ -46,16 +46,18 @@ __global__ void KernelDepthwiseConv(
-
padding_height
+
h_out
*
stride_height
+
filter_height
-
1
;
const
int
w_in_end
=
-
padding_width
+
w_out
*
stride_width
+
filter_width
-
1
;
const
int
in_offset
=
((
batch
*
input_channels
+
c_in
)
*
input_height
)
*
input_width
;
if
((
h_in_start
>=
0
)
&&
(
h_in_end
<
input_height
)
&&
(
w_in_start
>=
0
)
&&
(
w_in_end
<
input_width
))
{
for
(
int
kh
=
0
;
kh
<
filter_height
;
++
kh
)
{
for
(
int
kw
=
0
;
kw
<
filter_width
;
++
kw
)
{
const
int
h_in
=
-
padding_height
+
h_out
*
stride_height
+
kh
;
const
int
w_in
=
-
padding_width
+
w_out
*
stride_width
+
kw
;
const
int
offset
=
((
batch
*
input_channels
+
c_in
)
*
input_height
+
h_in
)
*
input_width
+
w_in
;
const
int
h_in
=
h_in_start
+
kh
;
const
int
w_in
=
w_in_start
+
kw
;
const
int
offset
=
in_offset
+
h_in
*
input_width
+
w_in
;
value
+=
(
*
weight
)
*
input_data
[
offset
];
++
weight
;
}
...
...
@@ -63,14 +65,11 @@ __global__ void KernelDepthwiseConv(
}
else
{
for
(
int
kh
=
0
;
kh
<
filter_height
;
++
kh
)
{
for
(
int
kw
=
0
;
kw
<
filter_width
;
++
kw
)
{
const
int
h_in
=
-
padding_height
+
h_out
*
stride_heigh
t
+
kh
;
const
int
w_in
=
-
padding_width
+
w_out
*
stride_width
+
kw
;
const
int
h_in
=
h_in_star
t
+
kh
;
const
int
w_in
=
w_in_start
+
kw
;
if
((
h_in
>=
0
)
&&
(
h_in
<
input_height
)
&&
(
w_in
>=
0
)
&&
(
w_in
<
input_width
))
{
const
int
offset
=
((
batch
*
input_channels
+
c_in
)
*
input_height
+
h_in
)
*
input_width
+
w_in
;
const
int
offset
=
in_offset
+
h_in
*
input_width
+
w_in
;
value
+=
(
*
weight
)
*
input_data
[
offset
];
}
++
weight
;
...
...
@@ -159,36 +158,33 @@ __global__ void KernelDepthwiseConvFilterGrad(
const
int
h_in_end
=
-
padding_height
+
h_out
*
stride_height
+
filter_height
;
const
int
w_in_end
=
-
padding_width
+
w_out
*
stride_width
+
filter_width
;
const
int
in_offset
=
(
batch
*
input_channels
+
c_in
)
*
input_height
*
input_width
;
T
*
addr_offset
=
filter_grad_data
+
c_out
*
filter_height
*
filter_width
;
if
((
h_in_start
>=
0
)
&&
(
h_in_end
<
input_height
)
&&
(
w_in_start
>=
0
)
&&
(
w_in_end
<
input_width
))
{
for
(
int
kw
=
0
;
kw
<
filter_width
;
kw
++
)
{
for
(
int
kh
=
0
;
kh
<
filter_height
;
kh
++
)
{
const
int
h_in
=
-
padding_height
+
h_out
*
stride_height
+
kh
;
const
int
w_in
=
-
padding_width
+
w_out
*
stride_width
+
kw
;
const
int
offset
=
((
batch
*
input_channels
+
c_in
)
*
input_height
+
h_in
)
*
input_width
+
w_in
;
const
int
h_in
=
h_in_start
+
kh
;
const
int
w_in
=
w_in_start
+
kw
;
const
int
offset
=
in_offset
+
h_in
*
input_width
+
w_in
;
const
T
diff_temp
=
output_grad_data
[
index
]
*
input_data
[
offset
];
T
*
addr
=
filter_grad_data
+
c_out
*
filter_height
*
filter_width
+
kh
*
filter_width
+
kw
;
T
*
addr
=
addr_offset
+
kh
*
filter_width
+
kw
;
paddle
::
platform
::
CudaAtomicAdd
(
addr
,
diff_temp
);
}
}
}
else
{
for
(
int
kw
=
0
;
kw
<
filter_width
;
kw
++
)
{
for
(
int
kh
=
0
;
kh
<
filter_height
;
kh
++
)
{
const
int
h_in
=
-
padding_height
+
h_out
*
stride_heigh
t
+
kh
;
const
int
w_in
=
-
padding_width
+
w_out
*
stride_width
+
kw
;
const
int
h_in
=
h_in_star
t
+
kh
;
const
int
w_in
=
w_in_start
+
kw
;
if
((
h_in
>=
0
)
&&
(
h_in
<
input_height
)
&&
(
w_in
>=
0
)
&&
(
w_in
<
input_width
))
{
const
int
offset
=
((
batch
*
input_channels
+
c_in
)
*
input_height
+
h_in
)
*
input_width
+
w_in
;
const
int
offset
=
in_offset
+
h_in
*
input_width
+
w_in
;
const
T
diff_temp
=
output_grad_data
[
index
]
*
input_data
[
offset
];
T
*
addr
=
filter_grad_data
+
c_out
*
filter_height
*
filter_width
+
kh
*
filter_width
+
kw
;
T
*
addr
=
addr_offset
+
kh
*
filter_width
+
kw
;
paddle
::
platform
::
CudaAtomicAdd
(
addr
,
diff_temp
);
}
}
...
...
python/paddle/v2/fluid/layers/nn.py
浏览文件 @
6e17babe
...
...
@@ -1013,7 +1013,8 @@ def conv2d(input,
num_channels
=
input
.
shape
[
1
]
l_type
=
'conv2d'
if
num_channels
==
groups
and
not
use_cudnn
:
if
(
num_channels
==
groups
and
num_filters
%
num_channels
==
0
and
not
use_cudnn
):
l_type
=
'depthwise_conv'
helper
=
LayerHelper
(
l_type
,
**
locals
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录