
    /jQ                    b    d dl mZ d dlZd dlZd dlmZ d dlmZ d dl	m
Z
  G d de          ZdS )    )annotationsN)Base)expect)_compute_attentionc                     e Zd ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            Z	edBd	            Z
edBd
            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            ZedBd            Z edBd             Z!edBd!            Z"edBd"            Z#edBd#            Z$edBd$            Z%edBd%            Z&edBd&            Z'edBd'            Z(edBd(            Z)edBd)            Z*edBd*            Z+edBd+            Z,edBd,            Z-edBd-            Z.edBd.            Z/edBd/            Z0edBd0            Z1edBd1            Z2edBd2            Z3edBd3            Z4edBd4            Z5edBd5            Z6edBd6            Z7edBd7            Z8edBd8            Z9edBd9            Z:edBd:            Z;edBd;            Z<edBd<            Z=edBd=            Z>edBd>            Z?edBd?            Z@edBd@            ZAdAS )C	AttentionreturnNonec            
     d   t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          |||          \  }}}}t          | |||g|gd
t           j        
                    dd          g           d S )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         j/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/onnx/backend/test/case/node/attention.pyexport_attentionzAttention.export_attention   s   {$$[SVRW$XXINN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a00
1aq!9C$;33B;;<	
 	
 	
 	
 	
 	
    c            
     d   t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          |||          \  }}}}t          | |||g|gd
t           j        
                    dd          g           d S )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_fp16zAttention.export_attention_fp16!   s   {$$[SVRW$XXINN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a00
1aq!9C);33B;;<	
 	
 	
 	
 	
 	
r.   c            
     d   t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            dd	d
d                              t          j                  }t          j                            dd	d
d                              t          j                  }t          |||          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   r   	   r   r   r   r   test_attention_4d_gqar   r   r   r   r)   s         r,   export_attention_gqazAttention.export_attention_gqa3   s   {$$[SVRW$XXINN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a00
1aq!9C(;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     d   t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d
                              t          j                  }t          |||          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )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_sizesz*Attention.export_attention_diff_head_sizesE   s   {$$[SVRW$XXINN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::'1a00
1aq!9C5;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     n   d} t           j                            dg ddg|           }t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          ||||           \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )N{Gz?r   r   r   r   r   scaler   r   r   r   r   r?   test_attention_4d_scaledr   r   r   r   r?   r*   r   r   r   r   r+   s          r,   export_attention_scaledz!Attention.export_attention_scaledW   s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1au===
1aq!9C+;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     n   d} t           j                            dg ddg|           }t          j                            dddd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          ||||           \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr=   r   r   r   r>   r   r5   r   r   r   r   r@   test_attention_4d_gqa_scaledr   r   r   r   rB   s          r,   export_attention_gqa_scaledz%Attention.export_attention_gqa_scaledo   s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1au===
1aq!9C/;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     n   d} t           j                            dg ddg|           }t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          ||||           \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr=   r   r   r   r>   r   r   r   r   r   r9   r@   )test_attention_4d_diff_heads_sizes_scaledr   r   r   r   rB   s          r,   'export_attention_diff_head_sizes_scaledz1Attention.export_attention_diff_head_sizes_scaled   s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::'1au===
1aq!9C<;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r      r   r   	is_causalr   r   r   r   r   rM   test_attention_4d_causalr   r   r   r   r)   s         r,   export_attention_causalz!Attention.export_attention_causal   s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a1===
1aq!9C+;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r   rK   rL   r   r5   r   r   r   r   rN   test_attention_4d_gqa_causalr   r   r   r   r)   s         r,   export_attention_gqa_causalz%Attention.export_attention_gqa_causal   s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a1===
1aq!9C/;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r   rK   rL   r   r   r   r   r   r9   rN   )test_attention_4d_diff_heads_sizes_causalr   r   r   r   r)   s         r,   'export_attention_diff_head_sizes_causalz1Attention.export_attention_diff_head_sizes_causal   s$   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::'	
 
 

