
    kh<
                         d Z ddlmZ ddlmZ ddlmZ  G d dej                        ZeZ G d d	ej                        Z	y
)a
   Depthwise Separable Conv Modules

Basic DWS convs. Other variations of DWS exist with batch norm or activations between the
DW and PW convs such as the Depthwise modules in MobileNetV2 / EfficientNet and Xception.

Hacked together by / Copyright 2020 Ross Wightman
    )nn   )create_conv2d)get_norm_act_layerc                        e Zd ZdZdddddddej
                  ej                  ddf fd		Zed
        Z	ed        Z
d Z xZS )SeparableConvNormActz4 Separable Conv w/ trailing Norm and Activation
       r    F      ?TNc           	      
   t         t        |           t        |t	        ||z        ||||d      | _        t        t	        ||z        ||	||      | _        t        |
|      }|t        |      ni } ||fd|i|| _	        y )NTstridedilationpadding	depthwiser   bias)
drop_layer	apply_act)
superr   __init__r   intconv_dwconv_pwr   dictbn)selfin_channelsout_channelskernel_sizer   r   r   r   channel_multiplierpw_kernel_size
norm_layer	act_layerr   r   norm_act_layernorm_kwargs	__class__s                   V/var/www/teggl/fontify/venv/lib/python3.12/site-packages/timm/layers/separable_conv.pyr   zSeparableConvNormAct.__init__   s     	"D24$[+==>HgO %001<Y`gkm ,J	B5?5Kdj1QS RRkR    c                 .    | j                   j                  S Nr   r   r   s    r(   r   z SeparableConvNormAct.in_channels!       ||'''r)   c                 .    | j                   j                  S r+   r   r   r-   s    r(   r   z!SeparableConvNormAct.out_channels%       ||(((r)   c                 l    | j                  |      }| j                  |      }| j                  |      }|S r+   )r   r   r   r   xs     r(   forwardzSeparableConvNormAct.forward)   s.    LLOLLOGGAJr)   )__name__
__module____qualname____doc__r   BatchNorm2dReLUr   propertyr   r   r5   __classcell__r'   s   @r(   r   r      sb    >?TU_ahm$'bnn`b`g`gDS  ( ( ) )r)   r   c                   N     e Zd ZdZ	 	 d fd	Zed        Zed        Zd Z xZ	S )SeparableConv2dz Separable Conv
    c
           	          t         t        |           t        |t	        ||z        ||||d      | _        t        t	        ||z        ||	||      | _        y )NTr   r   )r   r@   r   r   r   r   r   )r   r   r   r    r   r   r   r   r!   r"   r'   s             r(   r   zSeparableConv2d.__init__6   s_    ot-/$[+==>HgO %001<Y`gkmr)   c                 .    | j                   j                  S r+   r,   r-   s    r(   r   zSeparableConv2d.in_channelsA   r.   r)   c                 .    | j                   j                  S r+   r0   r-   s    r(   r   zSeparableConv2d.out_channelsE   r1   r)   c                 J    | j                  |      }| j                  |      }|S r+   )r   r   r3   s     r(   r5   zSeparableConv2d.forwardI   s!    LLOLLOr)   )r	   r   r   r
   Fr   r   )
r6   r7   r8   r9   r   r<   r   r   r5   r=   r>   s   @r(   r@   r@   3   sA    hm89	m ( ( ) )r)   r@   N)
r9   torchr   r   create_norm_actr   Moduler   SeparableConvBnActr@    r)   r(   <module>rJ      s>     ( /299 D * bii r)   