+
    9i                         ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ] P                  ! ]4      t ! R R]4      tR# )	    N)FusionGptAttention)FusionGptAttentionMegatron)FusionGptAttentionNoPast)FusionRotaryAttention)BertOnnxModelc                   >   a a ] tR t^t oV 3R ltR tR tRtVtV ;t	# )Gpt2OnnxModelc                (   < \         SV `  WV4       R # )N)super__init__)selfmodel	num_headshidden_size	__class__s   &&&&f/var/www/html/photoedit/myenv/lib/python3.14/site-packages/onnxruntime/transformers/onnx_model_gpt2.pyr   Gpt2OnnxModel.__init__   s    ;7    c                   \        V P                  P                  P                  4      ^8X  g/   \        V P                  P                  P                  4      ^8X  d'   \        W P                  4      pVP                  4        MJ\        W P                  4      pVP                  4        \        W P                  4      pVP                  4        \        W P                  V P                  4      pVP                  4        R# )   N)lenr   graphinputoutputr   r   applyr   r   r   r   )r   fusions   & r   fuse_attentionGpt2OnnxModel.fuse_attention   s    tzz%%&!+s4::3C3C3J3J/Kq/P-dNNCFLLN'nn=FLLN/nnEFLLN&t-=-=t~~Nr   c                   \         P                  R4       V P                  4       pV P                  4       p^ pV P	                  R4       EF  pV P                  VRVRR7      pV P                  VRR.^ ^ .V4      pVf;   V P                  VRR.^ ^ .V4      pVf   V P                  VRR	.^ ^ .V4      pVf   Ko  Vw  rxV P                  R
R4      p	\        P                  P                  R
V	R,           VP                  ^,          .V	R,           .V	R7      p
V P                  RR4      p\        P                  P                  RV	R,           VP                  ^,          .VR,           .VR7      pV P                  VP                  ^ ,          VR,           4       V P                  VP                  ^ ,          V	R,           4       V	R,           VP                  ^ &   V P                  VP                  ^ ,          VR,           4       V P                  V
4       V P                  V4       V^,          pEK  	  V P                  4        \         P!                  RV 24       R# )z
Remove extra reshape nodes.
zstart postprocessing...GemmReshapeF)	recursiveFastGeluNLayerNormalizationSkipLayerNormalizationMatMulFullyConnect_MatMul_input_output)inputsoutputsnameAddFullyConnect_Addz#postprocess: remove Reshape count: )loggerdebuginput_name_to_nodesoutput_name_to_nodeget_nodes_by_op_typefind_first_child_by_typematch_parent_pathcreate_node_nameonnxhelper	make_noder   replace_input_of_all_nodesr   add_nodeprune_graphinfo)r   r1   r2   reshape_count	gemm_nodereshape_after_gemmnodesreshape_before_gemm	root_nodematmul_node_namematmul_nodeadd_node_namer;   s   &            r   postprocessGpt2OnnxModel.postprocess"   sf    	./"668"668226:I!%!>!>9&9U "? " **9y*6MPQSTvWjkE}.. 45F'	 = 22!"$<=A+	E } /4, #44X?TU++//(83Y__Q5GH)I56%	 0 K !11%9KLM{{,,(94iooa6HI&23"	 - H ++,>,E,Ea,H-ZcJcd ++I,<,<Q,?AQT\A\]"2X"=IQ++,>,E,Ea,H-ZcJcdMM+&MM(#QMm ;p 	9-IJr    )
__name__
__module____qualname____firstlineno__r   r   rG   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r	   r	      s     8CK CKr   r	   )loggingr7   fusion_gpt_attentionr   fusion_gpt_attention_megatronr   fusion_gpt_attention_no_pastr   fusion_rotary_attentionr   onnx_model_bertr   	getLoggerrJ   r/   r	   rI   r   r   <module>rY      s<   
   3 D A 9 )			8	$TKM TKr   