o
    ;Î®c  ã                   @   s`   d dl Z ddlmZmZ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é   )ÚTENSOR_NAME_QUANT_SUFFIXÚQuantizedValueÚQuantizedValueTypeÚattribute_to_kwargÚ	ms_domainé   )ÚQuantOperatorBase)ÚQDQOperatorBasec                       ó   e Zd Z‡ fdd„Z‡  ZS )ÚQLinearSoftmaxc                    sP  | j }| jjtjjjkrd}d}nd}d}| j |jd ||¡\}}}}}| j 	|dg¡\}}	}
}|r7|d u r<t
ƒ  ¡ S |jd t }t|jd |||tjƒ}|| jj|jd < i }|jD ]	}| t|ƒ¡ q]t|d< | jj|d< |jdkr{|jd nd}tjjd|j |d |
d |	d ||g|g|fi |¤Ž}| |¡ | j j|7  _d S )	Nç      p?r   é€ÿÿÿÚdomainÚopsetÚ Ú_quantÚQLinear)ÚnodeÚ	quantizerÚactivation_qTypeÚonnxÚonnx_pbÚTensorProtoÚUINT8Ú_get_quantization_paramsÚoutputÚquantize_activationÚsuperÚquantizer   r   r   ÚInputÚquantized_value_mapÚ	attributeÚupdater   r   Úopset_versionÚnameÚhelperÚ	make_nodeÚop_typeÚappendÚ	new_nodes)Úselfr   Ú	out_scaleÚout_zero_pointÚ
data_foundÚoutput_scale_nameÚoutput_zp_nameÚ_Úquantized_input_namesÚinput_zero_point_namesÚinput_scale_namesÚnodesÚqlinear_output_nameÚquantized_output_valueÚkwargsr"   Úqlinear_node_nameÚqnode©Ú	__class__© úQ/tmp/pip-target-vg8gfxp4/lib/python/onnxruntime/quantization/operators/softmax.pyr   	   sh   ú	û
û
ûöõ
zQLinearSoftmax.quantize©Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__r=   r=   r;   r>   r      ó    r   c                       r   )Ú
QDQSoftmaxc                    sL   t ƒ  ¡  | jjtjjjkrd}d}nd}d}| j | j	j
d ||f¡ d S )Nr   r   r   )r   r   r   r   r   r   r   r   Úset_quant_scale_zpr   r   )r+   r,   r-   r;   r=   r>   r   N   s   
zQDQSoftmax.quantizer?   r=   r=   r;   r>   rE   M   rD   rE   )r   Úquant_utilsr   r   r   r   r   Úbase_operatorr	   Úqdq_base_operatorr
   r   rE   r=   r=   r=   r>   Ú<module>   s    E