
    קg                         d dl mZ  G d dej                  Z G d dej                  Z G d dej                  ZdS )	    )nnc                   *     e Zd ZdZd fd	Zd Z x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__s     W/var/www/html/ai-engine/env/lib/python3.11/site-packages/torch/ao/quantization/stubs.pyr
   zQuantStub.__init__   6     	#"DLLL	# 	#    c                     |S r    r   xs     r   forwardzQuantStub.forward       r   r   __name__
__module____qualname____doc__r
   r   __classcell__r   s   @r   r   r      V         # # # # # #
      r   r   c                   *     e Zd ZdZd fd	Zd Z xZS )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                 ^    t                                                       |r	|| _        d S d S r   r   r   s     r   r
   zDeQuantStub.__init__!   r   r   c                     |S r   r   r   s     r   r   zDeQuantStub.forward&   r   r   r   r   r   s   @r   r!   r!      r   r   r!   c                   R     e Zd ZU dZeed<   eed<   ej        ed<    fdZ	d Z
 x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                 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__9   s    &)T227!3!3444	;w#7#7888&)))

6?#####r   c                     |                      |          }|                     |          }|                     |          S r   )r&   r(   r'   )r   Xs     r   r   zQuantWrapper.forwardA   s0    JJqMMKKNN||Ar   )r   r   r   r   r   __annotations__r!   r   Moduler
   r   r   r   s   @r   r%   r%   *   s{         	 	 I$ $ $ $ $      r   r%   N)torchr   r1   r   r!   r%   r   r   r   <module>r3      s             	   $    ")   $    29     r   