
    {-jE                     F    d dl mZ ddlmZ ddlmZ  G d de          ZdS )	    )
functional   )Layer   )ConvertibleQuantedLayerc                   @     e Zd ZdZdef fdZd Zd Zd Zd Z	 xZ
S )QuantedLinearz
    The computational logic of QuantizedLinear is the same as Linear.
    The only difference is that its inputs are all fake quantized.
    layerc                 H   t                                                       |j        | _        |j        | _        |j        | _        d | _        d | _        |j        |j                            |          | _        |j        !|j                            |          | _        d S d S N)	super__init__weightbiasnameweight_quanteractivation_quanter	_instance
activation)selfr
   q_config	__class__s      Z/var/www/html/banglarbhumi/venv/lib/python3.11/site-packages/paddle/nn/quant/qat/linear.pyr   zQuantedLinear.__init__   s    lJ	J	 #"&?&"*/";";E"B"BD*&.&9&C&CE&J&JD### +*    c                     |}| j         }| j        |                     |          }| j        |                     | j                   }|                     ||          S r   )r   r   r   _linear_forward)r   inputquant_inputquant_weights       r   forwardzQuantedLinear.forward+   s^    {".11%88K*..t{;;L##K>>>r   c                 J    t          j        ||| j        | j                  }|S )N)xr   r   r   )Flinearr   r   )r   r   r   outs       r   r   zQuantedLinear._linear_forward4   s#    hvDIDINNN
r   c                     dgS )N)r   r    r   s    r   weights_to_quantersz!QuantedLinear.weights_to_quanters8   s    ,--r   c                     dgS )Nr   r'   r(   s    r   activation_quantersz!QuantedLinear.activation_quanters;   s    $%%r   )__name__
__module____qualname____doc__r   r   r    r   r)   r+   __classcell__)r   s   @r   r	   r	      s         
Ke K K K K K K? ? ?  . . .& & & & & & &r   r	   N)	paddle.nnr   r#   layer.layersr   formatr   r	   r'   r   r   <module>r4      sr     & % % % % % ! ! ! ! ! ! , , , , , ,&& && && && &&+ && && && && &&r   