1a 	q!9C<;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dd	                              t          j                  }t          ||||
          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   	attn_maskr   r   r   r   r   r   r   rY   test_attention_4d_attn_maskr   r   r   r   r*   r   r   r   rY   r   r+   s          r,   export_attention_attn_maskz$Attention.export_attention_attn_mask   sK   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//
;;	'	
 
 

1a 	q!Y'C.;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dd
dd	                              t          j                  }t          ||||          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   r   r   r   r   r   r   rK   rZ   test_attention_4d_attn_mask_3dr   r   r   r   r\   s          r,   export_attention_attn_3d_maskz'Attention.export_attention_attn_3d_mask  O   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1aA..55bjAA	'	
 
 

1a 	q!Y'C1;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dddd
                              t          j                  }t          ||||d          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   rK   rL   r   r   r   r   r   rY   rM   %test_attention_4d_attn_mask_3d_causalr   r   r   r   r\   s          r,   $export_attention_attn_3d_mask_causalz.Attention.export_attention_attn_3d_mask_causal!  U   {$$///E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1aA..55bjAA	'
 
 

1a 	q!Y'C8;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dddd	                              t          j                  }t          ||||
          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   r   r   r   r   r   r   rZ   test_attention_4d_attn_mask_4dr   r   r   r   r\   s          r,   export_attention_attn_4d_maskz'Attention.export_attention_attn_4d_mask?  ra   r.   c            
        t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dddd
                              t          j                  }t          ||||d          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   rK   rL   r   r   r   r   r   rc   %test_attention_4d_attn_mask_4d_causalr   r   r   r   r\   s          r,   $export_attention_attn_4d_mask_causalz.Attention.export_attention_attn_4d_mask_causal[  rf   r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dd	                              t                    }t          ||||
          \  }}}}t          | ||||g|gdt           j                            dd          g           d S )Nr   rX   r   r   r   r   r   r   r   rZ    test_attention_4d_attn_mask_boolr   r   r   r    r!   r"   r#   r$   r%   r&   r'   boolr   r   r(   r\   s          r,   export_attention_attn_mask_boolz)Attention.export_attention_attn_mask_booly  sI   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//55	'	
 
 

1a 	q!Y'C3;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dddd	                              t                    }t          ||||
          \  }}}}t          | ||||g|gdt           j                            dd          g           d S )Nr   rX   r   r   r   r   r   r   r   rZ   #test_attention_4d_attn_mask_bool_4dr   r   r   ro   r\   s          r,   "export_attention_attn_mask_bool_4dz,Attention.export_attention_attn_mask_bool_4d  sM   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1aA..55d;;	'	
 
 

1a 	q!Y'C6;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            dd	d
d                              t          j                  }t          j                            dd	d
d                              t          j                  }t          j                            dd
                              t          j                  }t          ||||          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   r   r   r5   r   r   r   r   rZ   test_attention_4d_gqa_attn_maskr   r   r   r   r\   s          r,   export_attention_gqa_attn_maskz(Attention.export_attention_gqa_attn_mask  sK   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//
;;	'	
 
 

1a 	q!Y'C2;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d
                              t          j                  }t          j                            dd	                              t          j                  }t          ||||          \  }}}}t          | ||||g|gdt           j        
                    dd          g           d S )Nr   rX   r   r   r   r   r   r   r   r9   rZ   ,test_attention_4d_diff_heads_sizes_attn_maskr   r   r   r   r\   s          r,   *export_attention_diff_head_sizes_attn_maskz4Attention.export_attention_diff_head_sizes_attn_mask  sK   {$$///E % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::INN1a((//
;;	'	
 
 

1a 	q!Y'C?;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d	                              t          j                  }t          j                            dd|d	                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r   r   r   rY   past_key
past_valuer   present_keypresent_valuer      r   r   r   r   r   rY   r}   r~   'test_attention_4d_with_past_and_presentr   r   r   r   r*   past_sequence_lengthr   r   r   rY   r}   r~   r   r   r   r+   s               r,   &export_attention_with_past_and_presentz0Attention.export_attention_with_past_and_present  s   {$$III999 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
+=!,
 ,
 ,
