o

    h                     @   s*   d dl Z d dl mZ G dd dejZdS )    N)nnc                       s<   e Zd ZdZ		ddededef fdd
Zd	d
 Z  Z	S )
LayerScaleav  LayerScale layer.

    Args:
        dim (int): Dimension of input features.
        inplace (bool): inplace: can optionally do the
            operation in-place. Default: ``False``
        data_format (str): The input data format, can be 'channels_last'
             and 'channels_first', representing (B, C, H, W) and
             (B, N, C) format data respectively.
    F
channels_lastdiminplacedata_formatc                    s@   t    |dv s
J d|| _|| _tt|d | _d S )N)r   channels_firstz<'data_format' could only be channels_last or channels_first.gh㈵>)	super__init__r   r   r   	Parametertorchonesweight)selfr   r   r   	__class__ 5/root/Awesome-Backbones/configs/common/layer_scale.pyr
      s   

zLayerScale.__init__c                 C   sV   | j dkr| jr|| jdddS || jddd S | jr&|| jS || j S )Nr      )r   r   mul_r   view)r   xr   r   r   forward   s
   
zLayerScale.forward)Fr   )
__name__
__module____qualname____doc__intboolstrr
   r   
__classcell__r   r   r   r   r      s    
r   )r   r   Moduler   r   r   r   r   <module>   s   