o
    ûÇhø  ã                   @   sF   d dl mZ G dd„ dejƒZG dd„ dejƒZG dd„ dejƒZdS )	é    )Únnc                       ó*   e Zd ZdZd‡ fdd„	Zdd„ Z‡  ZS )Ú	QuantStuba  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
    Nc                    ó   t ƒ  ¡  |r|| _d S d S ©N©ÚsuperÚ__init__Úqconfig©Úselfr
   ©Ú	__class__© úo/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/torch/ao/quantization/stubs.pyr	      ó   

ÿzQuantStub.__init__c                 C   ó   |S r   r   ©r   Úxr   r   r   Úforward   ó   zQuantStub.forwardr   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   Ú__classcell__r   r   r   r   r      ó    r   c                       r   )ÚDeQuantStuba  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
    Nc                    r   r   r   r   r   r   r   r	   !   r   zDeQuantStub.__init__c                 C   r   r   r   r   r   r   r   r   &   r   zDeQuantStub.forwardr   r   r   r   r   r   r      r   r   c                       sD   e Zd ZU dZeed< eed< ejed< ‡ fdd„Z	dd„ Z
‡  ZS )	ÚQuantWrapperaç  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                    sR   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   r   r   r	   9   s   
zQuantWrapper.__init__c                 C   s   |   |¡}|  |¡}|  |¡S r   )r    r"   r!   )r   ÚXr   r   r   r   A   s   


zQuantWrapper.forward)r   r   r   r   r   Ú__annotations__r   r   ÚModuler	   r   r   r   r   r   r   r   *   s   
 

r   N)Útorchr   r)   r   r   r   r   r   r   r   Ú<module>   s   