(;q 	q!Y*=]3:;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd|z                                 t          j                  }t          j                            dd
|d	                              t          j                  }t          j                            dd
|d	                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   r5   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_presentz4Attention.export_attention_gqa_with_past_and_present
  s   {$$III999 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
+=!,
 ,
 ,
(;q 	q!Y*=]3>;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd|z                                 t          j                  }t          j                            dd
|d	                              t          j                  }t          j                            dd
|d	                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   r5   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_fp16z9Attention.export_attention_gqa_with_past_and_present_fp16+  s   {$$III999 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
+=!,
 ,
 ,
(;q 	q!Y*=]3C;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d	                              t          j                  }t          j                            dd|d                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   r   r   r   r   r9   r   2test_attention_4d_diff_heads_with_past_and_presentr   r   r   r   r   s               r,   6export_attention_diff_head_sizes_with_past_and_presentz@Attention.export_attention_diff_head_sizes_with_past_and_presentL  s   {$$III999 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>CCJJ2:VV
+=!,
 ,
 ,
(;q 	q!Y*=]3E;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          j                            dddd
|z                                 t          j                  }t          j                            dd|d	                              t          j                  }t          j                            dd|d                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   r   r   r   r   r9   rK   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_mask3DzGAttention.export_attention_diff_head_sizes_with_past_and_present_mask3Dm     {$$III999 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::INN1aA0D,DEELLRZXX	9>>!Q(<a@@GG
SSY^^Aq*>CCJJ2:VV
+=!,
 ,
 ,
(;q 	q!Y*=]3L;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          j                            dddd
|z                                 t          j                  }t          j                            dd|d	                              t          j                  }t          j                            dd|d                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   r   r   r   r   r9   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_mask4DzGAttention.export_attention_diff_head_sizes_with_past_and_present_mask4D  r   r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r          @r   r   softcapr   r   r   r   r   r   test_attention_4d_softcapr   r   r   r   r)   s         r,   export_attention_softcapz"Attention.export_attention_softcap  s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a===
1aq!9C,;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          j                            dd
dd	                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   r   r   r5   r   r   r   r   r   test_attention_4d_gqa_softcapr   r   r   r   r)   s         r,   export_attention_gqa_softcapz&Attention.export_attention_gqa_softcap  s   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99'1a===
1aq!9C0;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     j   t           j                            dg ddgd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d                              t          j                  }t          |||d          \  }}}}t          | |||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   r   r   r   r   r   r   r9   r   *test_attention_4d_diff_heads_sizes_softcapr   r   r   r   r)   s         r,   (export_attention_diff_head_sizes_softcapz2Attention.export_attention_diff_head_sizes_softcap  s$   {$$"??E	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::'	
 
 

1a 	q!9C=;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     h   t           j                            dg dg d          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          |||          \  }}}}t          | |||g||gd
t           j        
                    dd          g           d S )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_matmulz)Attention.export_attention_with_qk_matmul  s   {$$"??555 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99$6q!Q$?$?!1a!q!9()3;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg dd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dd
                              t          j                  }t          ||||d          \  }}}}t          | ||||g||gdt           j        
                    dd          g           d S )Nr   rX   r   rK   r   r   qk_matmul_output_moder   r   r   r   r   rY   r   %test_attention_4d_with_qk_matmul_biasr   r   r   r   r*   r   r   r   rY   r   r+   r   s           r,   $export_attention_with_qk_matmul_biasz.Attention.export_attention_with_qk_matmul_bias  s[   {$$///555"#	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//
;;	$6"#%
 %
 %
!1a! 	q!Y'()8;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg ddd          } t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dd
                              t          j                  }t          ||||dd          \  }}}}t          | ||||g||gdt           j        
                    dd          g           d S )Nr   rX   r   r   r   )r   r   r   r   r   r   r   r   )rY   r   r   (test_attention_4d_with_qk_matmul_softcapr   r   r   r   r   s           r,   'export_attention_with_qk_matmul_softcapz1Attention.export_attention_with_qk_matmul_softcap-  sa   {$$///555"# % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//
;;	$6"#%
 %
 %
!1a! 	q!Y'();;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg dd          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            dd	                              t          j                  }t          ||||d
          \  }}}}t          | ||||g||gdt           j        
                    dd          g           d S )Nr   rX   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_softmaxz1Attention.export_attention_with_qk_matmul_softmaxM  s[   {$$///555"#	 % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a((//
;;	$6"#%
 %
 %
!1a! 	q!Y'();;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg dd          } d}t          j                            ddd	d
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            d	d|z                                 t          j                  }t          j                            dd|d
                              t          j                  }t          j                            dd|d
                              t          j                  }t          ||||||d          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )Nr   r|   r   r   r   r   rK   r   r   r   r   r   r   r   rY   r}   r~   r   6test_attention_4d_with_past_and_present_qk_matmul_biasr   r   r   r   r*   r   r   r   r   rY   r}   r~   r   r   r   r   s               r,   5export_attention_with_past_and_present_qk_matmul_biasz?Attention.export_attention_with_past_and_present_qk_matmul_biask  s   {$$IIIMMM"#	 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!"#;
 ;
 ;
7;'7 	q!Y*=]4DEI;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg dd          } d}t          j                            ddd	d
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            ddd	d|z                                 t          j                  }t          j                            dd|d
                              t          j                  }t          j                            dd|d
                              t          j                  }t          ||||||d          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )Nr   r|   r   rK   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_maskzGAttention.export_attention_with_past_and_present_qk_matmul_bias_3d_mask     {$$IIIMMM"#	 % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1aA0D,DEELLRZXX	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!"#;
 ;
 ;
7;'7 	q!Y*=]4DEQ;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg dd          } d}t          j                            ddd	d
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            ddd	d|z                                 t          j                  }t          j                            dd|d
                              t          j                  }t          j                            dd|d
                              t          j                  }t          ||||||d          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )Nr   r|   r   rK   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_maskzGAttention.export_attention_with_past_and_present_qk_matmul_bias_4d_mask  r   r.   c            
        t           j                            dg dg ddd          } d}t          j                            ddd	d
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            ddd	d|z                                 t          j                  }t          j                            dd|d
                              t          j                  }t          j                            dd|d
                              t          j                  }t          ||||||dd          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )Nr   r|   r   rK   r   r   r   rM   r   r   r   r   r   r   rY   r}   r~   r   rM   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_causalzNAttention.export_attention_with_past_and_present_qk_matmul_bias_3d_mask_causal     {$$IIIMMM"# % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1aA0D,DEELLRZXX	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!"#	;
 	;
 	;
7;'7 	q!Y*=]4DEX;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        t           j                            dg dg ddd          } d}t          j                            ddd	d
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            dddd
                              t          j                  }t          j                            ddd	d|z                                 t          j                  }t          j                            dd|d
                              t          j                  }t          j                            dd|d
                              t          j                  }t          ||||||dd          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )Nr   r|   r   rK   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_causalzNAttention.export_attention_with_past_and_present_qk_matmul_bias_4d_mask_causal  r   r.   c            
        t           j                            dg dg d          } d}t          j                            dddd	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            ddd
