o
    °ƒðjë
  ã                   @   sJ   d dl Z d dlmZ d dlmZ d dlmZ e  e¡Z	G dd„ deƒZ
dS )é    N)ÚFusion)Úhelper)Ú	OnnxModelc                       s*   e Zd Zdef‡ fdd„Zdd„ Z‡  ZS )ÚFusionQuickGeluÚmodelc                    s   t ƒ  |ddg¡ d S )NÚ	QuickGeluÚMul)ÚsuperÚ__init__)Úselfr   ©Ú	__class__© ú«/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/onnxruntime/transformers/fusion_quickgelu.pyr
      s   zFusionQuickGelu.__init__c           
      C   sT  |j dkrt d¡ d S |}|jd }| j |dgdg¡}|d u r(t d¡ d S |d }| j |dgdg¡}|d u rAt d¡ d S |d }| j |jd ¡ ¡ }t|d ƒd	kr_t d
¡ d S |jd |krmt d¡ d S t	j
d|g|jd g| j d¡d�}	d|	_|	j t	 d|¡g¡ | j |||g¡ | j |	¡ | j| j|	j< |  d¡ d S )Nr   z/fuse_quickgelu: failed to match second Mul noder   ÚSigmoidé   z,fuse_quickgelu: failed to match Sigmoid nodez.fuse_quickgelu: failed to match first Mul nodeg     <û?gü©ñÒMbP?z3fuse_quickgelu: failed to match approximation valuezFfuse_quickgelu: failed to match root input with first Mul node's inputr   )ÚinputsÚoutputsÚnamezcom.microsoftÚalpha)Úop_typeÚloggerÚdebugÚinputr   Úmatch_parent_pathÚget_constant_valueÚitemÚabsr   Ú	make_nodeÚoutputÚcreate_node_nameÚdomainÚ	attributeÚextendÚmake_attributeÚnodes_to_removeÚnodes_to_addÚappendÚthis_graph_nameÚnode_name_to_graph_namer   Úincrease_counter)
r   ÚnodeÚinput_name_to_nodesÚoutput_name_to_nodeÚsecond_mul_nodeÚ
root_inputÚsigmoid_nodeÚfirst_mul_nodeÚapproximation_valueÚnew_noder   r   r   Úfuse   sD   








üzFusionQuickGelu.fuse)Ú__name__Ú
__module__Ú__qualname__r   r
   r4   Ú__classcell__r   r   r   r   r      s    r   )ÚloggingÚfusion_baser   Úonnxr   Ú
onnx_modelr   Ú	getLoggerr5   r   r   r   r   r   r   Ú<module>   s   
