
    SiQ                    Z    S SK Jr  S SKrS SKrS SKJr  S SKJr  S SK	J
r
   " S S\5      rg)    )annotationsN)Base)expect)_compute_attentionc                     \ rS rSr\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r	\SBS j5       r
\SBS j5       r\SBS	 j5       r\SBS
 j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r\SBS j5       r \SBS j5       r!\SBS j5       r"\SBS  j5       r#\SBS! j5       r$\SBS" j5       r%\SBS# j5       r&\SBS$ j5       r'\SBS% j5       r(\SBS& j5       r)\SBS' j5       r*\SBS( j5       r+\SBS) j5       r,\SBS* j5       r-\SBS+ j5       r.\SBS, j5       r/\SBS- j5       r0\SBS. j5       r1\SBS/ j5       r2\SBS0 j5       r3\SBS1 j5       r4\SBS2 j5       r5\SBS3 j5       r6\SBS4 j5       r7\SBS5 j5       r8\SBS6 j5       r9\SBS7 j5       r:\SBS8 j5       r;\SBS9 j5       r<\SBS: j5       r=\SBS; j5       r>\SBS< j5       r?\SBS= j5       r@\SBS> j5       rA\SBS? j5       rBS@rCgA)C	Attention   c            
     B   [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        XU5      u  n    n[        U XU/U/S
[         R                  R                  SS5      /S9  g )Nr   QKVYinputsoutputs               test_attention_4d    r   r   nameopset_importsonnxhelper	make_nodenprandomrandastypefloat32r   r   make_opsetidnoder   r   r   r   _s         d/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/backend/test/case/node/attention.pyexport_attentionAttention.export_attention   s    {{$$[SVRW$XIINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a0
1a!9C$;;33B;<	
    c            
     B   [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        XU5      u  n    n[        U XU/U/S
[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   test_attention_4d_fp16r   r   r   r   r    r!   r"   r#   r$   r%   float16r   r   r'   r(   s         r+   export_attention_fp16Attention.export_attention_fp16!   s    {{$$[SVRW$XIINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a0
1a!9C);;33B;<	
r.   c            
     B   [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SS	S
S5      R                  [        R                  5      n[        R                  R                  SS	S
S5      R                  [        R                  5      n[        XU5      u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   	   r   r   r   r   test_attention_4d_gqar   r   r   r   r(   s         r+   export_attention_gqaAttention.export_attention_gqa3   s    {{$$[SVRW$XIINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a0
1a!9C(;;33B;<	
r.   c            
     B   [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S
5      R                  [        R                  5      n[        XU5      u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   
   "test_attention_4d_diff_heads_sizesr   r   r   r   r(   s         r+    export_attention_diff_head_sizes*Attention.export_attention_diff_head_sizesE   s    {{$$[SVRW$XIINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:'a0
1a!9C5;;33B;<	
r.   c            
     D   Sn [         R                  R                  S/ SQS/U S9n[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        X#X@S9u  n    n[        UX#U/U/S[         R                  R                  SS5      /S9  g )N{Gz?r   r   r   r   r   scaler   r   r   r   r   rB   test_attention_4d_scaledr   r   r   r   rB   r)   r   r   r   r   r*   s          r+   export_attention_scaled!Attention.export_attention_scaledW   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a=
1a!9C+;;33B;<	
r.   c            
     D   Sn [         R                  R                  S/ SQS/U S9n[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        X#X@S9u  n    n[        UX#U/U/S[         R                  R                  SS5      /S9  g )Nr@   r   r   r   rA   r   r6   r   r   r   r   rC   test_attention_4d_gqa_scaledr   r   r   r   rE   s          r+   export_attention_gqa_scaled%Attention.export_attention_gqa_scaledo   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a=
1a!9C/;;33B;<	
r.   c            
     D   Sn [         R                  R                  S/ SQS/U S9n[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        X#X@S9u  n    n[        UX#U/U/S[         R                  R                  SS5      /S9  g )Nr@   r   r   r   rA   r   r   r   r   r   r;   rC   )test_attention_4d_diff_heads_sizes_scaledr   r   r   r   rE   s          r+   'export_attention_diff_head_sizes_scaled1Attention.export_attention_diff_head_sizes_scaled   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:'a=
1a!9C<;;33B;<	
r.   c            
     B   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        XUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r      r   r   	is_causalr   r   r   r   r   rS   test_attention_4d_causalr   r   r   r   r(   s         r+   export_attention_causal!Attention.export_attention_causal   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a1=
1a!9C+;;33B;<	
r.   c            
     B   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        XUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   rR   r   r6   r   r   r   r   rT   test_attention_4d_gqa_causalr   r   r   r   r(   s         r+   export_attention_gqa_causal%Attention.export_attention_gqa_causal   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a1=
1a!9C/;;33B;<	
r.   c            
     D   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        UUUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   rR   r   r   r   r   r   r;   rT   )test_attention_4d_diff_heads_sizes_causalr   r   r   r   r(   s         r+   'export_attention_diff_head_sizes_causal1Attention.export_attention_diff_head_sizes_causal   s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:'	

1a 	!9C<;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUS
9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   	attn_maskr   r   r   r   r   r   r   rb   test_attention_4d_attn_maskr   r   r   r   r)   r   r   r   rb   r   r*   s          r+   export_attention_attn_mask$Attention.export_attention_attn_mask   s   {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//

;	'	

1a 	!'C.;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        UUUUS9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   rQ   rc   test_attention_4d_attn_mask_3dr   r   r   r   re   s          r+   export_attention_attn_3d_mask'Attention.export_attention_attn_3d_mask     {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA.55bjjA	'	

1a 	!'C1;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        UUUUSS9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   rQ   rR   r   r   r   r   r   rb   rS   %test_attention_4d_attn_mask_3d_causalr   r   r   r   re   s          r+   $export_attention_attn_3d_mask_causal.Attention.export_attention_attn_3d_mask_causal!     {{$$/E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA.55bjjA	'

1a 	!'C8;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSSS	5      R                  [        R                  5      n[        UUUUS
9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   rc   test_attention_4d_attn_mask_4dr   r   r   r   re   s          r+   export_attention_attn_4d_mask'Attention.export_attention_attn_4d_mask?  rl   r.   c            
        [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        UUUUSS9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   rQ   rR   r   r   r   r   r   rn   %test_attention_4d_attn_mask_4d_causalr   r   r   r   re   s          r+   $export_attention_attn_4d_mask_causal.Attention.export_attention_attn_4d_mask_causal[  rr   r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        5      n[        UUUUS
9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   rc    test_attention_4d_attn_mask_boolr   r   r   r   r    r!   r"   r#   r$   r%   r&   boolr   r   r'   re   s          r+   export_attention_attn_mask_bool)Attention.export_attention_attn_mask_booly  s   {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//5	'	

1a 	!'C3;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSSS	5      R                  [        5      n[        UUUUS
9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   rc   #test_attention_4d_attn_mask_bool_4dr   r   r   r}   re   s          r+   "export_attention_attn_mask_bool_4d,Attention.export_attention_attn_mask_bool_4d  s   {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA.55d;	'	

1a 	!'C6;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SS	S
S5      R                  [        R                  5      n[        R                  R                  SS	S
S5      R                  [        R                  5      n[        R                  R                  SS
5      R                  [        R                  5      n[        UUUUS9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r6   r   r   r   r   rc   test_attention_4d_gqa_attn_maskr   r   r   r   re   s          r+   export_attention_gqa_attn_mask(Attention.export_attention_gqa_attn_mask  s   {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//

;	'	

1a 	!'C2;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUS9u  n    n[        U XX4/U/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   r;   rc   ,test_attention_4d_diff_heads_sizes_attn_maskr   r   r   r   re   s          r+   *export_attention_diff_head_sizes_attn_mask4Attention.export_attention_diff_head_sizes_attn_mask  s   {{$$/E % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:IINN1a(//

;	'	

1a 	!'C?;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   rb   past_key
past_valuer   present_keypresent_valuer      r   r   r   r   r   rb   r   r   'test_attention_4d_with_past_and_presentr   r   r   r   r)   past_sequence_lengthr   r   r   rb   r   r   r   r   r   r*   s               r+   &export_attention_with_past_and_present0Attention.export_attention_with_past_and_present  st   {{$$I9 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
+=!,
( 	!=]3:;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SSU-   5      R                  [        R                  5      n[        R                  R                  SS
US	5      R                  [        R                  5      n[        R                  R                  SS
US	5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r6   r   r   r   r   r   +test_attention_4d_gqa_with_past_and_presentr   r   r   r   r   s               r+   *export_attention_gqa_with_past_and_present4Attention.export_attention_gqa_with_past_and_present
  st   {{$$I9 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
+=!,
( 	!=]3>;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SSU-   5      R                  [        R                  5      n[        R                  R                  SS
US	5      R                  [        R                  5      n[        R                  R                  SS
US	5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r6   r   r   r   r   r   0test_attention_4d_gqa_with_past_and_present_fp16r   r   r   r1   r   s               r+   /export_attention_gqa_with_past_and_present_fp169Attention.export_attention_gqa_with_past_and_present_fp16+  st   {{$$I9 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
+=!,
( 	!=]3C;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r;   r   2test_attention_4d_diff_heads_with_past_and_presentr   r   r   r   r   s               r+   6export_attention_diff_head_sizes_with_past_and_present@Attention.export_attention_diff_head_sizes_with_past_and_presentL  st   {{$$I9 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>CJJ2::V
+=!,
( 	!=]3E;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        R                  R                  SSSS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r;   rQ   r   9test_attention_4d_diff_heads_with_past_and_present_mask3dr   r   r   r   r   s               r+   =export_attention_diff_head_sizes_with_past_and_present_mask3DGAttention.export_attention_diff_head_sizes_with_past_and_present_mask3Dm  x   {{$$I9 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:IINN1aA0D,DELLRZZX	99>>!Q(<a@GG

SYY^^Aq*>CJJ2::V
+=!,
( 	!=]3L;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        R                  R                  SSSS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XU
/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r;   r   9test_attention_4d_diff_heads_with_past_and_present_mask4dr   r   r   r   r   s               r+   =export_attention_diff_head_sizes_with_past_and_present_mask4DGAttention.export_attention_diff_head_sizes_with_past_and_present_mask4D  r   r.   c            
     B   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        XUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r          @r   r   softcapr   r   r   r   r   r   test_attention_4d_softcapr   r   r   r   r(   s         r+   export_attention_softcap"Attention.export_attention_softcap  s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a=
1a!9C,;;33B;<	
r.   c            
     B   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        R                  R                  SS
SS	5      R                  [        R                  5      n[        XUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r6   r   r   r   r   r   test_attention_4d_gqa_softcapr   r   r   r   r(   s         r+   export_attention_gqa_softcap&Attention.export_attention_gqa_softcap  s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9'a=
1a!9C0;;33B;<	
r.   c            
     D   [         R                  R                  S/ SQS/SS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S5      R                  [        R                  5      n[        UUUSS9u  n    n[        U XU/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r;   r   *test_attention_4d_diff_heads_sizes_softcapr   r   r   r   r(   s         r+   (export_attention_diff_head_sizes_softcap2Attention.export_attention_diff_head_sizes_softcap  s    {{$$"E	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:'	

1a 	!9C=;;33B;<	
r.   c            
     B   [         R                  R                  S/ SQ/ SQS9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        XU5      u  n  pV[        U XU/XF/S
[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   qk_matmul_outputr   r   r   r   r   r    test_attention_4d_with_qk_matmulr   r   r   r   )r)   r   r   r   r   r*   r   s          r+   export_attention_with_qk_matmul)Attention.export_attention_with_qk_matmul  s    {{$$"5 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9$6qQ$?!1a!9)3;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SS
5      R                  [        R                  5      n[        UUUUSS9u  n  pg[        U XX4/XW/S[         R                  R                  SS5      /S9  g )Nr   ra   r   rQ   r   r   qk_matmul_output_moder   r   r   r   r   rb   r   %test_attention_4d_with_qk_matmul_biasr   r   r   r   r)   r   r   r   rb   r   r*   r   s           r+   $export_attention_with_qk_matmul_bias.Attention.export_attention_with_qk_matmul_bias  s   {{$$/5"#	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//

;	$6"#%
!1a 	!')8;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSSS9n [        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SS
5      R                  [        R                  5      n[        UUUUSSS9u  n  pg[        U XX4/XW/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   )r   r   r   r   r   r   r   r   )rb   r   r   (test_attention_4d_with_qk_matmul_softcapr   r   r   r   r   s           r+   'export_attention_with_qk_matmul_softcap1Attention.export_attention_with_qk_matmul_softcap-  s   {{$$/5"# % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//

;	$6"#%
!1a 	!');;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSS9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUSS
9u  n  pg[        U XX4/XW/S[         R                  R                  SS5      /S9  g )Nr   ra   r   r   r   r   r   r   r   r   (test_attention_4d_with_qk_matmul_softmaxr   r   r   r   r   s           r+   'export_attention_with_qk_matmul_softmax1Attention.export_attention_with_qk_matmul_softmaxM  s   {{$$/5"#	 % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a(//

;	$6"#%
!1a 	!');;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSS9n Sn[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  S	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        UUUUUUSS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   rQ   r   r   r   r   r   r   r   rb   r   r   r   6test_attention_4d_with_past_and_present_qk_matmul_biasr   r   r   r   r)   r   r   r   r   rb   r   r   r   r   r   r   s               r+   5export_attention_with_past_and_present_qk_matmul_bias?Attention.export_attention_with_past_and_present_qk_matmul_biask  sz   {{$$IM"#	 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!"#;
7 	!=]EI;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSS9n Sn[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSS	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        UUUUUUSS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   r   r   r   r   r   r   r   r   >test_attention_4d_with_past_and_present_qk_matmul_bias_3d_maskr   r   r   r   r   s               r+   =export_attention_with_past_and_present_qk_matmul_bias_3d_maskGAttention.export_attention_with_past_and_present_qk_matmul_bias_3d_mask  ~   {{$$IM"#	 % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA0D,DELLRZZX	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!"#;
7 	!=]EQ;;33B;<	
r.   c            
        [         R                  R                  S/ SQ/ SQSS9n Sn[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSS	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        UUUUUUSS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   r   r   r   r   r   r   r   r   >test_attention_4d_with_past_and_present_qk_matmul_bias_4d_maskr   r   r   r   r   s               r+   =export_attention_with_past_and_present_qk_matmul_bias_4d_maskGAttention.export_attention_with_past_and_present_qk_matmul_bias_4d_mask  r   r.   c                    [         R                  R                  S/ SQ/ SQSSS9n Sn[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSS	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        UUUUUUSSS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   r   r   r   rS   r   r   r   r   r   r   rb   r   r   r   rS   Etest_attention_4d_with_past_and_present_qk_matmul_bias_3d_mask_causalr   r   r   r   r   s               r+   Dexport_attention_with_past_and_present_qk_matmul_bias_3d_mask_causalNAttention.export_attention_with_past_and_present_qk_matmul_bias_3d_mask_causal     {{$$IM"# % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA0D,DELLRZZX	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!"#	;
7 	!=]EX;;33B;<	
r.   c                    [         R                  R                  S/ SQ/ SQSSS9n Sn[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSSS
5      R                  [        R                  5      n[        R                  R                  SSS	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        R                  R                  SSUS
5      R                  [        R                  5      n[        UUUUUUSSS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   rQ   r   r   r   r   r   r   r   r   Etest_attention_4d_with_past_and_present_qk_matmul_bias_4d_mask_causalr   r   r   r   r   s               r+   Dexport_attention_with_past_and_present_qk_matmul_bias_4d_mask_causalNAttention.export_attention_with_past_and_present_qk_matmul_bias_4d_mask_causal  r   r.   c            
        [         R                  R                  S/ SQ/ SQS9n Sn[        R                  R                  SSSS	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SSS
S	5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        R                  R                  SSUS	5      R                  [        R                  5      n[        UUUUUUS9u  pp[        U X#XEXg/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r   1test_attention_4d_with_past_and_present_qk_matmulr   r   r   r   r   s               r+   0export_attention_with_past_and_present_qk_matmul:Attention.export_attention_with_past_and_present_qk_matmul  st   {{$$IM % 
  "IINN1aA&--bjj9IINN1aA&--bjj9IINN1aA&--bjj9IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!;
7 	!=]ED;;33B;<	
r.   c            
     J   Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        UUUU US
9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   q_num_headskv_num_headsr   r      r   r   r   test_attention_3dr   r   r   r   r   r   r)   r   r   r   r   r*   s           r+   export_attention_3dAttention.export_attention_3d?  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C$;;33B;<	
r.   c            
     J   Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        UUUU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr6   r   r   r   r   r   r   r   H   r   r   r   test_attention_3d_gqar   r   r   r   r   s           r+   export_attention_3d_gqa!Attention.export_attention_3d_gqa^  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C(;;33B;<	
r.   c            
     J   Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        UUUU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r      r   "test_attention_3d_diff_heads_sizesr   r   r   r   r   s           r+   #export_attention_3d_diff_head_sizes-Attention.export_attention_3d_diff_head_sizes}  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C5;;33B;<	
r.   c            
     R   Sn Su  p[         R                  R                  S/ SQS/U UUS9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        UUUU UUS9u  n    n[        UXEU/U/S[         R                  R                  SS5      /S9  g )Nr@   r   r   r   r   r   r   rB   r   r   r   r   r   r   rB   r   r   test_attention_3d_scaledr   r   r   r   	rB   r   r   r)   r   r   r   r   r*   s	            r+   export_attention_3d_scaled$Attention.export_attention_3d_scaled  s   $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C+;;33B;<	
r.   c            
     R   Sn Su  p[         R                  R                  S/ SQS/U UUS9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUU UUS9u  n    n[        UXEU/U/S[         R                  R                  SS5      /S9  g )Nr@   r  r   r   r   r  r   r   r  r   r   r  test_attention_3d_gqa_scaledr   r   r   r   r  s	            r+   export_attention_3d_gqa_scaled(Attention.export_attention_3d_gqa_scaled  s   $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C/;;33B;<	
r.   c            
     R   Sn Su  p[         R                  R                  S/ SQS/U UUS9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUU UUS9u  n    n[        UXEU/U/S[         R                  R                  SS5      /S9  g )Nr@   r   r   r   r   r  r   r   r   r   r  r  )test_attention_3d_diff_heads_sizes_scaledr   r   r   r   r  s	            r+   *export_attention_3d_diff_head_sizes_scaled4Attention.export_attention_3d_diff_head_sizes_scaled  s   $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C<;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   rQ   r   r   rS   r   r   r   r   r   r   rS   r   r   test_attention_3d_causalr   r   r   r   r   s           r+   export_attention_3d_causal$Attention.export_attention_3d_causal  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C+;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr  r   r   r   rQ   r  r   r   r  r   r   r  test_attention_3d_gqa_causalr   r   r   r   r   s           r+   export_attention_3d_gqa_causal(Attention.export_attention_3d_gqa_causal#  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C/;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   rQ   r  r   r   r   r   r  r  )test_attention_3d_diff_heads_sizes_causalr   r   r   r   r   s           r+   *export_attention_3d_diff_head_sizes_causal4Attention.export_attention_3d_diff_head_sizes_causalD  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C<;;33B;<	
r.   c            
        Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUU US
9u  n    n[        UX4XV/U/S[         R                  R                  SS5      /S9  g )Nr   r   ra   r   r   r   r   r   r   rb   r   r   test_attention_3d_attn_maskr   r   r   r   	r   r   r)   r   r   r   rb   r   r*   s	            r+   export_attention_3d_attn_mask'Attention.export_attention_3d_attn_maske  s    $(!{{$$/E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a(//

;	'#%

1a 	!'C.;;33B;<	
r.   c            
        Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUU US9u  n    n[        UX4XV/U/S[         R                  R                  SS5      /S9  g )Nr  r   ra   r   r   r   r   r  r   r   r)  test_attention_3d_gqa_attn_maskr   r   r   r   r+  s	            r+   !export_attention_3d_gqa_attn_mask+Attention.export_attention_3d_gqa_attn_mask  s    $(!{{$$/E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a(//

;	'#%

1a 	!'C2;;33B;<	
r.   c            
        Su  p[         R                  R                  S/ SQS/U US9n[        R                  R                  SSS5      R                  [        R                  5      n[        R                  R                  SS	S5      R                  [        R                  5      n[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SS	5      R                  [        R                  5      n[        UUUUU US9u  n    n[        UX4XV/U/S[         R                  R                  SS5      /S9  g )Nr   r   ra   r   r   r   r   r   r   r  r)  ,test_attention_3d_diff_heads_sizes_attn_maskr   r   r   r   r+  s	            r+   -export_attention_3d_diff_head_sizes_attn_mask7Attention.export_attention_3d_diff_head_sizes_attn_mask  s    $(!{{$$/E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a(//

;	'#%

1a 	!'C?;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r         @r   r   r   r   r   r   r   r   r   r   r   r   test_attention_3d_softcapr   r   r   r   r   s           r+   export_attention_3d_softcap%Attention.export_attention_3d_softcap  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C,;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr  r   r   r   r7  r8  r   r   r  r   r   r9  test_attention_3d_gqa_softcapr   r   r   r   r   s           r+   export_attention_3d_gqa_softcap)Attention.export_attention_3d_gqa_softcap  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C0;;33B;<	
r.   c            
     N   Su  p[         R                  R                  S/ SQS/SU US9n[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        UUUSU US9u  n    n[        UX4U/U/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r7  r8  r   r   r   r   r  r9  *test_attention_3d_diff_heads_sizes_softcapr   r   r   r   r   s           r+   +export_attention_3d_diff_head_sizes_softcap5Attention.export_attention_3d_diff_head_sizes_softcap
  s    $(!{{$$"E#% % 
 IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7'#%

1a 	!9C=;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU US9nSn[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U US9u  pp[        UXEXgX/XU/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r   r   rb   r   r   r   r   'test_attention_3d_with_past_and_presentr   r   r   r   r   r   r)   r   r   r   r   rb   r   r   r   r   r   r*   s                 r+   )export_attention_3d_with_past_and_present3Attention.export_attention_3d_with_past_and_present+  s   $(!{{$$I9#% % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
+=!#%	,
( 	!=]3:;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU US9nSn[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U US9u  pp[        UXEXgX/XU/S[         R                  R                  SS5      /S9  g )Nr  r   r   r   r   r   r   r   r  r   r   r   r   rF  +test_attention_3d_gqa_with_past_and_presentr   r   r   r   rH  s                 r+   -export_attention_3d_gqa_with_past_and_present7Attention.export_attention_3d_gqa_with_past_and_presentQ  s   $(!{{$$I9#% % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
+=!#%	,
( 	!=]3>;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU US9nSn[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U US9u  pp[        UXEXgX/XU/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r  r   r   r;   rF  2test_attention_3d_diff_heads_with_past_and_presentr   r   r   r   rH  s                 r+   9export_attention_3d_diff_head_sizes_with_past_and_presentCAttention.export_attention_3d_diff_head_sizes_with_past_and_presentw  s   $(!{{$$I9#% % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>CJJ2::V
+=!#%	,
( 	!=]3E;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU US9nSn[        R                  R                  SSS	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
S	5      R                  [        R                  5      n[        R                  R                  SS
U-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U US9u  pp[        UXEXgX/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   r   r   r   r   r   r   rF  1test_attention_3d_with_past_and_present_qk_matmulr   r   r   r   r   r   r)   r   r   r   r   rb   r   r   r   r   r   r   s                 r+   3export_attention_3d_with_past_and_present_qk_matmul=Attention.export_attention_3d_with_past_and_present_qk_matmul  s   $(!{{$$IM#% % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!#%	;
7 	!=]ED;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU USS9nSn[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  S	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U USS9	u  pp[        UXEXgX/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   rQ   r   r   r   r   r   r   r   r   r   r   r   r   rb   r   r   r   r   r   6test_attention_3d_with_past_and_present_qk_matmul_biasr   r   r   r   rU  s                 r+   8export_attention_3d_with_past_and_present_qk_matmul_biasBAttention.export_attention_3d_with_past_and_present_qk_matmul_bias  s   $(!{{$$IM#%"# % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!#%"#
;
7 	!=]EI;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU USSS9nSn[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  S	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U USSS9
u  pp[        UXEXgX/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   )rb   r   r   r   r   r   r   9test_attention_3d_with_past_and_present_qk_matmul_softcapr   r   r   r   rU  s                 r+   ;export_attention_3d_with_past_and_present_qk_matmul_softcapEAttention.export_attention_3d_with_past_and_present_qk_matmul_softcap  s   $(!{{$$IM#%"# % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!#%"#;
7 	!=]EL;;33B;<	
r.   c                    Su  p[         R                  R                  S/ SQ/ SQU USS9nSn[        R                  R                  SS	S
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  SSS
5      R                  [        R                  5      n[        R                  R                  S	SU-   5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n[        R                  R                  SSUS5      R                  [        R                  5      n	[        UUUUUU	U USS9	u  pp[        UXEXgX/XX/S[         R                  R                  SS5      /S9  g )Nr   r   r   r   r   rY  r   r   r   r   r   r   rZ  9test_attention_3d_with_past_and_present_qk_matmul_softmaxr   r   r   r   rU  s                 r+   ;export_attention_3d_with_past_and_present_qk_matmul_softmaxEAttention.export_attention_3d_with_past_and_present_qk_matmul_softmax  s   $(!{{$$IM#%"# % 
  "IINN1a$++BJJ7IINN1a$++BJJ7IINN1a$++BJJ7IINN1a*>&>?FFrzzR	99>>!Q(<a@GG

SYY^^Aq*>BII"**U
:L!#%"#
;
7 	!=]EL;;33B;<	
r.   c            
     B   Su  p[         R                  R                  S/ SQS/U US9nSnSnSnSnX-  nX-  n[        R                  " X4U4[        R
                  S	9n	[        U 5       H"  n
X-  nX-   n[        U
S-   5      U	S
SS2X24'   M$     [        R                  " X5U4[        R
                  S	9S-  n[        R                  " X5U4[        R
                  S	9S-  n[        U	UUU US9u  n    n[        UXU/U/S[         R                  R                  SS5      /S9  g)a1  Test case to verify correct 3D to 4D transpose behavior.

This test verifies that 3D inputs are correctly reshaped and transposed
according to the ONNX specification:
[batch_size, seq_length, hidden_size] ->
[batch_size, seq_length, num_heads, head_size] ->
[batch_size, num_heads, seq_length, head_size]
r   r   r   r   r   rQ   r   r   dtyper   Ng?r   (test_attention_3d_transpose_verificationr   r   r   )r   r    r!   r"   zerosr&   rangefloatonesr   r   r'   )r   r   r)   
batch_sizeq_seq_lengthkv_seq_length	head_sizeq_hidden_sizekv_hidden_sizer   head	start_idxend_idxr   r   r   r*   s                    r+   *export_attention_3d_transpose_verification4Attention.export_attention_3d_transpose_verification=  sF    %)!{{$$"E#% % 
 
	#/%1 HHj>bjjQ+&D(I+G).taxAaI%%& '
 GGZ?rzzRUXXGGZ?rzzRUXX'#%

1a 	!9C;;;33B;<	
r.   c            
        [         R                  R                  S/ SQS/S9n [        R                  R                  SSSS5      R                  [        R                  5      n[        R                  R                  SSS	S5      R                  [        R                  5      n[        R                  R                  SSS	S
5      R                  [        R                  5      n[        R                  R                  SSSS5      R                  [        R                  5      n[        R                  " SS/[        R                  S9n[        UUUUUS9u  n    n[        U XX4U/U/S[         R                  R                  SS5      /S9  g )Nr   )r   r   r   rb   r   r   nonpad_kv_seqlenr   r   r   r   r   r   r   r;   rg  )rb   rz  -test_attention_4d_diff_heads_mask4d_padded_kvr   r   r   )r   r    r!   r"   r#   r$   r%   r&   arrayint64r   r   r'   )r)   r   r   r   rb   rz  r   r*   s           r+   /export_attention_4d_diff_heads_mask4d_padded_kv9Attention.export_attention_4d_diff_heads_mask4d_padded_kvt  s5   {{$$KE % 
 IINN1aA&--bjj9IINN1aA&--bjj9IINN1aB'..rzz:IINN1aA.55bjjA	88QF"((;'-

1a 	!(89C@;;33B;<	
r.    N)returnNone)D__name__
__module____qualname____firstlineno__staticmethodr,   r3   r8   r=   rF   rJ   rN   rV   rZ   r^   rf   rj   rp   ru   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r  r  r  r  r"  r&  r,  r0  r4  r;  r?  rC  rI  rM  rQ  rV  r\  r`  rd  rw  r~  __static_attributes__r  r.   r+   r   r      s   
 
" 
 
" 
 
" 
 
" 
 
. 
 
. 
 
. 
 
, 
 
, 
 
6 
 
6 
 
6 
 
: 
 
6 
 
: 
 
6 
 
6 
 
6 
 
6 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
, 
 
, 
 
6 
 
* 
 
: 
 
> 
 
:  
  
D  
  
D  
  
D "
 "
H "
 "
H 
 
@ 
 
< 
 
< 
 
< 
 
B 
 
B 
 
B 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ 
 
@ #
 #
J #
 #
J #
 #
J #
 #
J %
 %
N '
 '
R %
 %
N 4
 4
l 
 
r.   r   )
__future__r   numpyr"   r   onnx.backend.test.case.baser   onnx.backend.test.case.noder   onnx.reference.ops.op_attentionr   r   r  r.   r+   <module>r     s'    #   , . >B
 B
r.   