From 9322d34032d2157486841bd0ddd45ca9a420db92 Mon Sep 17 00:00:00 2001 From: shippingwang Date: Wed, 26 Dec 2018 17:22:17 +0000 Subject: [PATCH] Fix, test=develop --- paddle/fluid/API.spec | 2 +- paddle/fluid/operators/shuffle_channel_op.cc | 33 +++++++++----------- paddle/fluid/operators/shuffle_channel_op.h | 1 - python/paddle/fluid/layers/nn.py | 4 +-- 4 files changed, 17 insertions(+), 23 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index b1e8a986fb6..a480a14ecc8 100644 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -208,7 +208,7 @@ paddle.fluid.layers.bilinear_tensor_product ArgSpec(args=['x', 'y', 'size', 'act paddle.fluid.layers.merge_selected_rows ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.get_tensor_from_selected_rows ArgSpec(args=['x', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.lstm ArgSpec(args=['input', 'init_h', 'init_c', 'max_len', 'hidden_size', 'num_layers', 'dropout_prob', 'is_bidirec', 'is_test', 'name', 'default_initializer', 'seed'], varargs=None, keywords=None, defaults=(0.0, False, False, None, None, -1)) -paddle.fluid.layers.shuffle_channel ArgSpec(args=['x', 'group', 'name'], varargs=None, keywords=None, defaults=(1, None)) +paddle.fluid.layers.shuffle_channel ArgSpec(args=['x', 'group', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.py_func ArgSpec(args=['func', 'x', 'out', 'backward_func', 'skip_vars_in_backward_input'], varargs=None, keywords=None, defaults=(None, None)) paddle.fluid.layers.psroi_pool ArgSpec(args=['input', 'rois', 'output_channels', 'spatial_scale', 'pooled_height', 'pooled_width', 'name'], varargs=None, keywords=None, defaults=(None,)) paddle.fluid.layers.huber_loss ArgSpec(args=['input', 'label', 'delta'], varargs=None, keywords=None, defaults=None) diff --git a/paddle/fluid/operators/shuffle_channel_op.cc b/paddle/fluid/operators/shuffle_channel_op.cc index 8449efe4a90..9b0631d5fff 100644 --- a/paddle/fluid/operators/shuffle_channel_op.cc +++ b/paddle/fluid/operators/shuffle_channel_op.cc @@ -29,15 +29,13 @@ class ShuffleChannelOp : public framework::OperatorWithKernel { ctx->SetOutputDim("Out", input_dims); } - /* - protected: - framework::OpKernelType GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - return framework::OpKernelType( - framework::ToDataType(ctx.Input("X")->type()), - ctx.device_context()); - } - */ + + protected: + framework::OpKernelType GetExpectedKernelType( + const framework::ExecutionContext& ctx) const override { + return framework::OpKernelType(ctx.Input("X")->type(), + ctx.device_context()); + } }; class ShuffleChannelOpMaker : public framework::OpProtoAndCheckerMaker { @@ -89,16 +87,13 @@ class ShuffleChannelGradOp : public framework::OperatorWithKernel { ctx->SetOutputDim(framework::GradVarName("X"), input_dims); } - /* - protected: - framework::OpKernelType GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - return framework::OpKernelType( - framework::ToDataType( - framework::ToDataType(ctx.Input("X")->type()), - ctx.device_context()); - } - */ + + protected: + framework::OpKernelType GetExpectedKernelType( + const framework::ExecutionContext& ctx) const override { + return framework::OpKernelType(ctx.Input("X")->type(), + ctx.device_context()); + } }; } // namespace operators diff --git a/paddle/fluid/operators/shuffle_channel_op.h b/paddle/fluid/operators/shuffle_channel_op.h index dbb4495e338..f6af1bc8859 100644 --- a/paddle/fluid/operators/shuffle_channel_op.h +++ b/paddle/fluid/operators/shuffle_channel_op.h @@ -50,7 +50,6 @@ class ShuffleChannelOpKernel : public framework::OpKernel { } } } - return; } }; diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 4d0ed7c55cd..9ebbb35c071 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -9335,13 +9335,13 @@ def get_tensor_from_selected_rows(x, name=None): return out -def shuffle_channel(x, group=1, name=None): +def shuffle_channel(x, group, name=None): """ **Shuffle Channel Operator** This operator obtains the group convolutional layer with channels shuffled. First, divide the input channels in each group into several subgroups, then, feed each group in the next layer with different subgroups. - Shuffle channel operation makes it possible to build more powerful structures + Channel shuffling operation makes it possible to build more powerful structures with multiple group convolutional layers. Args: -- GitLab