Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
5a9ea9a7
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
697
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看板
提交
5a9ea9a7
编写于
12月 25, 2018
作者:
S
shippingwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ShuffleChannel Op
上级
76c6f115
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
6 deletion
+12
-6
paddle/fluid/operators/shuffle_channel_op.cc
paddle/fluid/operators/shuffle_channel_op.cc
+5
-1
paddle/fluid/operators/shuffle_channel_op.cu
paddle/fluid/operators/shuffle_channel_op.cu
+2
-0
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+5
-5
未找到文件。
paddle/fluid/operators/shuffle_channel_op.cc
浏览文件 @
5a9ea9a7
...
...
@@ -28,7 +28,7 @@ class ShuffleChannelOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE
(
input_dims
.
size
()
==
4
,
"The layout of input is NCHW."
);
// ENFORCE group
// auto group = ctx->Attrs().Get<int>("group");
ctx
->
SetOutputDim
(
"Out"
,
input_dims
);
}
/*
...
...
@@ -87,6 +87,10 @@ class ShuffleChannelGradOp : public framework::OperatorWithKernel {
"Output(X@Grad) should not be null"
);
auto
input_dims
=
ctx
->
GetInputDim
(
"X"
);
PADDLE_ENFORCE
(
input_dims
.
size
()
==
4
,
"The layout of input is NCHW."
);
// ENFORCE group
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"X"
),
input_dims
);
}
/*
...
...
paddle/fluid/operators/shuffle_channel_op.cu
浏览文件 @
5a9ea9a7
...
...
@@ -81,6 +81,7 @@ class ShuffleChannelGradOpCUDAKernel : public framework::OpKernel<T> {
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
*
input
=
ctx
.
Input
<
framework
::
Tensor
>
(
"X"
);
int
group
=
ctx
.
Attr
<
int
>
(
"group"
);
auto
input_dims
=
input
->
dims
();
auto
num
=
input_dims
[
0
];
auto
channel
=
input_dims
[
1
];
...
...
@@ -101,6 +102,7 @@ class ShuffleChannelGradOpCUDAKernel : public framework::OpKernel<T> {
int
blocks
=
NumBlocks
(
output_grad
->
numel
());
int
threads
=
kNumCUDAThreads
;
int
count
=
num
*
group_column
*
group_row
*
sp_sz
;
ShuffleChannel
<
T
><<<
blocks
,
threads
,
0
,
ctx
.
cuda_device_context
().
stream
()
>>>
(
count
,
feature_map_size
,
input_grad_data
,
output_grad_data
,
group_row
,
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
5a9ea9a7
...
...
@@ -55,6 +55,8 @@ __all__ = [
'softmax'
,
'pool2d'
,
'pool3d'
,
'adaptive_pool2d'
,
'adaptive_pool3d'
,
'batch_norm'
,
'beam_search_decode'
,
'conv2d_transpose'
,
...
...
@@ -9342,24 +9344,22 @@ def shuffle_channel(x, group=1, name=None):
x: The input tensor variable..
group: The num of group
Returns:
Variable: channel shuffled tensor variable.
Variable: channel
s
shuffled tensor variable.
Raises:
ValueError: If group i
n
not an int type variable.
ValueError: If group i
s
not an int type variable.
Examples:
.. code-block:: python
out = fluid.layers.shuffle_channel(x=group_conv,group=4)
"""
helper
=
LayerHelper
(
"shuffle_channel"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
helper
.
in
t
put_dtype
(
'x'
))
dtype
=
helper
.
input_dtype
(
'x'
))
if
not
isinstance
(
group
,
int
):
raise
TypeError
(
"group must be int type"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录