
    h
                     j    S SK r S SKJr  S SKJr  S SKJr  \ R                  " \5      r	 " S S\5      r
g)    N)Fusion)helper)	OnnxModelc                   6   ^  \ rS rSrS\4U 4S jjrS rSrU =r$ )FusionQuickGelu   modelc                 *   > [         TU ]  USS/5        g )N	QuickGeluMul)super__init__)selfr	   	__class__s     c/var/www/fran/franai/venv/lib/python3.13/site-packages/onnxruntime/transformers/fusion_quickgelu.pyr   FusionQuickGelu.__init__   s    eW5    c                 :   UR                   S:w  a  [        R                  S5        g UnUR                  S   nU R                  R                  US/S/5      nUc  [        R                  S5        g US   nU R                  R                  US/S/5      nUc  [        R                  S5        g US   nU R                  R                  UR                  S   5      R                  5       n[        US-
  5      S	:  a  [        R                  S
5        g UR                  S   U:w  a  [        R                  S5        g [        R                  " SU/UR                  S   /U R                  R                  S5      S9n	SU	l        U	R                  R                  [        R                   " SU5      /5        U R"                  R                  XvU/5        U R$                  R'                  U	5        U R(                  U R*                  U	R,                  '   U R/                  S5        g )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   fuse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____firstlineno__r   r   r9   __static_attributes____classcell__)r   s   @r   r   r      s    6i 67+ 7+r   r   )loggingfusion_baser   onnxr   
onnx_modelr   	getLoggerr<   r   r   r;   r   r   <module>rG      s/        			8	$;+f ;+r   