+
    9i                     p    ^ RI Ht ^ RIHt ^ RIHt ^ RIHtHtH	t	 ^ RI
Ht ]! ]4      t ! R R]4      tR# )	    )	getLogger)Fusion)NumpyHelper)	NodeProtoTensorProtohelper	OnnxModelc                   t   a a ] tR t^t oV3R lV 3R lltV3R lR ltV3R lR ltV3R lR ltR	tVt	V ;t
# )
FusionGemmFastGeluc                    < V ^8  d   QhRS[ /# )   modelr	   )format__classdict__s   "j/var/www/html/photoedit/myenv/lib/python3.14/site-packages/onnxruntime/transformers/fusion_gemmfastgelu.py__annotate__FusionGemmFastGelu.__annotate__   s     & &i &    c                H   < \         SV `  VR RR 4       RV n        RV n        R# )GemmFastGeluFastGeluNF)super__init__shape_infershape_infer_done)selfr   	__class__s   &&r   r   FusionGemmFastGelu.__init__   s&    
NK %r   c                4   < V ^8  d   QhRS[ RS[R,          /# )r   tensor_protoreturnN)r   int)r   r   s   "r   r   r      s       [ SSWZ r   c                    VP                   P                  P                  R 4      '       d4   \        VP                   P                  P                  P
                  4      # R# )shapeN)typetensor_typeHasFieldlenr%   dim)r   r!   s   &&r    get_dimensions_from_tensor_proto3FusionGemmFastGelu.get_dimensions_from_tensor_proto   sE    ((11'::|((44::>>??r   c                4   < V ^8  d   QhRS[ RS[R,          /# )r   
input_namer"   N)strr#   )r   r   s   "r   r   r      s       t r   c                V   V P                   P                  V4      pV'       d   V P                  V4      # V P                  '       g)   V P                   P	                  R R7      V n        R V n        V P
                  e-   V P                  V P
                  P                  V,          4      # R# )T)updateN)r   find_graph_inputr+   r   infer_runtime_shaper   	known_vi_)r   r.   graph_inputs   && r   get_dimensions!FusionGemmFastGelu.get_dimensions   s    jj11*=88EE$$$#zz==T=JD$(D!'889I9I9S9ST^9_``r   c                h   < V ^8  d   QhRS[ RS[S[S[S[ ,          3,          RS[S[S[ 3,          /# )r   nodeinput_name_to_nodesoutput_name_to_node)r   dictr/   list)r   r   s   "r   r   r   *   sJ     OM OMOM "#tI"67OM "#y.1	OMr   c                   Rp\        VP                  4      ^8X  d   RpV P                  P                  VR.^ .4      pVf   R# V^ ,          pRp^ pRp	\	        VP                  4       F`  w  rV P                  P                  V4      pVf%   V P                  VP                  V
,          4      pKH  T
p\        P                  ! V4      p	Kb  	  V	f   R# \        V	P                  4      ^8w  d   R# V\        V	P                  4      8  d   R# RpV'       d|   Rp\	        VP                  4       F>  w  rV P                  P                  V4      pVf   K&  T
p\        P                  ! V4      p M	  Vf   R# \        VP                  4      ^8w  d   R# W.pV P                  P                  WP                  ^ ,          .W#4      '       g   R# V P                  P                  V4       V'       d@   VP                  ^V,
          ,          VP                  V,          VP                  V,          .M,VP                  ^V,
          ,          VP                  V,          .p\        P                  ! RVVP                  V P                  P!                  R4      R7      pRVn        V P$                  P'                  V4       V P(                  V P*                  VP,                  &   R# )	z{
This pattern is from PyTorch bert model
Fuse MatMul with FastGelu into one node:

    [root] --> MatMul --> FastGelu -->

FTMatMulNr   )inputsoutputsnamezcom.microsoft)r)   inputr   match_parent_path	enumerateget_initializerr6   r   to_arrayr%   is_safe_to_fuse_nodesoutputnodes_to_removeextendr   	make_nodecreate_node_namedomainnodes_to_addappendthis_graph_namenode_name_to_graph_namerB   )r   r9   r:   r;   has_biasmatch_nodesmatmulweight_indexx_dimsweightirD   initializer
bias_indexbias_weightsubgraph_nodesr@   
fused_nodes   &&&&              r   fuseFusionGemmFastGelu.fuse*   sl    tzz?aHjj224(aSIQ !&,,/HA**44U;K",,V\\!_= $--k: 0 >v||!C%% 
K%djj1"jj88?&
)22;? 2 ";$$%*zz//[[^,.A
 
 ##N3  \\!l*+V\\,-GT^I_`,,q</0&,,|2LM 	 %%KK,,^<	

 ,
  ,8<8L8L$$Z__5r   )r   r   )__name__
__module____qualname____firstlineno__r   r+   r6   r`   __static_attributes____classdictcell____classcell__)r   r   s   @@r   r   r      s8     & &
  OM OM OMr   r   N)loggingr   fusion_baser   fusion_utilsr   onnxr   r   r   
onnx_modelr
   rb   loggerr    r   r   <module>rp      s3      $ / /  	8	iM iMr   