o
    iP8                     @   s  d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZmZmZmZ d dlmZ d dlmZ e
 ZejZg Zedd	e jfg7 Zed
de jfg7 Zedde jfg7 Zg Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde jfg7 Zedde j fg7 Zedde j!fg7 Zedde j"fg7 Zedde j#fg7 Zed d!e j$fg7 Zed"d#e j%fg7 Zed$d%e j&fg7 Zed&d'e j'fg7 Zed(d)e j(fg7 Zed*d+e j)fg7 Zed,d-e j*fg7 Zed.d/e j+fg7 Zed0d1e j,fg7 Zed2d3e j-fg7 Zed4d5e j.fg7 Zed6d7e j/fg7 Zed8d9e j0fg7 Zed:d;e j1fg7 Zed<d=e j2fg7 Zed>d?e j3fg7 Zed@dAe j4fg7 Zi Z5dBe5d/< dCe5d7< dDe5d?< dEe5d< dFe5d%< dGe5d'< dHe5d#< g Z6e6dIdJe j7fg7 Z6e6dKdLe j8fg7 Z6e6dMdNe j9fg7 Z6e6dOdPe j:fg7 Z6e6dQdRe j;fg7 Z6e6dSdTe j<fg7 Z6i Z=dUe=dN< ee jej>ee jej>dVdW Z?eej@ejejdXdY ZAee jej>dZd[ ZBee j/ejCd\d] ZDee j+ejCd^d_ ZEee j%ejCd`da ZFee j'ejCdbdc ZGee j&ejCddde ZHee jejCdfdg ZIee jejCdhdi ZJee jejCdjdk ZKee j$ejCdldm ZLee jejCdndo ZMee j4ejCdpdq ZNdrds ZOdtdu ZPdvdw ZQdxdy ZRdzd{ ZSd|d} ZTd~d ZUdd ZVdd ZWeD ]\ZXZYZZe[eeYZ\e[eeXZ]eOeZee\ eOeZee] qleD ](\ZXZYZZe[eeYZ\e[eeXZ]eReZee\ eReZee] eSeZee] eSeZee] qe6D ](\ZXZYZZe[eeYZ\e[eeXZ]eVeZee\ eVeZee] eWeZee] eWeZee] qdd Z^e^ejej_ e^ejej` dd Zaeaejejb eaejejc dd Zdedejeje edejejf dd Zgegejejh egejeji dd Zjejejejk ejejejl eSe jleejl eSe jleejl dd Zmemejejn emejejo dS )    N)ir)typestypingcgutilstargetconfig)Registry)float32float64int64uint64)	libdevice)cudaZisnandZisnanfZisinfdZisinffZ	isfinitedZfinitefceilZceilffloorZfloorffabsZfabsfexpZexpfexpm1Zexpm1ferfZerfferfcZerfcfZtgammaZtgammaflgammaZlgammafsqrtZsqrtflogZlogflog2Zlog2flog10Zlog10flog1pZlog1pfacoshZacoshfacosZacosfcosZcosfcoshZcoshfasinhZasinhfasinZasinfsinZsinfsinhZsinhfatanZatanfatanhZatanhftanZtanftruncZtruncfZ	fast_cosfZ	fast_sinfZ	fast_tanfZ	fast_expfZ
fast_log2fZfast_log10fZ	fast_logfcopysignZ	copysignfatan2Zatan2fpowZpowffmodZfmodfhypotZhypotf	remainderZ
remainderfZ	fast_powfc                 C      |  tjdS )Nr   Zget_constantr   booleancontextbuildersigargs r5   b/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/cuda/mathimpl.pymath_isinf_isnan_intD   s   r7   c                 C   sx   | j rtttt}| tj|}|||S t||d  | j	
|d W d    n1 s0w   Y  |j| }|S )N   )zdivision by zero)fastmathr   	signaturer   get_functionr   Zfast_fdividefr   Zif_zeroZerror_modelZfp_zero_divisionZfdiv)r1   r2   r3   r4   implresr5   r5   r6   maybe_fast_truedivJ   s   