d	                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d	                              t          j                  }t          j                            dd|d	                              t          j                  }t          ||||||          \  }}	}
}t          | ||||||g||	|
|gdt           j        
                    dd          g           d S )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_matmulz:Attention.export_attention_with_past_and_present_qk_matmul  s   {$$IIIMMM % 
 
  "INN1aA&&--bj99INN1aA&&--bj99INN1aA&&--bj99INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!;
 ;
 ;
7;'7 	q!Y*=]4DED;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     r   d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d                              t          j                  }t          j                            dd	d                              t          j                  }t          |||| |
          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )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_3dzAttention.export_attention_3d?  s.   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C$;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     r   d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d
                              t          j                  }t          j                            dd	d
                              t          j                  }t          |||| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr5   r   r   r   r   r   r   r   H   r   r   r   test_attention_3d_gqar   r   r   r   r   s           r,   export_attention_3d_gqaz!Attention.export_attention_3d_gqa^  s.   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C(;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     r   d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d                              t          j                  }t          j                            dd	d
                              t          j                  }t          |||| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )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_sizesz-Attention.export_attention_3d_diff_head_sizes}  s.   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C5;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     z   d} d\  }}t           j                            dg ddg| ||          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d	                              t          j                  }t          |||| ||          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr=   r   r   r   r   r   r   r?   r   r   r   r   r   r   r?   r   r   test_attention_3d_scaledr   r   r   r   	r?   r   r   r*   r   r   r   r   r+   s	            r,   export_attention_3d_scaledz$Attention.export_attention_3d_scaled  s9   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C+;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     z   d} d\  }}t           j                            dg ddg| ||          }t          j                            ddd	                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
