
     Ng
                     n    d dl Z d dlmZ d dlmZ d dlmZ  e j        e          Z	 G d de          Z
dS )    N)Fusion)helper)	OnnxModelc                   *     e Zd Zdef fdZd Z xZS )FusionQuickGelumodelc                 P    t                                          |ddg           d S )N	QuickGeluMul)super__init__)selfr   	__class__s     e/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnxruntime/transformers/fusion_quickgelu.pyr   zFusionQuickGelu.__init__   s'    eW55555    c                 R   |j         dk    rt                              d           d S |}|j        d         }| j                            |dgdg          }|t                              d           d S |d         }| j                            |dgdg          }|t                              d           d S |d         }| j                            |j        d                                                   }t          |dz
            d	k    rt                              d
           d S |j        d         |k    rt                              d           d S t          j
        d|g|j        d         g| j                            d                    }	d|	_        |	j                            t          j        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     <?gMbP?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_nodes
             r   fusezFusionQuickGelu.fuse   s    <5  LLJKKKF$*1-
z33Oi[STRUVVLLGHHHF#A55lUGaSQQ!LLIJJJF'*"j;;N<PQR<STTYY[["\122d::LLNOOOF"j00LLabbbF#<$+A./,,[99	
 
 
 *!!6#8BU#V#V"WXXX##^\?$STTT  ***6:6J$X]3k*****r   )__name__
__module____qualname__r   r   r7   __classcell__)r   s   @r   r   r      sS        6i 6 6 6 6 6 67+ 7+ 7+ 7+ 7+ 7+ 7+r   r   )loggingfusion_baser   onnxr   
onnx_modelr   	getLoggerr8   r   r    r   r   <module>rB      s                            		8	$	$;+ ;+ ;+ ;+ ;+f ;+ ;+ ;+ ;+ ;+r   