
    sh3                        S SK rS SKJrJrJrJr  S SKJr  S SK	J
r
Jr  S SKJr  S SKrS SKrS SKJr  S rS rS	 rS
 rS rS rS rS rS rS rS rS rS rS rS r S r!\RD                  " SSS9S 5       r#\RD                  " SSS9S 5       r$S r%S r&S r'S r(S  r) " S! S"\5      r*\+S#:X  a  \RX                  " 5         gg)$    N)unittestCUDATestCaseskip_unless_cc_53skip_on_cudasim)cuda)f2b1)compile_ptx)
from_dtypec                     X-  U S'   g Nr    aryabs      y/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/cuda/tests/cudapy/test_operator.pysimple_fp16_div_scalarr          UCF    c                     X-   U S'   g r   r   r   s      r   simple_fp16addr      r   r   c                     U S==   U-  ss'   g r   r   r   r   s     r   simple_fp16_iaddr          FaKFr   c                     U S==   U-  ss'   g r   r   r   s     r   simple_fp16_isubr      r   r   c                     U S==   U-  ss'   g r   r   r   s     r   simple_fp16_imulr       r   r   c                     U S==   U-  ss'   g r   r   r   s     r   simple_fp16_idivr"       r   r   c                     X-
  U S'   g r   r   r   s      r   simple_fp16subr$   $   r   r   c                     X-  U S'   g r   r   r   s      r   simple_fp16mulr&   (   r   r   c                     U* U S'   g r   r   r   s     r   simple_fp16negr(   ,   s    RCFr   c                      [        U5      U S'   g r   )absr   s     r   simple_fp16absr+   0   s    VCFr   c                     X:  U S'   g r   r   r   s      r   simple_fp16_gtr-   4   r   r   c                     X:  U S'   g r   r   r   s      r   simple_fp16_ger/   8       VCFr   c                     X:  U S'   g r   r   r   s      r   simple_fp16_ltr2   <   r   r   c                     X:*  U S'   g r   r   r   s      r   simple_fp16_ler4   @   r0   r   c                     X:H  U S'   g r   r   r   s      r   simple_fp16_eqr6   D   r0   r   c                     X:g  U S'   g r   r   r   s      r   simple_fp16_ner8   H   r0   r   z
b1(f2, f2)T)devicec                 
    X:  $ Nr   xys     r   
hlt_func_1r?   L   	    5Lr   c                 
    X:  $ r;   r   r<   s     r   