d                              t          j                  }t          |||| ||          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )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_scaledz(Attention.export_attention_3d_gqa_scaled  s9   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C/;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     z   d} d\  }}t           j                            dg ddg| ||          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d                              t          j                  }t          |||| ||          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )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_scaledz4Attention.export_attention_3d_diff_head_sizes_scaled  s9   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C<;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d	                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   rK   r   r   rM   r   r   r   r   r   r   rM   r   r   test_attention_3d_causalr   r   r   r   r   s           r,   export_attention_3d_causalz$Attention.export_attention_3d_causal  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C+;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
d                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   rK   r   r   r   r   r   r   r   test_attention_3d_gqa_causalr   r   r   r   r   s           r,   export_attention_3d_gqa_causalz(Attention.export_attention_3d_gqa_causal#  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C/;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   rK   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_causalz4Attention.export_attention_3d_diff_head_sizes_causalD  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C<;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d                              t          j                  }t          j                            dd	d                              t          j                  }t          j                            dd	                              t          j                  }t          ||||| |
          \  }}}}t          |||||g|gdt           j        
                    dd          g           d S )Nr   r   rX   r   r   r   r   r   r   rY   r   r   test_attention_3d_attn_maskr   r   r   r   	r   r   r*   r   r   r   rY   r   r+   s	            r,   export_attention_3d_attn_maskz'Attention.export_attention_3d_attn_maske  s[   $(!\{$$///E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a((//
;;	'#%
 
 

1a 	q!Y'C.;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d
                              t          j                  }t          j                            dd	d
                              t          j                  }t          j                            dd	                              t          j                  }t          ||||| |          \  }}}}t          |||||g|gdt           j        
                    dd          g           d S )Nr   r   rX   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_maskz+Attention.export_attention_3d_gqa_attn_mask  s[   $(!\{$$///E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a((//
;;	'#%
 
 

1a 	q!Y'C2;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg ddg| |          }t          j                            ddd                              t          j                  }t          j                            dd	d                              t          j                  }t          j                            dd	d
                              t          j                  }t          j                            dd	                              t          j                  }t          ||||| |          \  }}}}t          |||||g|gdt           j        
                    dd          g           d S )Nr   r   rX   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_maskz7Attention.export_attention_3d_diff_head_sizes_attn_mask  s[   $(!\{$$///E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a((//
;;	'#%
 
 

1a 	q!Y'C?;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d	                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )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_softcapz%Attention.export_attention_3d_softcap  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C,;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
d                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   r  r  r   r   r   r   r   r  test_attention_3d_gqa_softcapr   r   r   r   r   s           r,   export_attention_3d_gqa_softcapz)Attention.export_attention_3d_gqa_softcap  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C0;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     v   d\  } }t           j                            dg ddgd| |          }t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d                              t          j                  }t          |||d| |          \  }}}}t          ||||g|gdt           j        
                    dd          g           d S )Nr   r   r   r   r  r  r   r   r   r   r   r  *test_attention_3d_diff_heads_sizes_softcapr   r   r   r   r   s           r,   +export_attention_3d_diff_head_sizes_softcapz5Attention.export_attention_3d_diff_head_sizes_softcap
  s4   $(!\{$$"??E#% % 
 
 INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77'#%
 
 

1a 	q!9C=;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg dg d| |          }d}t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |          \  }
}}}t          |||||||	g|
||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r   r   r   r   r   r   r   rY   r}   r~   r   r   'test_attention_3d_with_past_and_presentr   r   r   r   r   r   r*   r   r   r   r   rY   r}   r~   r   r   r   r+   s                 r,   )export_attention_3d_with_past_and_presentz3Attention.export_attention_3d_with_past_and_present+  s   $(!\{$$III999#% % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
+=!#%	,
 	,
 	,
