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