
    hv                     ^    S SK JrJrJr  SSKJr  SSKJr    " S S\5      r " S S\5      r	g	)
   )TENSOR_NAME_QUANT_SUFFIXQuantizedValueQuantizedValueType   )QuantOperatorBase)QDQOperatorBasec                   :   ^  \ rS rSrU 4S jrS rU 4S jrSrU =r$ )GatherQuant
   c                 $   > [         TU ]  X5        g Nsuper__init__selfonnx_quantizer	onnx_node	__class__s      c/var/www/fran/franai/venv/lib/python3.13/site-packages/onnxruntime/quantization/operators/gather.pyr   GatherQuant.__init__       3    c                     U R                   R                  U R                  5      (       d  gU R                   R                  U R                  R                  S   5      $ )NF    )	quantizershould_quantize_nodenodeis_valid_quantize_weightinput)r   s    r   should_quantizeGatherQuant.should_quantize   s@    ~~22499==~~66tyyq7IJJr   c                   > U R                   nUR                  S:X  d   eU R                  R                  US/5      u  nnnnUc  [        TU ]  5       $ UR                  S   [        -   n[        UR                  S   UUS   US   [        R                  5      nXpR                  R                  UR                  S   '   XaR                  S'   US   UR                  S'   UR                  U5        U R                  =R                  U-  sl        g )NGatherr   )r   op_typer   quantize_activationr   quantizeoutputr   r   r   Inputquantized_value_mapr    append	new_nodes)	r   r   quantized_input_nameszero_point_namesscale_namesnodesgather_new_outputq_outputr   s	           r   r'   GatherQuant.quantize   s    yy||x''' NN..taS9	
! (7#%% KKN-EE "KKNNQ$$
 >F**4;;q>:*A-a0

1T  E) r    )	__name__
__module____qualname____firstlineno__r   r!   r'   __static_attributes____classcell__r   s   @r   r
   r
   
   s    4K* *r   r
   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )	QDQGather4   c                 $   > [         TU ]  X5        g r   r   r   s      r   r   QDQGather.__init__5   r   r   c                    U R                   nUR                  S:X  d  UR                  S:X  d   eU R                  R                  UR                  S   5      (       d  U R                  R
                  (       aj  U R                  R                  UR                  S   5        U R                  R                  UR                  S   UR                  S   UR                  5        g U R                  R                  UR                  S   5      (       aB  U R                  R                  UR                  S   UR                  S   UR                  5        g g )Nr$   GatherElementsr   )r   r%   r   r   r    force_quantize_no_input_checkquantize_activation_tensorquantize_output_same_as_inputr(   nameis_tensor_quantized)r   r   s     r   r'   QDQGather.quantize8   s    yy||x'4<<;K+KKK>>224::a=AAT^^EqEqNN55djjmDNN88QTUX\XaXab^^//

1>>NN88QTUX\XaXab ?r   r4   )r5   r6   r7   r8   r   r'   r9   r:   r;   s   @r   r=   r=   4   s    4c cr   r=   N)
quant_utilsr   r   r   base_operatorr   qdq_base_operatorr   r
   r=   r4   r   r   <module>rL      s2    V V , .
'*# '*Tc cr   