
     Ngv                     l    d dl mZmZmZ ddlmZ ddlmZ 	  G d de          Z G d de          Z	d	S )
   )TENSOR_NAME_QUANT_SUFFIXQuantizedValueQuantizedValueType   )QuantOperatorBase)QDQOperatorBasec                   .     e Zd Z fdZd Z fdZ xZS )GatherQuantc                 L    t                                          ||           d S Nsuper__init__selfonnx_quantizer	onnx_node	__class__s      e/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnxruntime/quantization/operators/gather.pyr   zGatherQuant.__init__   #    33333    c                     | j                             | j                  sdS | j                             | j        j        d                   S )NF    )	quantizershould_quantize_nodenodeis_valid_quantize_weightinput)r   s    r   should_quantizezGatherQuant.should_quantize   s@    ~2249== 	5~66tyq7IJJJr   c                    | j         }|j        dk    sJ | j                            |dg          \  }}}}| t	                                                      S |j        d         t          z   }t          |j        d         ||d         |d         t          j
                  }|| j        j        |j        d         <   ||j        d<   |d         |j        d<   |                    |           | j        xj        |z  c_        d S )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$   zGatherQuant.quantize   s   y|x'''' N..taS99	
! (77##%%% KN-EE "KNNQ$
 
 >F*4;q>:*A-a0
1T  E)    r   )__name__
__module____qualname__r   r   r$   __classcell__r   s   @r   r
   r
   
   sc        4 4 4 4 4K K K* * * * * * * * *r   r
   c                   $     e Zd Z fdZd Z xZS )	QDQGatherc                 L    t                                          ||           d S r   r   r   s      r   r   zQDQGather.__init__5   r   r   c                    | j         }|j        dk    s|j        dk    sJ | j                            |j        d                   s| j        j        r^| j                            |j        d                    | j                            |j        d         |j        d         |j	                   d S | j        
                    |j        d                   r9| j                            |j        d         |j        d         |j	                   d S d S )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$   zQDQGather.quantize8   s    y|x''4<;K+K+K+K+K>224:a=AA 	cT^Eq 	cN55djmDDDN88QTUX\Xabbbbb^//
1>> 	cN88QTUX\Xabbbbb	c 	cr   )r0   r1   r2   r   r$   r3   r4   s   @r   r6   r6   4   sN        4 4 4 4 4c c c c c c cr   r6   N)
quant_utilsr   r   r   base_operatorr   qdq_base_operatorr   r
   r6    r   r   <module>rC      s    V V V V V V V V V V , , , , , , . . . . . .
'* '* '* '* '*# '* '* '*Tc c c c c c c c c cr   