mindspore.ops.channel_shuffle

View Source On Gitee
mindspore.ops.channel_shuffle(x, groups)[source]

Divide the channels in a tensor of shape (,C,H,W) into g groups and rearrange them as (,Cg,g,HW), while retaining the original tensor shape in the final output.

Parameters
  • x (Tensor) – The input tensor.

  • groups (int) – Number of groups to divide channels in.

Returns

Tensor

Supported Platforms:

Ascend CPU

Examples

>>> import mindspore
>>> x = mindspore.tensor(mindspore.ops.arange(0, 16, dtype=mindspore.int16).reshape(1, 4, 2, 2))
>>> y = mindspore.ops.channel_shuffle(x, groups=2)
>>> print(y)
[[[[ 0  1]
   [ 2  3]]
   [[ 8  9]
   [10 11]]
   [[ 4  5]
   [ 6  7]]
   [[12 13]
   [14 15]]]]