o

    h                     @   s.   d dl mZ ddlmZ G dd dejZdS )    N   )
ConvModulec                	       sB   e Zd ZdZddddeddddddf	 fdd		Zd
d Z  ZS )DepthwiseSeparableConvModulea  Depthwise separable convolution module.

    See https://arxiv.org/pdf/1704.04861.pdf for details.

    This module can replace a ConvModule with the conv block replaced by two
    conv block: depthwise conv block and pointwise conv block. The depthwise
    conv block contains depthwise-conv/norm/activation layers. The pointwise
    conv block contains pointwise-conv/norm/activation layers. It should be
    noted that there will be norm/activation layer in the depthwise conv block
    if `norm_cfg` and `act_cfg` are specified.

    Args:
        in_channels (int): Number of channels in the input feature map.
            Same as that in ``nn._ConvNd``.
        out_channels (int): Number of channels produced by the convolution.
            Same as that in ``nn._ConvNd``.
        kernel_size (int | tuple[int]): Size of the convolving kernel.
            Same as that in ``nn._ConvNd``.
        stride (int | tuple[int]): Stride of the convolution.
            Same as that in ``nn._ConvNd``. Default: 1.
        padding (int | tuple[int]): Zero-padding added to both sides of
            the input. Same as that in ``nn._ConvNd``. Default: 0.
        dilation (int | tuple[int]): Spacing between kernel elements.
            Same as that in ``nn._ConvNd``. Default: 1.
        norm_cfg (dict): Default norm config for both depthwise ConvModule and
            pointwise ConvModule. Default: None.
        act_cfg (dict): Default activation config for both depthwise ConvModule
            and pointwise ConvModule. Default: dict(type='ReLU').
        dw_norm_cfg (dict): Norm config of depthwise ConvModule. If it is
            'default', it will be the same as `norm_cfg`. Default: 'default'.
        dw_act_cfg (dict): Activation config of depthwise ConvModule. If it is
            'default', it will be the same as `act_cfg`. Default: 'default'.
        pw_norm_cfg (dict): Norm config of pointwise ConvModule. If it is
            'default', it will be the same as `norm_cfg`. Default: 'default'.
        pw_act_cfg (dict): Activation config of pointwise ConvModule. If it is
            'default', it will be the same as `act_cfg`. Default: 'default'.
        kwargs (optional): Other shared arguments for depthwise and pointwise
            ConvModule. See ConvModule for ref.
    r   r   NReLU)typedefaultc
              	      s   t t|   d|
vsJ d|	dkr|	n|}	|
dkr|
n|}
|dkr%|n|}|dkr-|n|}t|||f|||||	|
d|
| _t||df||d|
| _d S )Ngroupszgroups should not be specifiedr   )stridepaddingdilationr   norm_cfgact_cfgr   )r   r
   )superr   __init__r   depthwise_convpointwise_conv)selfin_channelsout_channelskernel_sizer	   r
   r   r   r
   Zdw_norm_cfgZ
dw_act_cfgZpw_norm_cfgZ
pw_act_cfgkwargs	__class__ I/root/Awesome-Backbones/configs/common/depthwise_separable_conv_module.pyr   -   s<   
z%DepthwiseSeparableConvModule.__init__c                 C   s   |  |}| |}|S )N)r   r   )r   xr   r   r   forwardZ   s   

z$DepthwiseSeparableConvModule.forward)__name__
__module____qualname____doc__dictr   r   
__classcell__r   r   r   r   r      s    ,-r   )torch.nnnnconv_moduler   Moduler   r   r   r   r   <module>   s    