r>   c                 C   r-   )Nr8   r.   r0   r5   r5   r6   math_isfinite_intW   s   r?   c                 C      dd }|  ||||S )Nc                 S      t j| S N)r   fp16Zhsinxr5   r5   r6   fp16_sin^      zfp16_sin_impl.<locals>.fp16_sinZcompile_internal)r1   r2   r3   r4   rF   r5   r5   r6   fp16_sin_impl\      rI   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhcosrD   r5   r5   r6   fp16_cosf   rG   zfp16_cos_impl.<locals>.fp16_cosrH   )r1   r2   r3   r4   rK   r5   r5   r6   fp16_cos_impld   rJ   rL   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhlogrD   r5   r5   r6   fp16_logn   rG   zfp16_log_impl.<locals>.fp16_logrH   )r1   r2   r3   r4   rM   r5   r5   r6   fp16_log_impll   rJ   rN   c                 C   r@   )Nc                 S   rA   rB   )r   rC   Zhlog10rD   r5   r5   r6   
fp16_log10v   rG   z#fp16_log10_impl.<locals>.fp16_log10rH   )r1   r2   r3   r4   rO   r5   r5   r6   fp16_log10_implt   rJ   rP   c                 C   r@   )Nc                 S   rA   rB   )r   rC   Zhlog2rD   r5   r5   r6   	fp16_log2~   rG   z!fp16_log2_impl.<locals>.fp16_log2rH   )r1   r2   r3   r4   rQ   r5   r5   r6   fp16_log2_impl|   rJ   rR   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhexprD   r5   r5   r6   fp16_exp   rG   zfp16_exp_impl.<locals>.fp16_exprH   )r1   r2   r3   r4   rS   r5   r5   r6   fp16_exp_impl   rJ   rT   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhfloorrD   r5   r5   r6   
fp16_floor   rG   z#fp16_floor_impl.<locals>.fp16_floorrH   )r1   r2   r3   r4   rU   r5   r5   r6   fp16_floor_impl   rJ   rV   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhceilrD   r5   r5   r6   	fp16_ceil   rG   z!fp16_ceil_impl.<locals>.fp16_ceilrH   )r1   r2   r3   r4   rW   r5   r5   r6   fp16_ceil_impl   rJ   rX   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhsqrtrD   r5   r5   r6   	fp16_sqrt   rG   z!fp16_sqrt_impl.<locals>.fp16_sqrtrH   )r1   r2   r3   r4   rY   r5   r5   r6   fp16_sqrt_impl   rJ   rZ   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhabsrD   r5   r5   r6   	fp16_fabs   rG   z!fp16_fabs_impl.<locals>.fp16_fabsrH   )r1   r2   r3   r4   r[   r5   r5   r6   fp16_fabs_impl   rJ   r\   c                 C   r@   )Nc                 S   rA   rB   )r   rC   ZhtruncrD   r5   r5   r6   
fp16_trunc   rG   z#fp16_trunc_impl.<locals>.fp16_truncrH   )r1   r2   r3   r4   r]   r5   r5   r6   fp16_trunc_impl   rJ   r^   c                    s     fdd}t | | d S )Nc                    s4   |   ttj}|||}| ||tjtjS rB   )r;   r   r:   r   int32castr/   )r1   r2   r3   r4   libfunc_implresultlibfunctyr5   r6   lower_boolean_impl   s
   
z(impl_boolean.<locals>.lower_boolean_impllower)keyre   rd   rf   r5   rc   r6   impl_boolean   s   rj   c                        fdd}|S )Nc                    sR    }d }t kr| jrt j}|d urtt|}| |t	}|||S rB   )
r   r9   unarys_fastmathget__name__getattrr   r;   r   r:   r1   r2   r3   r4   Zactual_libfuncZfast_replacementra   rc   r5   r6   lower_unary_impl   s   


z.get_lower_unary_impl.<locals>.lower_unary_implr5   ri   re   rd   rq   r5   rc   r6   get_lower_unary_impl      rs   c                 C   sv   ddt jf}t|g D ]$\}}}| |kr/|tkrtt|}n	|tkr'tt|}t|||  S qtd|  d| d)NtanhtanhfImplementation of  for 
 not found)	mathru   unarysr   ro   r   r	   rs   RuntimeError)fnre   Z
tanh_implsfname64fname32ri   r<   r5   r5   r6   get_unary_impl_for_fn_and_ty   s   
r   c                 C   s   t | ||}t| || d S rB   )rs   rh   rr   r5   r5   r6   
impl_unary   s   r   c                    s    fdd}t | || d S )Nc                    sn   |j d tkr|j}n|j d tkr|j}nd}t|||d t }t	t
t
}|  |}|||gS )Nr   z<Only 64-bit integers are supported for generic unary int ops)r4   r
   sitofpr   uitofp	TypeErrorr   
DoubleTyper   r:   r	   r;   )r1   r2   r3   r4   convertmargra   rd   r5   r6   lower_unary_int_impl   s   z,impl_unary_int.<locals>.lower_unary_int_implrg   )ri   re   rd   r   r5   r   r6   impl_unary_int   s   r   c                    rk   )Nc                    sT    }d }t kr| jrt j}|d urtt|}| |t	}|||S rB   )
r   r9   binarys_fastmathrm   rn   ro   r   r;   r   r:   rp   rc   r5   r6   lower_binary_impl   s   

z0get_lower_binary_impl.<locals>.lower_binary_implr5   ri   re   rd   r   r5   rc   r6   get_lower_binary_impl   rt   r   c                 C   sd   t D ]$\}}}| |kr&|tkrtt|}n	|tkrtt|}t|||  S qtd|  d| d)Nrw   rx   ry   )binarysr   ro   r   r	   r   r|   )r}   re   r~   r   ri   r<   r5   r5   r6   get_binary_impl_for_fn_and_ty  s   
r   c                 C   s    t | ||}t| ||| d S rB   )r   rh   r   r5   r5   r6   impl_binary  s   r   c                    s     fdd}t | ||| d S )Nc                    sn   |j d tkr|j n|j d tkr|j nd}t| fdd|D }tttt}| 	|}|||S )Nr   z=Only 64-bit integers are supported for generic binary int opsc                    s   g | ]	} |t  qS r5   )r   r   ).0r   r   r5   r6   
<listcomp>#  s    zBimpl_binary_int.<locals>.lower_binary_int_impl.<locals>.<listcomp>)
r4   r
   r   r   r   r   r   r:   r	   r;   )r1   r2   r3   r4   r   ra   r   r   r6   lower_binary_int_impl  s   