(;q 	q!Y*=]3:;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg dg d| |          }d}t          j                            ddd	                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |          \  }
}}}t          |||||||	g|
||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r   r   r   r   r   r   r   r   r  +test_attention_3d_gqa_with_past_and_presentr   r   r   r   r  s                 r,   -export_attention_3d_gqa_with_past_and_presentz7Attention.export_attention_3d_gqa_with_past_and_presentQ  s   $(!\{$$III999#% % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
+=!#%	,
 	,
 	,
(;q 	q!Y*=]3>;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg dg d| |          }d}t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |          \  }
}}}t          |||||||	g|
||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r   r   r   r   r   r   r   r   r9   r  2test_attention_3d_diff_heads_with_past_and_presentr   r   r   r   r  s                 r,   9export_attention_3d_diff_head_sizes_with_past_and_presentzCAttention.export_attention_3d_diff_head_sizes_with_past_and_presentw  s   $(!\{$$III999#% % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>CCJJ2:VV
+=!#%	,
 	,
 	,
(;q 	q!Y*=]3E;33B;;<	
 	
 	
 	
 	
 	
r.   c            
        d\  } }t           j                            dg dg d| |          }d}t          j                            ddd	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
d	                              t          j                  }t          j                            dd
|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |          \  }
}}}t          |||||||	g|
|||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r   r   r   r   r   r   r   r  1test_attention_3d_with_past_and_present_qk_matmulr   r   r   r   r   r   r*   r   r   r   r   rY   r}   r~   r   r   r   r   s                 r,   3export_attention_3d_with_past_and_present_qk_matmulz=Attention.export_attention_3d_with_past_and_present_qk_matmul  s   $(!\{$$IIIMMM#% % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!#%	;
 	;
 	;
7;'7 	q!Y*=]4DED;33B;;<	
 	
 	
 	
 	
 	
r.   c                 
   d\  } }t           j                            dg dg d| |d          }d}t          j                            dd	d
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            d	d|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |d	  	        \  }
}}}t          |||||||	g|
|||gdt           j        
                    dd          g           d S )Nr   r   r|   r   rK   r   r   r   r   r   r   r   r   r   r   r   r   rY   r}   r~   r   r   r   6test_attention_3d_with_past_and_present_qk_matmul_biasr   r   r   r   r  s                 r,   8export_attention_3d_with_past_and_present_qk_matmul_biaszBAttention.export_attention_3d_with_past_and_present_qk_matmul_bias  s   $(!\{$$IIIMMM#%"# % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!#%"#
;
 
;
 
;
7;'7 	q!Y*=]4DEI;33B;;<	
 	
 	
 	
 	
 	
r.   c                    d\  } }t           j                            dg dg d| |dd          }d}t          j                            dd	d
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            d	d|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |dd
  
        \  }
}}}t          |||||||	g|
|||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   )rY   r}   r~   r   r   r   r   9test_attention_3d_with_past_and_present_qk_matmul_softcapr   r   r   r   r  s                 r,   ;export_attention_3d_with_past_and_present_qk_matmul_softcapzEAttention.export_attention_3d_with_past_and_present_qk_matmul_softcap  s   $(!\{$$IIIMMM#%"# % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!#%"#;
 ;
 ;
7;'7 	q!Y*=]4DEL;33B;;<	
 	
 	
 	
 	
 	
r.   c                 
   d\  } }t           j                            dg dg d| |d          }d}t          j                            dd	d
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            ddd
                              t          j                  }t          j                            d	d|z                                 t          j                  }t          j                            dd|d                              t          j                  }t          j                            dd|d                              t          j                  }	t          ||||||	| |d	  	        \  }
}}}t          |||||||	g|
|||gdt           j        
                    dd          g           d S )Nr   r   r|   r   r   r!  r   r   r   r   r   r   r"  9test_attention_3d_with_past_and_present_qk_matmul_softmaxr   r   r   r   r  s                 r,   ;export_attention_3d_with_past_and_present_qk_matmul_softmaxzEAttention.export_attention_3d_with_past_and_present_qk_matmul_softmax  s   $(!\{$$IIIMMM#%"# % 
 
  "INN1a$$++BJ77INN1a$$++BJ77INN1a$$++BJ77INN1a*>&>??FFrzRR	9>>!Q(<a@@GG
