U
    U?hD  ã                   @   s   G d d„ dƒZ dS )c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚQuantOperatorBasec                 C   s   || _ || _d S )N)Ú	quantizerÚnode)ÚselfZonnx_quantizerZ	onnx_node© r   úb/var/www/html/venv/lib/python3.8/site-packages/onnxruntime/quantization/operators/base_operator.pyÚ__init__   s    zQuantOperatorBase.__init__c                 C   s&   | j  | j¡sdS | j  | jjd ¡S )NFé    )r   Zshould_quantize_noder   Zis_float_tensorÚinput)r   r   r   r   Úshould_quantize   s    z!QuantOperatorBase.should_quantizec                 C   sL   t | jjƒD ]*\}}| j |¡}|dk	r| jj |¡ q| jj | j¡ dS )a‡  
        Given a node which does not support quantization, this method checks whether the input to
        this node is quantized and adds a DequantizeLinear node to dequantize this input back to FP32
            parameter node: Current node
            parameter new_nodes_list: List of new nodes created before processing current node
            return: List of new nodes created
        N)Ú	enumerater   r	   r   Z_dequantize_valueZ	new_nodesÚappend)r   Ú_Z
node_inputZdequantize_noder   r   r   Úquantize   s
    zQuantOperatorBase.quantizeN)Ú__name__Ú
__module__Ú__qualname__r   r
   r   r   r   r   r   r      s   r   N)r   r   r   r   r   Ú<module>   ó    