z.impl_binary_int.<locals>.lower_binary_int_implrg   )ri   re   rd   r   r5   r   r6   impl_binary_int  s   r   c                    &    fdd}t tjtj| d S )Nc                    &   t tj}|  |}|||S rB   r   r:   r   r_   r;   )r1   r2   r3   r4   Zpowi_sigra   rc   r5   r6   lower_pow_impl_intE     
z(impl_pow_int.<locals>.lower_pow_impl_int)rh   rz   r)   r   r_   )re   rd   r   r5   rc   r6   impl_pow_intD     r   c                    s0   t d fdd}ttj| d S )N   c                    "   t }|  |}|||S rB   r   r:   r;   )r1   r2   r3   r4   Zmodf_sigra   rd   Zrettyre   r5   r6   lower_modf_implT     
z"impl_modf.<locals>.lower_modf_impl)r   ZUniTuplerh   rz   modf)re   rd   r   r5   r   r6   	impl_modfQ  s   r   c                    s4   t t jf fdd}ttj| d S )Nc                    r   rB   r   )r1   r2   r3   r4   Z	frexp_sigra   r   r5   r6   lower_frexp_implc  r   z$impl_frexp.<locals>.lower_frexp_impl)r   Tupler_   rh   rz   frexp)re   rd   r   r5   r   r6   
impl_frexp`  s   r   c                    r   )Nc                    r   rB   r   )r1   r2   r3   r4   Z	ldexp_sigra   rc   r5   r6   lower_ldexp_implp  r   z$impl_ldexp.<locals>.lower_ldexp_impl)rh   rz   ldexpr   r_   )re   rd   r   r5   rc   r6   
impl_ldexpo  r   r   c                    s"    fdd}t tj| d S )Nc                    sR   dd } fdd} fdd}t kr&jr&| }|dkr&| S | S )Nc                  S   s   t   } | jS rB   )r   ZConfigStacktopZcompute_capability)flagsr5   r5   r6   get_compute_capability~  s   zBimpl_tanh.<locals>.lower_tanh_impl.<locals>.get_compute_capabilityc                     s"   t } | }| S rB   r   )Ztanh_sigra   )r4   r2   r1   rd   re   r5   r6   tanh_impl_libdevice  r   z?impl_tanh.<locals>.lower_tanh_impl.<locals>.tanh_impl_libdevicec                     s0   t t  t  g} t | dd}| S )Nztanh.approx.f32 $0, $1;z=f,f)r   FunctionTypeZ	FloatTypeZ	InlineAsmcall)Zfntyasm)r4   r2   r5   r6   tanhf_impl_fastmath  s   z?impl_tanh.<locals>.lower_tanh_impl.<locals>.tanhf_impl_fastmath)      )r   r9   )r1   r2   r3   r4   r   r   r   ccrc   )r4   r2   r1   r6   lower_tanh_impl}  s   z"impl_tanh.<locals>.lower_tanh_impl)rh   rz   ru   )re   rd   r   r5   rc   r6   	impl_tanh|  s   r   c                    sF    fdd}t tj  | t tj  | t t  | d S )Nc                    s    fdd}|  ||||S )Nc                    s   |j dkr|jdkr d d S | j dkr,|j dkr, d d S t| j | j}t||j }t| j| j }||j  }|jdkrc|t||j  }||jt| 7 }| t| t	| d   S )Ng        g      ?y                y              ?)
realimagrz   r+   r)   r(   r   r   r   r!   )abZvabslenatZphasectyftyr5   r6   cpow_internal  s   
z3cpow_implement.<locals>.core.<locals>.cpow_internalrH   )r1   r2   r3   r4   r   r   r5   r6   core  s   zcpow_implement.<locals>.core)rh   operatorr)   ipow)r   r   r   r5   r   r6   cpow_implement  s   r   )prz   r   Zllvmliter   Z
numba.corer   r   r   r   Znumba.core.imputilsr   Znumba.typesr   r	   r
   r   Z
numba.cudar   Znumbar   registryrh   Zbooleansisnanisinfisfiniter{   r   r   r   r   r   r   r   gammar   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   rl   r   r'   r(   r)   r*   r+   r,   r   Integerr7   truedivr>   r?   Zfloat16rI   rL   rN   rP   rR   rT   rV   rX   rZ   r\   r^   rj   rs   r   r   r   r   r   r   r   r~   r   ri   ro   Zimpl32Zimpl64r   ZpowifZpowir   Zmodffr   r   Zfrexpfr   r   Zldexpfr   r   rv   ru   r   Z	complex64Z
complex128r5   r5   r5   r6   <module>   s   



















		