SSY^^Aq*>BBII"*UU
:L!#%"#
;
 
;
 
;
7;'7 	q!Y*=]4DEL;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     p   d\  } }t           j                            dg ddg| |          }d}d}d}d}| |z  }||z  }t          j        |||ft          j        	          }	t          |           D ](}
|
|z  }||z   }t          |
dz             |	d
dd||f<   )t          j        |||ft          j        	          dz  }t          j        |||ft          j        	          dz  }t          |	||| |          \  }}}}t          ||	||g|gdt           j                            dd          g           dS )aa  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   rK   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_verificationz4Attention.export_attention_3d_transpose_verification=  s    %)!\{$$"??E#% % 
 
 
	#i/%	1 Hj,>bjQQQ+&& 	9 	9Dy(I)+G).taxAaIg%%&&GZ?rzRRRUXXGZ?rzRRRUXX'#%
 
 

1a 	q!9C;;33B;;<	
 	
 	
 	
 	
 	
r.   c            
     0   t           j                            dg ddg          } t          j                            dddd                              t          j                  }t          j                            ddd	d                              t          j                  }t          j                            ddd	d
                              t          j                  }t          j                            dddd                              t          j                  }t          j        ddgt          j	                  }t          |||||          \  }}}}t          | |||||g|gdt           j                            dd          g           d S )Nr   )r   r   r   rY   r   r   nonpad_kv_seqlenr   r   r   r   r   r   r   r9   r,  )rY   r>  -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   rY   r>  r   r+   s           r,   /export_attention_4d_diff_heads_mask4d_padded_kvz9Attention.export_attention_4d_diff_heads_mask4d_padded_kvt  sp   {$$KKKE % 
 
 INN1aA&&--bj99INN1aA&&--bj99INN1aB''..rz::INN1aA..55bjAA	8QF"(;;;'-
 
 

1a 	q!Y(89C@;33B;;<	
 	
 	
 	
 	
 	
r.   N)r	   r
   )B__name__
__module____qualname__staticmethodr-   r3   r7   r;   rC   rF   rI   rP   rS   rV   r]   r`   re   ri   rl   rq   rt   rw   rz   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  r  r  r  r  r  r$  r'  r*  r<  rB   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
 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   rG  r.   r,   <module>rM     s    # " " " " "      , , , , , , . . . . . . > > > > > >B
 B
 B
 B
 B
 B
 B
 B
 B
 B
r.   