U
    U?h                     @   sX   d dl Z ddlmZmZmZ ddlmZ ddlmZ G dd deZ	G d	d
 d
eZ
dS )    N   )QuantizedValueQuantizedValueTypeattribute_to_kwarg   )QuantOperatorBase)QDQOperatorBasec                       s(   e Zd Z fddZ fddZ  ZS )QSplitc                    s   t  || d S )N)super__init__)selfZonnx_quantizerZ	onnx_node	__class__ Z/var/www/html/venv/lib/python3.8/site-packages/onnxruntime/quantization/operators/split.pyr   	   s    zQSplit.__init__c                    s  | j }| j|dg\}}}}|d kr0t  S d}|jrD|jd }i }|jD ]}|t| qNg }	|j	D ]<}
|
d }|	
| t|
||d |d tj}|| jj|
< qlt|jdkr||jdd   tjj|j||	|f|}|
| | j j|7  _d S )Nr    Z_quantZ	quantizedr   )node	quantizerZquantize_activationr
   quantizename	attributeupdater   outputappendr   r   ZInputZquantized_value_mapleninputextendonnxhelperZ	make_nodeop_typeZ	new_nodes)r   r   Zquantized_input_namesZzero_point_namesZscale_namesZnodesZquantized_node_namekwargsr   Zquantized_output_namesZoutput_nameZquantized_output_nameZq_outputZquantized_noder   r   r   r      sN    




   
zQSplit.quantize)__name__
__module____qualname__r   r   __classcell__r   r   r   r   r	      s   r	   c                   @   s   e Zd Zdd ZdS )QDQSplitc                 C   sf   | j }|jdkst| j|jd s8| j|jd  | jsb|jD ]}| j	||jd |j
 qDd S )NZSplitr   )r   r   AssertionErrorr   Zis_tensor_quantizedr   Zquantize_activation_tensorZdisable_qdq_for_node_outputr   Zquantize_output_same_as_inputr   )r   r   r   r   r   r   r   7   s    
zQDQSplit.quantizeN)r!   r"   r#   r   r   r   r   r   r%   6   s   r%   )r   Zquant_utilsr   r   r   Zbase_operatorr   Zqdq_base_operatorr   r	   r%   r   r   r   r   <module>   s
   .