+
    9i"                     ~    ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ]! ]
4      t ! R R]4      t ! R R	]4      tR
# )    )	getLogger)Fusion)NumpyHelper)helper	OnnxModelc                   L   a a ] tR t^t oRtRV3R lV 3R llltR tRtVtV ;t	# )FusionSkipLayerNormalizationz
Fuse Add + LayerNormalization into one node: SkipLayerNormalization
Note: This fusion does not check the input shape of Add and LayerNormalization.
c                2   < V ^8  d   QhRS[ RS[RS[RS[/# )   modelfused_op_typesearch_op_typesshape_infer)r   strbool)format__classdict__s   "k/var/www/html/photoedit/myenv/lib/python3.14/site-packages/onnxruntime/transformers/fusion_skiplayernorm.py__annotate__)FusionSkipLayerNormalization.__annotate__   s9     O OO O 	O
 O    c                   < \         SV `  WV4       V'       dN   V P                  P                  R ^R^/RR7      V n        V P                  f   \
        P                  R4       R# R# R# )
batch_sizeseq_lenT)updateNz,symbolic shape inference disabled or failed.)super__init__r   infer_runtime_shapeshape_infer_helperloggerwarning)selfr   r   r   r   	__class__s   &&&&&r   r   %FusionSkipLayerNormalization.__init__   sc     	?&*jj&D&DlTUW`bcEdmq&D&rD#&&.MN / r   c           
     l
   V P                   P                  V^ V4      pVe   VP                  R8w  d   R# \        VP                  4      ^8w  d   R# VP                   F#  pV P                   P                  V4      f   K"   R# 	  W@P                  9   d   R# VP                  R8H  p\        V R4      '       Ed<   V P                  Ee   V P                  P                  VP                  ^ ,          4      '       dd   \        V P                  P                  VP                  ^ ,          4      4      ^8w  d*   \        P                  RVP                  ^ ,          4       R# V P                  P                  VP                  ^ ,          VP                  ^,          4      '       g<   \        P                  RVP                  ^ ,          VP                  ^,          4       R# M\        P                  R4       R# V P                   P                  VR.R.4      pVe`   V P                   P                  V^ ,          P                  ^,          4      f+   V P                   P                  V^ ,          R	.^.4      f   R# V P                   P                  VP                   ^ ,          4      RJpT;'       g(    \        V P                   P#                  WB4      4      ^8  p	VP                   p
V	'       d$   V
P%                  VP                   ^ ,          .4       VP                   ^ ,          .pV	'       d&   VP%                  R
R
VP                   ^ ,          .4       V P                   P'                  WA.WV4      '       Ed   V P                  P%                  WA.4       V'       gK   VP                  ^ ,          VP                  ^,          VP                  ^,          VP                  ^,          .M7VP                  ^ ,          VP                  ^,          VP                  ^,          .p\(        P*                  ! V P,                  VVV P                   P/                  V P,                  RR7      R7      pRVn        VP2                   F2  pVP4                  R8X  g   K  VP2                  P%                  V.4       K4  	  \        VP2                  4      ^ 8X  d2   VP2                  P%                  \(        P6                  ! RR4      .4       V P8                  P;                  V4       V P<                  V P>                  VP4                  &   R# R# )r   NAddSimplifiedLayerNormalizationr    zDskip SkipLayerNormalization fusion since shape of input %s is not 3DzNskip SkipLayerNormalization fusion since shape of inputs (%s, %s) are not samezHskip SkipLayerNormalization fusion since symbolic shape inference failedGatherConstantOfShape SkipLayerNorm)name_prefixinputsoutputsnamecom.microsoftepsilon-q=) r   
get_parentop_typeleninputget_initializernodes_to_removehasattrr    get_edge_shaper!   debugcompare_shapematch_parent_pathfind_graph_inputfind_graph_outputoutputget_childrenextendis_safe_to_fuse_nodesr   	make_noder   create_node_namedomain	attributer1   make_attributenodes_to_addappendthis_graph_namenode_name_to_graph_name)r#   nodeinput_name_to_nodesoutput_name_to_nodeadd	add_input
simplifiedgather_pathadd_has_graph_output#residual_add_has_multiple_consumersoutputs_to_keepr0   r/   normalize_nodeatts   &&&&           r   fuse!FusionSkipLayerNormalization.fuse%   s   jj##D!-@A ;#++. syy>QIzz)))4@ #
 &&& \\%CC
4-..&&2++::399Q<HHD33BB399Q<PQUVVLL!gilirirstiuv ..<<SYYq\399UV<XXLLh		!		!
  Y ghjj223
TFK"tzz'B'B;q>CWCWXYCZ'['czz++KN=N<ORSQTU]  $zz;;CJJqMJRVV ^^C

(?(?(Y$Z]^$^ 	, ++.""CJJqM?3;;q>" /NNBCJJqM23::++SK_rss  ''4 " 1syy|TZZ]DJJqMJiilCIIaL$**Q-@ 
 $--""ZZ001C1CQ`0a	N %4N! ~~88y(",,33SE: &
 >++,1((//1F1FyRY1Z0[\$$^4@D@T@TD(()<)<=5 tr   )r    )SkipLayerNormalizationLayerNormalizationT)
__name__
__module____qualname____firstlineno____doc__r   r[   __static_attributes____classdictcell____classcell__r$   r   s   @@r   r
   r
      s$     
O O_U _Ur   r
   c                   D   a a ] tR t^t oV3R lV 3R lltR tRtVtV ;t# ) FusionBiasSkipLayerNormalizationc                    < V ^8  d   QhRS[ /# )r   r   r   )r   r   s   "r   r   -FusionBiasSkipLayerNormalization.__annotate__   s     ` `i `r   c                ,   < \         SV `  VR R R4       R# )r]   zadd biasN)r   r   )r#   r   r$   s   &&r   r   )FusionBiasSkipLayerNormalization.__init__   s     8:RT^_r   c           	     D   \        VP                  4      ^8w  d   R# . pV P                  P                  VRR.RR.W44      pVe   Vw  rgM0. pV P                  P                  V. RO. ROW44      pVe   Vw  rhpMR# \        V4      ^8X  g   \        V4      ^8X  g   Q hV^ ,          p	V	^8  d   R# VP                  V^,          ,          p
VP                  ^V^,          ,
          ,          pVP                  ^V	,
          ,          pV P                  P	                  V4      pVf   R# \
        P                  ! V4      pVf   \        P                  R4       R# \        VP                  4      ^8w  d   \        P                  R4       R# W.pV P                  P                  WP                  W#4      '       g   \        P                  R4       R# V P                  P                  V4       V
VVP                  ^,          VP                  ^,          V.p\        P                  ! RVVP                  V P                  P!                  RR4      R	7      pR
Vn        VP$                   F2  pVP&                  R8X  g   K  VP$                  P                  V.4       K4  	  \        VP$                  4      ^ 8X  d2   VP$                  P                  \        P(                  ! RR4      .4       V P*                  P-                  V4       V P.                  V P0                  VP&                  &   R# )   Nr'   MatMulzBias weight not foundzBias weight is not 1DzASkip fusing SkipLayerNormalization with Bias since it is not safer]   SkipLayerNorm_AddBias_r.   r2   r3   r4   )r'   Castrp   )NNN)r7   r8   r   r?   r9   r   to_arrayr!   r=   shaperE   rB   r:   rD   r   rF   rG   rH   rI   r1   rJ   rK   rL   rM   rN   )r#   rO   rP   rQ   return_indicenodesrR   _matmul_castadd_input_index	sln_input
bias_input
skip_inputinitializerbias_weightsubgraph_nodesr/   new_noderZ   s   &&&&               r   r[   %FusionBiasSkipLayerNormalization.fuse   s   tzz?a

,,TE83DtTlTgw"NS' MJJ00/1CEXE  (-%W=!Q&#m*<*AAA'*aIImA./	YYq=#334
ZZO 34
 jj00<!**;7LL01{  !Q&LL01zz//M`vvLL\]##N3JJqMJJqM
 ##$KK,,-EG_`	
 * >>Cxx9$""))3%0 "
 x!!"a'%%v'<'<Y'P&QR  *6:6J6J$$X]]3r    )	r_   r`   ra   rb   r   r[   rd   re   rf   rg   s   @@r   ri   ri      s     ` `FK FKr   ri   N)loggingr   fusion_baser   fusion_utilsr   onnxr   
onnx_modelr   r_   r!   r
   ri   r   r   r   <module>r      sA      $   	8	tU6 tUnJKv JKr   