o
    #j,                     @   s  d dgdggd dgdggd dgdggddgdggddgdggddgdggdZ i dddgdggdddgdggd	ddgdggd
dgdggdddgdggddgdggddgdggddgdggddgdggdddgdggddgdggdddgdggdddgdggdddgdggdddgdggddgdggdddgdggi ddgdggddgdggddgdggddgdggddgdggdd gdggddgdggdddgdggd dgdggd!dgdggd"dgdggd#dd$gdggd%dgdggd&dgdggd'dgdggd(dgdggd)dgdggi d*dgdggd+ddgdggd,ddgdggd-dgdggd.dgdggd/d d0gd1ggd2d d0gd1ggd3dgdggd4dgdggd5dgdggd6dgdggd7dgdggd8dgdggd9dgdggd:dgdggd;dgdggd<dgdggi d=dgdggd>d gdggd?dgdggd@dgdggdAdgdggdBdgdggdCdgdggdDdEgdFggdGdgdggdHdgdggdIdgdggdJdgdggdKg dggdLdgdggdMdgdggdNdOdPgdggdQdOdPgdggi dRdgdSggdTdgdggdUdgdggdVdgdggdWdgdggdXdgddYggdZddgdggd[dgdggd\dgdggd]dd^gdggd_d gdggd`g dadggdbddcgdggdddgdggdedgg dfgdgdgdggdhdgdggdgdggdgdggdgdggdgdggdiZe  Zee G djdk dkZG dldm dmeZG dndo doeZG dpdq dqeZdrS )sZInputFilterOutputXYZOut)Zconv2dZdepthwise_conv2dZconv2d_transposemulmatmul	matmul_v2r   r   r   pool2delementwise_addconcatsoftmaxargmaxZ	transposeequalZgatherZgreater_equalgreater_thanZ
less_equal	less_thanmean	not_equalZreshapeZreshape2Z
transpose2nearest_interptrilinear_interpsliceZsqueezeelementwise_subrelurelu6
leaky_reluZpreluAlphatanhswishZdropoutZ
batch_norm
layer_normsigmoidelementwise_mulelementwise_pow
hard_swishhard_sigmoidZgruZWeightZHiddenZlstmZpad2dZpad3dflattenZflatten2Z
unsqueeze2Zflatten_contiguous_rangesplitZsqueeze2nearest_interp_v2bilinear_interpbilinear_interp_v2Zfill_constant_batch_size_likeZarg_maxabsZassigncastclipZ	box_coderZPriorBoxZ	OutputBoxcropZcumsumZ	expand_v2Zfill_any_likeZfill_constantgeluZinstance_normZlookup_tableWZIdsZlookup_table_v2ZnormZNormZp_normpowreduce_meanstackZtop_k_v2ZIndiceslogical_andZlogical_notZmeshgridZ	roi_alignZROIsZstrided_slicewhere)	Conditionr   r   Zgrid_samplerZGridZtileZ
group_norm)r   ZMeanZVariance
reduce_sumZsquare)softplusZshuffle_channel
reduce_maxscalec                   @   sB   e Zd ZdZg dfddZedd Zedd Zed	d
 ZdS )BaseQuantizera  
    Basic quantization configuration class, which configures some hyperparameters
    required for quantization, including the list of op types to be quantized,
    quantization bit number for weight and activation and the range of quantization values.
    Args:
        quantizable_op_type(list[str], optional): List the type of ops
            that will be quantized. Default is []. If quantizable_op_type is [],
            it will use the default quantization op type of the qunat config in
            the current Quantizer.
        quant_bits(int, optional): Quantization bit number for weight and activation.
            Default is 8.
       c                 C   s   || _ || _d| _d| _d S Ni   )_quantizable_op_type_quant_bits
_quant_min
_quant_maxselfZquantizable_op_typeZ
quant_bits rA   h/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/static/quantization/quant_config.py__init__   s   
zBaseQuantizer.__init__c                 C   s<   t t }| jrg }| jD ]}||v r|| q|S |S )z
        Operation type list which should support weight quantization.
        And before these ops, quant dequant nodes will be inserted.
        )list#SUPPORT_WEIGHT_QUANTIZATION_OP_DICTkeysr;   append)r@   Zbase_weight_op_type_listZweight_list_op_typerA   rA   rB   weight_quant_operation_types   s   