hlt_func_2rB   Q   r@   r   c                 D    [        X5      =(       a    [        X#5      U S'   g r   )r?   rB   rr   r   cs       r   test_multiple_hcmp_1rG   V   s    a0
1 0AaDr   c                 6    [        X5      =(       a    X#:  U S'   g r   r?   rD   s       r   test_multiple_hcmp_2rJ   [   s    a%AaDr   c                 6    [        X5      =(       a    X2:  U S'   g r   rI   rD   s       r   test_multiple_hcmp_3rL   `   s    a&AaDr   c                 (    X:  =(       a    X#:  U S'   g r   r   rD   s       r   test_multiple_hcmp_4rN   e   s    5?QUAaDr   c                 (    X:  =(       a    X2:  U S'   g r   r   rD   s       r   test_multiple_hcmp_5rP   j   s    5QVAaDr   c                     ^  \ rS rSrU 4S jr S rS rS rS rS r	S r
\S	 5       r\" S
5      S 5       r\S 5       r\" S
5      S 5       r\S 5       r\S 5       r\" S
5      S 5       r\" S
5      S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\" S
5      S 5       r\" S
5      S 5       r\" S
5      S 5       rSrU =r$ )TestOperatorModuleo   c                 `   > [         TU ]  5         [        R                  R	                  S5        g r   )supersetUpnprandomseed)self	__class__s    r   rV   TestOperatorModule.setUpp   s    
		qr   c                   ^ [         R                  U4S j5       n[        R                  " S5      n[        R                  " S5      nUR	                  5       nUS   " XT5        [        R
                  R                  UT" X45      5        g )Nc                 (   > SnT" X   X   5      X'   g r   r   )r   r   iops      r   foo1TestOperatorModule.operator_template.<locals>.foox   s    AadAD>ADr      rc   rc   )r   jitrW   onescopytestingassert_equal)rZ   r`   ra   r   r   ress    `    r   operator_template$TestOperatorModule.operator_templatew   sd    		" 
	" GGAJGGAJffhD	#


RX.r   c                 B    U R                  [        R                  5        g r;   )rk   operatoraddrZ   s    r   test_addTestOperatorModule.test_add       x||,r   c                 B    U R                  [        R                  5        g r;   )rk   rn   subrp   s    r   test_subTestOperatorModule.test_sub   rs   r   c                 B    U R                  [        R                  5        g r;   )rk   rn   mulrp   s    r   test_mulTestOperatorModule.test_mul   rs   r   c                 B    U R                  [        R                  5        g r;   )rk   rn   truedivrp   s    r   test_truedivTestOperatorModule.test_truediv   s    x//0r   c                 B    U R                  [        R                  5        g r;   )rk   rn   floordivrp   s    r   test_floordiv TestOperatorModule.test_floordiv   s    x001r   c                    [         [        [        [        4n[        R
                  [        R                  [        R                  [        R                  4n[        X5       GH  u  p4U R                  US9   [        R                  " S5      " U5      n[        R                  " S[        R                  S9n[        R                   R!                  S5      R#                  [        R                  5      n[        R                   R!                  S5      R#                  [        R                  5      nUS   " XgS   US   5        U" Xx5      n	[        R$                  R'                  Xi5        S S S 5        GM     g ! , (       d  f       GM$  = f)Nr`   zvoid(f2[:], f2, f2)rc   dtyperd   r   )r   r$   r&   r   rn   ro   ru   ry   r}   zipsubTestr   re   rW   zerosfloat16rX   astyperh   assert_allclose
rZ   	functionsopsfnr`   kernelgotarg1arg2expecteds
             r   test_fp16_binary#TestOperatorModule.test_fp16_binary   s    #^^+-	||X\\8<<9I9IJ))FB$"78<hhq

3yy''*11"**=yy''*11"**=tSq'473d>

**39 %$ *$$s   5C1E44
F	z(Compilation unsupported in the simulatorc                    [         [        [        4nSn[        S S  [        [        4n[	        X5       H:  u  pEU R                  US9   [        XCSS9u  pgU R                  XV5        S S S 5        M<     g ! , (       d  f       MN  = fN)zadd.f16zsub.f16zmul.f16)instr      cc)r   r$   r&   r   r   r   r
   assertInrZ   r   instrsargsr   r   ptx_s           r   test_fp16_binary_ptx'TestOperatorModule.test_fp16_binary_ptx   sj    #^^D	21r2Y/IBE*$R&9e) +* 0**s   A22
B	c                    [         [        [        [        4n[        R
                  [        R                  [        R                  [        R                  4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4n[         R"                  " [%        X5      U5       GH  u  u  pEnU R'                  XVS9   [(        R*                  " U5      n[        R,                  R-                  S5      R/                  [        R0                  5      n[        R,                  R-                  S5      S-  R/                  U5      n	[        R2                  " [        R0                  U5      n
[        R4                  " SU
S9nUS   " XS   U	S   5        U" X5      n[        R6                  R9                  X5        S S S 5        GM     g ! , (       d  f       GM-  = f)Nr`   tyrc   d   r   rd   r   )r   r$   r&   r   rn   ro   ru   ry   r}   rW   int8int16int32int64float32float64	itertoolsproductr   r   r   re   rX   r   r   result_typer   rh   r   )rZ   r   r   typesr   r`   r   r   r   r   res_tyr   r   s                r   !test_mixed_fp16_binary_arithmetic4TestOperatorModule.test_mixed_fp16_binary_arithmetic   sI   #^^+-	||X\\8<<9I9IJ"((BHHbhhRZZ)%--c).A5ILHRb+"yy''*11"**=		((+c199"=

B7hhq/tSq'473d>

**39 ,+ J++s   )C7G..
G>	c                     [         [        [        4nSn[        S S  [        4n[	        X5       H:  u  pEU R                  US9   [        XCSS9u  pgU R                  XV5        S S S 5        M<     g ! , (       d  f       MN  = fr   )r   r   r    r   r   r   r
   r   r   s           r   test_fp16_inplace_binary_ptx/TestOperatorModule.test_fp16_inplace_binary_ptx   sj    %'79IJ	21r{Y/IBE*$R&9e) +* 0**s   A--
A<	c                    [         [        [        [        4n[        R
                  [        R                  [        R                  [        R                  4n[        X5       H  u  p4U R                  US9   [        R                  " S5      " U5      n[        R                  R                  S5      R                  [        R                   5      nUR#                  5       n[        R                  R                  S5      R                  [        R                   5      S   nUS   " Xh5        U" Xx5        [        R$                  R'                  Xg5        S S S 5        M     g ! , (       d  f       GM  = f)Nr   void(f2[:], f2)rc   r   rd   )r   r   r    r"   rn   iaddisubimulitruedivr   r   r   re   rW   rX   r   r   rg   rh   r   )	rZ   r   r   r   r`   r   r   r   args	            r   test_fp16_inplace_binary+TestOperatorModule.test_fp16_inplace_binary   s    %'79I%'	}}hmmX]]H<M<MN))FB$"34R8ii&&q)00<88:ii&&q)00<Q?tS&8!

