
    {-jv                        d dl Z  G d d          Z ee j        j        dgdgdg           ee j        j        dgdgd	g           ee j        j        dgg dg           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j	        dgg d	g           ee j        j
        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        dgg d	g           ee j        j        j        ddgg d	g          gZ ee j        j        j        j        dgdgdg           ee j        j        j        j        dgdgd	g          gZe j        j        e j        j        gZ G d
 d          ZdS )    Nc                   "     e Zd ZdZ fdZ xZS )	LayerInfoz8
    Store the arg names of the inputs and outputs.
    c                     t                                                       || _        || _        || _        || _        d S N)super__init__layerinput_namesweight_namesoutput_names)selfr	   r
   r   r   	__class__s        k/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddle/quantization/imperative/ptq_registry.pyr   zLayerInfo.__init__   s>    
&((    )__name__
__module____qualname____doc__r   __classcell__r   s   @r   r   r      sB         ) ) ) ) ) ) ) ) )r   r   InputFilterOutputXYOutc                        e Zd ZdZi Zi ZdZ fdZed             Z	ed             Z
ed             Zed             Zed             Z xZS )	PTQRegistryzH
    Register the supported layers for PTQ and provide layers info.
    Fc                 H    t                                                       d S r   )r   r   )r   r   s    r   r   zPTQRegistry.__init__I   s    r   c                     | j         s<t          D ]}|| j        |j        <   t          t          z   }|D ]}|| j        |j        <   d| _         d S )NT)	is_initedPTQ_LAYERS_INFOsupported_layers_mapr	   QUANT_LAYERS_INFOregistered_layers_map)cls
layer_infoall_layers_infos      r   _initzPTQRegistry._initL   sk    } 	I- H H
=G()9::-0AAO- I I
>H)**:;;r   c                     |                                   || j        v p3t          |t          | j                                                            S )z
        Analyze whether the layer supports quantization.
        Args:
            layer(Layer): The input layer can be a python class or an instance.
        Returns:
            flag(bool): Whether the layer is supported.
        )r)   r#   
isinstancetuplekeysr&   r	   s     r   is_supported_layerzPTQRegistry.is_supported_layerW   sN     			00 
J516688995
 5
 	
r   c                     |                                   || j        v p3t          |t          | j                                                            S )z
        Analyze whether the layer is register layer_info.
        Args:
            layer(Layer): The input layer can be a python class or an instance.
        Returns:
            flag(bool): Whether the layer is register layer_info.
        )r)   r%   r+   r,   r-   r.   s     r   is_registered_layerzPTQRegistry.is_registered_layere   sN     			11 
Z527799::6
 6
 	
r   c                 X    |t           v p!t          |t          t                               S )z
        Analyze whether the layer is simulated quant layer.
        Args:
            layer(Layer): The input layer can be a python class or an instance.
        Returns:
            flag(bool): Whether the layer is supported.
        )SIMULATED_LAYERSr+   r,   r.   s     r   is_simulated_quant_layerz$PTQRegistry.is_simulated_quant_layers   s1     (( 
J5)**-
 -
 	
r   c                     |                      |          s
J d            | j                                        D ]\  }}||k    st          ||          r|c S  dS )z
        Get the information for the layer.
        Args:
            layer(Layer): The input layer can be a python class or an instance.
        Returns:
            layer_info(LayerInfo): The layer info of the input layer.
        z The input layer is not register.N)r1   r%   itemsr+   )r&   r	   	layer_keyr'   s       r   r'   zPTQRegistry.layer_info   s     &&u-- 	
 	
.	
 	
- &)%>%D%D%F%F 	" 	"!Iz	!!Zy%A%A!!!!! "	" 	"r   )r   r   r   r   r#   r%   r!   r   classmethodr)   r/   r1   r4   r'   r   r   s   @r   r   r   @   s          I       [ 
 
 [
 
 
 [
 

 

 [

 " " [" " " " "r   r   )paddler   nnConv2DLinearBatchNorm2DAdaptiveMaxPool2DAdaptiveAvgPool2D	AvgPool2D	MaxPool2DReLUReLU6	HardswishSwishSigmoidSoftmaxTanhquantaddr"   quant_layersQuantizedConv2DQuantizedLinearr$   r3   r    r   r   <module>rO      s   
) 
) 
) 
) 
) 
) 
) 
) Ifi	H:zBBIfiuug66Ifi#cUB66Ifi)C5"ug>>Ifi)C5"ug>>Ifi!C5"ug66Ifi!C5"ug66IfinseR%11Ifioub5'22Ifi!C5"ug66Ifioub5'22Ifi#UG44Ifi#UG44IfinseR%11Ifio!C:rE7;;& I	$4			
	
	  I	$4secUUG 
  I$fi&67 O" O" O" O" O" O" O" O" O" O"r   