§
    ŠŠtjê  ã                   ó¬   — d dl mZ d dlZd dlmZ d dlmZ g d¢Z G d„ dej        ¦  «        Z G d„ d	ej        ¦  «        Z	 G d
„ dej        ¦  «        Z
dS )é    )ÚAnyN)Únn)ÚQConfig)Ú	QuantStubÚDeQuantStubÚQuantWrapperc                   óT   ‡ — e Zd ZdZddedz  fˆ fd„Zdej        dej        fd„Zˆ xZ	S )	r   a  Quantize stub module, before calibration, this is same as an observer,
    it will be swapped as `nnq.Quantize` in `convert`.

    Args:
        qconfig: quantization configuration for the tensor,
            if qconfig is not provided, we will get qconfig from parent modules
    NÚqconfigc                 ó^   •— t          ¦   «                              ¦   «          |r	|| _        d S d S ©N©ÚsuperÚ__init__r
   ©Úselfr
   Ú	__class__s     €úY/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/torch/ao/quantization/stubs.pyr   zQuantStub.__init__   ó6   ø€ Ý‰Œ×ÒÑÔÐØð 	#Ø"ˆDŒLˆLˆLð	#ð 	#ó    ÚxÚreturnc                 ó   — |S r   © ©r   r   s     r   ÚforwardzQuantStub.forward   ó   € Øˆr   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   ÚtorchÚTensorr   Ú__classcell__©r   s   @r   r   r      s}   ø€ € € € € ðð ð#ð # ¨$¡ð #ð #ð #ð #ð #ð #ð
˜œð ¨%¬,ð ð ð ð ð ð ð ð r   r   c                   óT   ‡ — e Zd ZdZddedz  fˆ fd„Zdej        dej        fd„Zˆ xZ	S )	r   a  Dequantize stub module, before calibration, this is same as identity,
    this will be swapped as `nnq.DeQuantize` in `convert`.

    Args:
        qconfig: quantization configuration for the tensor,
            if qconfig is not provided, we will get qconfig from parent modules
    Nr
   c                 ó^   •— t          ¦   «                              ¦   «          |r	|| _        d S d S r   r   r   s     €r   r   zDeQuantStub.__init__&   r   r   r   r   c                 ó   — |S r   r   r   s     r   r   zDeQuantStub.forward+   r   r   r   )
r   r   r   r    r   r   r!   r"   r   r#   r$   s   @r   r   r      s}   ø€ € € € € ðð ð#ð #  d¡
ð #ð #ð #ð #ð #ð #ð
˜œð ¨%¬,ð ð ð ð ð ð ð ð r   r   c                   ó€   ‡ — e Zd ZU dZeed<   eed<   ej        ed<   dej        fˆ fd„Z	de
j        de
j        fd„Zˆ xZS )	r   aç  A wrapper class that wraps the input module, adds QuantStub and
    DeQuantStub and surround the call to module with call to quant and dequant
    modules.

    This is used by the `quantization` utility functions to add the quant and
    dequant modules, before `convert` function `QuantStub` will just be observer,
    it observes the input tensor, after `convert`, `QuantStub`
    will be swapped to `nnq.Quantize` which does actual quantization. Similarly
    for `DeQuantStub`.
    ÚquantÚdequantÚmodulec                 óV  •— t          ¦   «                              ¦   «          t          |dd ¦  «        }|                      dt	          |¦  «        ¦  «         |                      dt          |¦  «        ¦  «         |                      d|¦  «         |                      |j        ¦  «         d S )Nr
   r)   r*   r+   )r   r   ÚgetattrÚ
add_moduler   r   ÚtrainÚtraining)r   r+   r
   r   s      €r   r   zQuantWrapper.__init__?   s�   ø€ Ý‰Œ×ÒÑÔÐÝ˜& )¨TÑ2Ô2ˆØ�Š˜¥¨7Ñ!3Ô!3Ñ4Ô4Ð4Ø�Š˜	¥;¨wÑ#7Ô#7Ñ8Ô8Ð8Ø�Š˜ &Ñ)Ô)Ð)Ø�
Š
�6”?Ñ#Ô#Ð#Ð#Ð#r   ÚXr   c                 ó€   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        S r   )r)   r+   r*   )r   r1   s     r   r   zQuantWrapper.forwardG   s0   € Ø�JŠJ�q‰MŒMˆØ�KŠK˜‰NŒNˆØ�|Š|˜A‰ŒÐr   )r   r   r   r    r   Ú__annotations__r   r   ÚModuler   r!   r"   r   r#   r$   s   @r   r   r   /   s    ø€ € € € € € ð	ð 	ð ÐÐÑØÐÐÑØŒIÐÐÑð$˜rœyð $ð $ð $ð $ð $ð $ð˜œð ¨%¬,ð ð ð ð ð ð ð ð r   r   )Útypingr   r!   r   Útorch.ao.quantizationr   Ú__all__r4   r   r   r   r   r   r   ú<module>r8      sß   ðØ Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )ð 7Ð
6Ð
6€ðð ð ð ð �”	ñ ô ð ð$ð ð ð ð �"”)ñ ô ð ð$ð ð ð ð �2”9ñ ô ð ð ð r   