Ë
    cQêjÄ  ã                   óf   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  ee
«      Z G d„ de«      Zy)	é    )Ú	getLogger)ÚFusion)ÚFusionUtils)Úhelper)Ú	OnnxModelc                   ó4   ‡ — e Zd Zdefˆ fd„Zdedefd„Zˆ xZS )ÚFusionQOrderedGeluÚmodelc                 ó,   •— t         ‰| �  |dddg«       y )NÚQOrderedGeluÚGeluÚFastGelu)ÚsuperÚ__init__)Úselfr
   Ú	__class__s     €úr/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/onnxruntime/transformers/fusion_qordered_gelu.pyr   zFusionQOrderedGelu.__init__   s   ø€ Ü‰Ñ˜ °¸Ð0DÕEó    Úinput_name_to_nodesÚoutput_name_to_nodec           	      ó®  — | j                   j                  ||«      }t        |«      dk(  r|d   j                  dk(  s3t        |«      dk(  r$|d   j                  dk(  r|d   j                  dk(  sy|d   }d}t        |«      dk(  r|d   }t	        j
                  || j                   «      sy| j                   j                  |dgdgfg|«      \  }}}	|dk  ry|d   }
t	        j
                  |
| j                   «      sy|g}|j                  ||
g«       | j                   j                  ||�|j                  d   |j                  d   gn|j                  ||«      st        j                  d«       y| j                  j                  |«       t        j                  d	|
j                  d   |
j                  d   |j                  d   g|j                  d   g| j                   j!                  d	d	¬
«      ¬«      }|�7| j                   j#                  ||j                  d   |j                  d   «       |j$                  j                  t        j&                  dd«      g«       |j$                  j                  t        j&                  dd«      g«       d|_        | j*                  j-                  |«       | j.                  | j0                  |j2                  <   y)a  
        INPUT PATTERN
        Fuse (quantized) Gelu subgraph into one node QOrderedGelu:
            -> quantized input  -> DQ -> Gelu -> Q ->

        (or)

            -> quantized input  -> DQ -> FastGelu -> Q ->

        OUTPUT PATTERN
            -> QOrderedGelu ->
        é   r   ÚQuantizeLinearé   ÚShapeNÚDequantizeLinearz.It is not safe to fuse QOrderedGelu node. Skipr   )Úname_prefix)ÚinputsÚoutputsÚnameÚorder_XÚorder_Yzcom.microsoft)r
   Úget_childrenÚlenÚop_typer   Úcheck_qdq_node_for_fusionÚmatch_parent_pathsÚextendÚis_safe_to_fuse_nodesÚoutputÚloggerÚdebugÚnodes_to_remover   Ú	make_nodeÚinputÚcreate_node_nameÚreplace_node_inputÚ	attributeÚmake_attributeÚdomainÚnodes_to_addÚappendÚthis_graph_nameÚnode_name_to_graph_namer    )r   Únoder   r   Úgelu_childrenÚdownstream_quantize_nodeÚdownstream_shape_nodeÚfirst_path_idÚfirst_input_parent_nodesÚ_Úupstream_dequantize_nodeÚsubgraph_nodesÚordered_gelu_nodes                r   ÚfusezFusionQOrderedGelu.fuse   sÕ  € ð Ÿ
™
×/Ñ/°Ð6IÓJˆô
 �Ó 1Ò$¨°qÑ)9×)AÑ)AÐEUÒ)Uä�MÓ" aÒ'Ø! !Ñ$×,Ñ,Ð0@Ò@Ø! !Ñ$×,Ñ,°Ò7ð à#0°Ñ#3Ð Ø $Ðäˆ}Ó Ò"Ø$1°!Ñ$4Ð!ä×4Ñ4Ð5MÈtÏzÉzÔZØð 6:·Z±Z×5RÑ5RØØ!Ð" Q CÐ(Ð)Øó6
Ñ2ˆÐ/°ð ˜1ÒØà#;¸AÑ#>Ð ä×4Ñ4Ð5MÈtÏzÉzÔZØð ˜ˆØ×ÑÐ7Ð9QÐRÔSà�z‰z×/Ñ/Øð )Ð4ð —‘˜Q‘Ð!9×!@Ñ!@ÀÑ!CÑDà-×4Ñ4àØô	
ô �L‰LÐIÔJØà×Ñ×#Ñ# NÔ3ä"×,Ñ,Øà(×.Ñ.¨qÑ1Ø(×.Ñ.¨qÑ1Ø(×.Ñ.¨qÑ1ðð
 .×4Ñ4°QÑ7Ð8Ø—‘×,Ñ,¨^ÈÐ,ÓXô	
Ðð !Ð,Ø�J‰J×)Ñ)Ø%Ð'<×'BÑ'BÀ1Ñ'EÐG_×GfÑGfÐghÑGiôð 	×#Ñ#×*Ñ*¬F×,AÑ,AÀ)ÈQÓ,OÐ+PÔQØ×#Ñ#×*Ñ*¬F×,AÑ,AÀ)ÈQÓ,OÐ+PÔQà#2ÐÔ à×Ñ× Ñ Ð!2Ô3Ø?C×?SÑ?Sˆ×$Ñ$Ð%6×%;Ñ%;Ò<r   )Ú__name__Ú
__module__Ú__qualname__r   r   ÚdictrC   Ú__classcell__)r   s   @r   r	   r	      s*   ø„ ðF˜iõ FðbT¨dð bTÈ÷ bTr   r	   N)Úloggingr   Úfusion_baser   Úfusion_utilsr   Úonnxr   Ú
onnx_modelr   rD   r+   r	   © r   r   ú<module>rO      s0   ðõ å Ý $Ý Ý  á	�8Ó	€ôfT˜õ fTr   