From c3fdb8177a827a89c6feea3b69d00222e8fdf0b9 Mon Sep 17 00:00:00 2001 From: zqw_1997 <118182234+zhengqiwen1997@users.noreply.github.com> Date: Thu, 24 Nov 2022 21:25:34 +0800 Subject: [PATCH] remove paddle.fluid.layers.nn.shuffle_channel (#48226) --- python/paddle/fluid/layers/nn.py | 76 ------------------- .../ir/inference/test_trt_subgraph_pass.py | 28 ------- .../fluid/tests/unittests/test_layers.py | 8 -- 3 files changed, 112 deletions(-) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 215dd0845e..d792e78629 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -146,7 +146,6 @@ __all__ = [ 'bilinear_tensor_product', 'merge_selected_rows', 'get_tensor_from_selected_rows', - 'shuffle_channel', 'temporal_shift', 'py_func', 'psroi_pool', @@ -9849,81 +9848,6 @@ def get_tensor_from_selected_rows(x, name=None): return out -def shuffle_channel(x, group, name=None): - """ - This operator shuffles the channels of input x. - It divide the input channels in each group into :attr:`group` subgroups, - and obtain a new order by selecting element from every subgroup one by one. - - Please refer to the paper - https://arxiv.org/pdf/1707.01083.pdf - - .. code-block:: text - - Given a 4-D tensor input with the shape (N, C, H, W): - input.shape = (1, 4, 2, 2) - input.data =[[[[0.1, 0.2], - [0.2, 0.3]], - - [[0.3, 0.4], - [0.4, 0.5]], - - [[0.5, 0.6], - [0.6, 0.7]], - - [[0.7, 0.8], - [0.8, 0.9]]]] - Given group: 2 - then we get a 4-D tensor out with the same shape of input: - out.shape = (1, 4, 2, 2) - out.data = [[[[0.1, 0.2], - [0.2, 0.3]], - - [[0.5, 0.6], - [0.6, 0.7]], - - [[0.3, 0.4], - [0.4, 0.5]], - - [[0.7, 0.8], - [0.8, 0.9]]]] - - Args: - x(Variable): The input tensor variable. It should be a 4-D tensor with shape [N, C, H, W] - group(int): Indicating the counts of subgroups, It should divide the number of channels. - - Returns: - out(Variable): the channels shuffling result is a tensor variable with the - same shape and same type as the input. - - Raises: - ValueError: If group is not an int type variable. - - Examples: - .. code-block:: python - - import paddle - import paddle.fluid as fluid - paddle.enable_static() - input = fluid.data(name='input', shape=[None,4,2,2], dtype='float32') - out = fluid.layers.shuffle_channel(x=input, group=2) - """ - helper = LayerHelper("shuffle_channel", **locals()) - - out = helper.create_variable_for_type_inference(dtype=x.dtype) - - if not isinstance(group, int): - raise TypeError("group must be int type") - - helper.append_op( - type="shuffle_channel", - inputs={"X": x}, - outputs={"Out": out}, - attrs={"group": group}, - ) - return out - - @templatedoc() def temporal_shift(x, seg_num, shift_ratio=0.25, name=None, data_format="NCHW"): """ diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_subgraph_pass.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_subgraph_pass.py index 86a995c45c..e260f46a5d 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_subgraph_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_subgraph_pass.py @@ -453,33 +453,5 @@ class TensorRTSubgraphPassElementwiseBroadcastDynamicTest(InferencePassTest): ) -class TensorRTSubgraphPassShuffleChannelTest(InferencePassTest): - def setUp(self): - with fluid.program_guard(self.main_program, self.startup_program): - data = fluid.data( - name="data", shape=[-1, 6, 64, 64], dtype="float32" - ) - sc_out = fluid.layers.shuffle_channel(data, group=3) - out = fluid.layers.batch_norm(sc_out, is_test=True) - self.feeds = { - "data": np.random.random([1, 6, 64, 64]).astype("float32"), - } - self.enable_trt = True - self.trt_parameters = ( - TensorRTSubgraphPassShuffleChannelTest.TensorRTParam( - 1 << 30, 32, 0, AnalysisConfig.Precision.Float32, False, False - ) - ) - self.fetch_list = [out] - - def test_check_output(self): - if core.is_compiled_with_cuda(): - use_gpu = True - self.check_output_with_option(use_gpu) - self.assertTrue( - PassVersionChecker.IsCompatible('tensorrt_subgraph_pass') - ) - - if __name__ == "__main__": unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_layers.py b/python/paddle/fluid/tests/unittests/test_layers.py index f78bb59a06..f62adf08ec 100644 --- a/python/paddle/fluid/tests/unittests/test_layers.py +++ b/python/paddle/fluid/tests/unittests/test_layers.py @@ -3744,14 +3744,6 @@ class TestBook(LayerTest): out = layers.temporal_shift(x, seg_num=2, shift_ratio=0.2) return out - def make_shuffle_channel(self): - with program_guard( - fluid.default_main_program(), fluid.default_startup_program() - ): - x = self._get_data(name="X", shape=[16, 4, 4], dtype="float32") - out = layers.shuffle_channel(x, group=4) - return out - def make_fsp_matrix(self): with program_guard( fluid.default_main_program(), fluid.default_startup_program() -- GitLab