z*BaseQuantizer.weight_quant_operation_typesc                 C   sD   t t }g }| jr| jD ]}||v r|| q|S g d}|S )
        Operation type list which should support activation quantization.
        And before these ops, quant dequant nodes will be inserted.
        )r   r   r   )rD    SUPPORT_ACT_QUANTIZATION_OP_DICTrF   r;   rG   )r@   Zbase_act_op_type_listZact_quant_op_listrH   rA   rA   rB    activation_quant_operation_types   s   

z.BaseQuantizer.activation_quant_operation_typesc                 C   s   t t S )aU  
        Operation type list for observer in quantization. These nodes only count the
        calibration boundary scale and do not participate in the fake quantization.
        In order to facilitate the deployment of the prediction engine, quant
        and dequant nodes will be inserted after these ops when exporting the model.
        )rD   rK   rF   r@   rA   rA   rB   observer_operation_types   s   z&BaseQuantizer.observer_operation_typesN)	__name__
__module____qualname____doc__rC   propertyrI   rL   rN   rA   rA   rA   rB   r7      s    



r7   c                       2   e Zd ZdZg df fdd	Zedd Z  ZS )TensorRTQuantizera  
    TensorRT quantization configuration class.
    Args:
        quantizable_op_type(list[str], optional): List the type of ops
            that will be quantized. Default is []. If quantizable_op_type is [],
            it will use the default quantization op type of the qunat config in
            the current Quantizer.
        quant_bits(int, optional): Quantization bit number for weight and activation.
            Default is 8.
    r8   c                    &   t    || _|| _d| _d| _d S r9   superrC   r;   r<   r=   r>   r?   	__class__rA   rB   rC      
   

zTensorRTQuantizer.__init__c                 C      g dS )rJ   )!r   r	   r   r   r   r
   r   r   r   r   r   r   r   r   r4   r+   r!   r    r   r   r   r#   r%   r   r   r$   r%   r&   r)   r-   r.   r3   r5   rA   rM   rA   rA   rB   rL         z2TensorRTQuantizer.activation_quant_operation_typesrO   rP   rQ   rR   rC   rS   rL   __classcell__rA   rA   rY   rB   rU          rU   c                       rT   )MKLDNNQuantizera  
    MKLDNN quantization configuration class.
    Args:
        quantizable_op_type(list[str], optional): List the type of ops
            that will be quantized. Default is []. If quantizable_op_type is [],
            it will use the default quantization op type of the qunat config in
            the current Quantizer.
        quant_bits(int, optional): Quantization bit number for weight and activation.
            Default is 8.
    r8   c                    rV   r9   rW   r?   rY   rA   rB   rC     r[   zMKLDNNQuantizer.__init__c                 C   r\   )rJ   )r   r	   r   r
   r   r$   r#   rA   rM   rA   rA   rB   rL   !  r]   z0MKLDNNQuantizer.activation_quant_operation_typesr^   rA   rA   rY   rB   ra   
  r`   ra   c                       s&   e Zd ZdZg df fdd	Z  ZS )ARMCPUQuantizera  
    ARM CPU with Paddle Lite quantization configuration class.
    Args:
        quantizable_op_type(list[str], optional): List the type of ops
            that will be quantized. Default is []. If quantizable_op_type is [],
            it will use the default quantization op type of the qunat config in
            the current Quantizer.
        quant_bits(int, optional): Quantization bit number for weight and activation.
            Default is 8.
    r8   c                    rV   )Nir:   rW   r?   rY   rA   rB   rC   >  r[   zARMCPUQuantizer.__init__)rO   rP   rQ   rR   rC   r_   rA   rA   rY   rB   rb   2  s
    rb   N)	rE   rK   copyZSUPPORT_QUANTIZATION_OP_DICTupdater7   rU   ra   rb   rA   rA   rA   rB   <module>   sz  	
 !"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTU
V


^
IB(