U
    8‹Ñh  ã                   @   s>   d dl mZ ddlmZ ddlmZ dgZG dd„ deƒZdS )	é   )ÚModuleé   )Ú
functionalé    )ÚTensorÚChannelShufflec                       sV   e Zd ZU dZdgZeed< eddœ‡ fdd„Zeedœdd	„Z	e
d
œdd„Z‡  ZS )r   a.  Divides and rearranges the channels in a tensor.

    This operation divides the channels in a tensor of shape :math:`(*, C , H, W)`
    into g groups as :math:`(*, \frac{C}{g}, g, H, W)` and shuffles them,
    while retaining the original tensor shape in the final output.

    Args:
        groups (int): number of groups to divide channels in.

    Examples::

        >>> channel_shuffle = nn.ChannelShuffle(2)
        >>> input = torch.arange(1, 17, dtype=torch.float32).view(1, 4, 2, 2)
        >>> input
        tensor([[[[ 1.,  2.],
                  [ 3.,  4.]],
                 [[ 5.,  6.],
                  [ 7.,  8.]],
                 [[ 9., 10.],
                  [11., 12.]],
                 [[13., 14.],
                  [15., 16.]]]])
        >>> output = channel_shuffle(input)
        >>> output
        tensor([[[[ 1.,  2.],
                  [ 3.,  4.]],
                 [[ 9., 10.],
                  [11., 12.]],
                 [[ 5.,  6.],
                  [ 7.,  8.]],
                 [[13., 14.],
                  [15., 16.]]]])
    ÚgroupsN)r   Úreturnc                    s   t ƒ  ¡  || _d S ©N)ÚsuperÚ__init__r   )Úselfr   ©Ú	__class__© úM/tmp/user/2202/pip-unpacked-wheel-bf9o3bgk/torch/nn/modules/channelshuffle.pyr   .   s    
zChannelShuffle.__init__)Úinputr	   c                 C   s   t  || j¡S r
   )ÚFZchannel_shuffler   )r   r   r   r   r   Úforward2   s    zChannelShuffle.forward)r	   c                 C   s   d| j › �S )Nzgroups=)r   )r   r   r   r   Ú
extra_repr5   s    zChannelShuffle.extra_repr)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z__constants__ÚintÚ__annotations__r   r   r   Ústrr   Ú__classcell__r   r   r   r   r      s   
"N)	Úmoduler   Ú r   r   Ztorchr   Ú__all__r   r   r   r   r   Ú<module>   s   