**39 %$ *$$s   4CE
E+	c                 8   [         [        4n[        R                  [        R                  4n[        X5       H  u  p4U R                  US9   [        R                  " S5      " U5      n[        R                  " S[        R                  S9n[        R                  R                  S5      R                  [        R                  5      nUS   " XgS   5        U" U5      n[        R                  R                  Xh5        S S S 5        M     g ! , (       d  f       M  = f)Nr   r   rc   r   rd   r   )r(   r+   rn   negr*   r   r   r   re   rW   r   r   rX   r   rh   r   )	rZ   r   r   r   r`   r   r   r   r   s	            r   test_fp16_unary"TestOperatorModule.test_fp16_unary   s    #^4	||X\\*))FB$"34R8hhq

3yy''*11"**=tSq'*d8

**39 %$ *$$s   B1D


D	c                 h    [         S S  [         4n[        [        USS9u  p#U R                  SU5        g )Nr   r   zneg.f16)r   r
   r(   r   rZ   r   r   r   s       r   test_fp16_neg_ptx$TestOperatorModule.test_fp16_neg_ptx   s-    1r{^Tf=i%r   c                 h    [         S S  [         4n[        [        USS9u  p#U R                  SU5        g )Nr   r   zabs.f16)r   r
   r+   r   r   s       r   test_fp16_abs_ptx$TestOperatorModule.test_fp16_abs_ptx   s-    1r{^Tf=i%r   c                 J   [         [        [        [        [        [
        4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4n[        X5       GH  u  p4U R                  US9   [        R                   " S5      " U5      n["        R$                  " S["        R&                  S9n["        R(                  R)                  S5      R+                  ["        R,                  5      n["        R(                  R)                  S5      R+                  ["        R,                  5      nUS   " XgS   US   5        U" Xx5      n	U R/                  US   U	5        S S S 5        GM     g ! , (       d  f       GM  = f)Nr   zvoid(b1[:], f2, f2)rc   r   rd   r   )r-   r/   r2   r4   r6   r8   rn   gtgeltleeqner   r   r   re   rW   r   bool_rX   r   r   assertEqualr   s
             r   test_fp16_comparison'TestOperatorModule.test_fp16_comparison   s   #^#^#^5	 {{HKKhkk{{HKK) ))FB$"78<hhq1yy''*11"**=yy''*11"**=tSq'473d>  Q2 %$ *$$s   C'F
F"	c                    [         [        [        [        [        [
        4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4n[        R                  [        R                  [        R                   [        R"                  [        R$                  [        R&                  4n[(        R*                  " [-        X5      U5       H  u  u  pEnU R/                  XVS9   [0        R2                  " U5      n[        R4                  " S[        R6                  S9n[        R8                  R9                  S5      R;                  [        R<                  5      n	[        R8                  R9                  S5      S-  R;                  U5      n
US   " XS   U
S   5        U" X5      nU R?                  US   U5        S S S 5        M     g ! , (       d  f       GM
  = f)Nr   rc   r   r   rd   r   ) r-   r/   r2   r4   r6   r8   rn   r   r   r   r   r   r   rW   r   r   r   r   r   r   r   r   r   r   r   re   r   r   rX   r   r   r   )rZ   r   r   r   r   r`   r   r   r   r   r   r   s               r   test_mixed_fp16_comparison-TestOperatorModule.test_mixed_fp16_comparison  sS   #^#^#^5	 {{HKKhkk{{HKK)"((BHHbhhRZZ) &--c).A.35LHRb+"hhq1yy''*11"**=		((+c199"=tSq'473d>  Q2 ,+5++s   CG33
H	c                    [         [        [        [        [        4nU H  nU R                  US9   [        R                  " S5      " U5      n[        R                  " S[        R                  S9n[        R                  " S5      n[        R                  " S5      n[        R                  " S5      nUS   " XEXg5        U R                  US	   5        S S S 5        M     g ! , (       d  f       M  = f)
Nr   void(b1[:], f2, f2, f2)rc   r          @      @g      @rd   r   )rG   rJ   rL   rN   rP   r   r   re   rW   r   r   r   
assertTruerZ   r   r   compiledr   r   r   arg3s           r   !test_multiple_float16_comparisons4TestOperatorModule.test_multiple_float16_comparisons'  s    )))))	+	
 B$88$=>rBhhq1zz"~zz"~zz"~s$5A' %$ $$   B"C
C.	c                    [         [        [        [        [        4nU H  nU R                  US9   [        R                  " S5      " U5      n[        R                  " S[        R                  S9n[        R                  " S5      n[        R                  " S5      n[        R                  " S5      nUS   " XEXg5        U R                  US	   5        S S S 5        M     g ! , (       d  f       M  = f)
Nr   r   rc   r   r   r   g      ?rd   r   )rG   rJ   rL   rN   rP   r   r   re   rW   r   r   r   assertFalser   s           r   'test_multiple_float16_comparisons_false:TestOperatorModule.test_multiple_float16_comparisons_false8  s    )))))	+	
 B$88$=>rBhhq1zz"~zz"~zz"~s$5  Q( %$ $$r   c                    [         [        [        [        [        [
        4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4nSn[        S S  [        [        4n[        XU5       H;  u  pVnU R!                  US9   [#        XTSS9u  pU R%                  Xx5        S S S 5        M=     g ! , (       d  f       MO  = f)N)setp.gt.f16setp.ge.f16setp.lt.f16setp.le.f16setp.eq.f16setp.ne.f16r   r   r   )r-   r/   r2   r4   r6   r8   rn   r   r   r   r   r   r   r	   r   r   r   r
   r   )
rZ   r   r   opstringr   r   r`   sr   r   s
             r   test_fp16_comparison_ptx+TestOperatorModule.test_fp16_comparison_ptxI  s    #^#^#^5	 {{HKKhkk{{HKK)2 1r2YX6IBA$$R&9a% %$ 7$$s   4C
C.	c                    [         [        [        [        [        [
        4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4n[        R                  S[        R                  S[        R                  S[        R                  S[        R                  S[        R                  S0n[        X5       Hd  u  pEU R                  US9   [        S S  [         [#        [$        R&                  5      4n[)        XFSS	9u  pxU R+                  X5   U5        S S S 5        Mf     g ! , (       d  f       Mx  = f)
Nr   r   r   r   r   r   r   r   r   )r-   r/   r2   r4   r6   r8   rn   r   r   r   r   r   r   r   r   r	   r   r   rW   r   r
   r   )	rZ   r   r   r   r   r`   r   r   r   s	            r   test_fp16_int8_comparison_ptx0TestOperatorModule.test_fp16_int8_comparison_ptxZ  s     $^#^#^5	 {{HKKhkk{{HKK) KKKKKKKKKKKK/ ))FB$1r:bgg#67$R&9hlC0 %$ *$$s   >AE
E"	c                    [         [        [        [        [        [
        4n[        R                  [        R                  [        R                  [        R                  [        R                  [        R                  4n[        R                  [        R                  [        R                   [        R"                  [        R$                  4n[        R                  S[        R                  S[        R                  S[        R                  S[        R                  S[        R                  S0n[        R&                  " S5      S[        R&                  " S	5      S[        R&                  " S
5      S[        R&                  " S5      S0n[(        R*                  " [-        X5      U5       H  u  u  pgnU R/                  XxS9   [        R0                  " [        R2                  U5      n	[4        S S  [6        [9        U	5      4n
[;        XjSS9u  pXG   XY   -   nU R=                  X+5        S S S 5        M     g ! , (       d  f       M  = f)Nzsetp.gt.zsetp.ge.zsetp.lt.zsetp.le.zsetp.eq.z	setp.neu.r   f64r   r   f32r   r   r   r   )r-   r/   r2   r4   r6   r8   rn   r   r   r   r   r   r   rW   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r
   r   )rZ   r   r   types_promoter   opsuffixr   r`   r   arg2_tyr   r   r   s                r   (test_mixed_fp16_comparison_promotion_ptx;TestOperatorModule.test_mixed_fp16_comparison_promotion_ptxp  s   #^#^#^5	 {{HKKhkk{{HKK) 288RXXRZZ1KK
KK
KK
KK
KK
KK- HHW%uHHW%uHHY'HHY'0
 &--c).A.;=LHRb+..R81r:g#67$R&9lX%66c' ,+=++s   =A%H//
H>	r   )__name__
__module____qualname____firstlineno__rV   rk   rq   rv   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  __static_attributes____classcell__)r[   s   @r   rR   rR   o   s   /---12 : :" ?@* A* : :& ?@* A* : :  : : ?@& A&
 ?@& A& 3 3& 3 3, ( (  ) )  ?@& A&  ?@1 A1* ?@( A(r   rR   __main__)-numpyrW   numba.cuda.testingr   r   r   r   numbar   numba.core.typesr   r	   
numba.cudar
   rn   r   numba.np.numpy_supportr   r   r   r   r   r    r"   r$   r&   r(   r+   r-   r/   r2   r4   r6   r8   re   r?   rB   rG   rJ   rL   rN   rP   rR   r  mainr   r   r   <module>r     s    1 1  # "   - ,t$ % ,t$ %1
&
'


^( ^(B	 zMMO r   