Ë
    7^(h  ã                   ó  — d dl mZ d dl mZ ddlmZ ddlmZ  ej                  d«      Zdee	   defd	„Z
d
e	dej                  egef   fd„Zd
e	dej                  egef   fd„Zd
e	dej                  egef   fd„Zej                   e
g d¢¬«       ed«      d5d„«       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d„«       «       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d„«       «       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d„«       «       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d„«       «       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d„«       «       «       «       Zej                   e
ddg¬«       ed«      ej"                  d5d „«       «       «       «       Zej                   e
ddg¬«       ed!«      ej"                  d5d"„«       «       «       «       Zej                   e
dg¬«       ed#«      ej"                  d5d$„«       «       «       «       Zej                   e
ddg¬«       ed%«      ej"                  d5d&„«       «       «       «       Zej"                  ej                   ed'«      d5d(„«       «       «       Zej                   ed)«      d6d*„«       «       Zej                   e
dg¬«       ed+«      d5d,„«       «       «       Zej                   e
ddg¬«       ed-«      ej"                  d5d.„«       «       «       «       Zej                   e
ddg¬«       ed/«      ej"                  d5d0„«       «       «       «       Zej                   e
ddg¬«       ed1«      ej"                  d5d2„«       «       «       «       Z ej                   ed3«      d5d4„«       «       Z!y)7é   )Úcore)Úsemanticé    ©Úwraps)ÚListÚTÚdtypesÚreturnc                 ó   ‡ — ˆ fd„}|S )al  
    We're following libdevice's convention to check accepted data types for math functions.
    It is not a good practice to support all data types as accelerators/GPUs don't support
    many float16 and bfloat16 math operations.
    We should let the users know that they are using and invoke explicit cast to convert
    the data type to the supported one.
    c                 ó2   •‡ — t        ‰ «      ˆˆ fd„«       }|S )Nc                  ój  •— t        | «      t        |j                  «       «      z   }|D �cg c]  }t        |t        j                  «      sŒ|‘Œ! c}D ]S  }|j
                  j                  j                  ‰vsŒ&t        d‰› d|j
                  j                  j                  › �«      ‚  ‰| i |¤ŽS c c}w )NzExpected dtype z	 but got )	ÚlistÚvaluesÚ
isinstancer   ÚtensorÚtypeÚscalarÚnameÚ
ValueError)ÚargsÚkwargsÚall_argsÚaÚargr
   Úfns        €€úR/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/triton/language/math.pyÚcheckz,_check_dtype.<locals>.wrapper.<locals>.check   sœ   ø€ ô ˜D“z¤D¨¯©«Ó$9Ñ9ˆHØ#+ÖJ˜a¬z¸!¼T¿[¹[Õ/IšÒJò `�Ø—8‘8—?‘?×'Ñ'¨vÒ5Ü$ °v°h¸iÈÏÉÏÉ×H\ÑH\ÐG]Ð%^Ó_Ð_ð`ñ �tÐ&˜vÑ&Ð&ùò Ks   «B0ÁB0r   )r   r   r
   s   ` €r   Úwrapperz_check_dtype.<locals>.wrapper   s    ù€ ä	ˆr‹ô	'ó 
ð	'ð ˆó    © )r
   r   s   ` r   Ú_check_dtyper"   	   s   ø€ ôð €Nr    r   c                 ó,   ‡ — dt         dt         fˆ fd„}|S )NÚfuncr   c                 ó:   •— d}|j                  ‰¬«      | _        | S )Nzk
    Computes the element-wise {name} of :code:`x`.

    :param x: the input values
    :type x: Block
    ©r   ©ÚformatÚ__doc__©r$   Údocstrr   s     €r   Ú
_decoratorz)_add_math_1arg_docstr.<locals>._decorator$   s#   ø€ ðˆð —}‘}¨$�}Ó/ˆŒØˆr    ©r	   ©r   r,   s   ` r   Ú_add_math_1arg_docstrr/   "   s   ø€ ðœð œqõ ð Ðr    c                 ó,   ‡ — dt         dt         fˆ fd„}|S )Nr$   r   c                 ó:   •— d}|j                  ‰¬«      | _        | S )Nz«
    Computes the element-wise {name} of :code:`x` and :code:`y`.

    :param x: the input values
    :type x: Block
    :param y: the input values
    :type y: Block
    r&   r'   r*   s     €r   r,   z)_add_math_2arg_docstr.<locals>._decorator3   s#   ø€ ðˆð —}‘}¨$�}Ó/ˆŒØˆr    r-   r.   s   ` r   Ú_add_math_2arg_docstrr2   1   s   ø€ ð
œð 
œqõ 
ð Ðr    c                 ó,   ‡ — dt         dt         fˆ fd„}|S )Nr$   r   c                 ó:   •— d}|j                  ‰¬«      | _        | S )Nzé
    Computes the element-wise {name} of :code:`x`, :code:`y`, and :code:`z`.

    :param x: the input values
    :type x: Block
    :param y: the input values
    :type y: Block
    :param z: the input values
    :type z: Block
    r&   r'   r*   s     €r   r,   z)_add_math_3arg_docstr.<locals>._decoratorD   s#   ø€ ð	ˆð —}‘}¨$�}Ó/ˆŒØˆr    r-   r.   s   ` r   Ú_add_math_3arg_docstrr5   B   s   ø€ ðœð œqõ ð Ðr    )Úint32Úint64Úuint32Úuint64)r
   z-most significant N bits of the 2N-bit productNc                 ó  — t        j                  | |«      } t        j                  ||«      }t        j                  | ||«      \  } }t        j                  |j                  | j                  |j                  «      | j                  «      S ©N)r   Ú	to_tensorr   Úbinary_op_type_legalizationr   Úcreate_umulhiÚhandler   ©ÚxÚyÚ_builders      r   ÚumulhirD   U   sj   € ô 	×Ñ˜1˜hÓ'€AÜ×Ñ˜1˜hÓ'€AÜ×+Ñ+¨A¨q°(Ó;�D€A€qÜ�;‰;�x×-Ñ-¨a¯h©h¸¿¹ÓAÀ1Ç6Á6ÓJÐJr    Úfp32Úfp64Úexponentialc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Ú
create_expr?   r   ©rA   rC   s     r   ÚexprK   _   ó:   € ô
 	×Ñ˜1˜hÓ'€AÜ�;‰;�x×*Ñ*¨1¯8©8Ó4°a·f±fÓ=Ð=r    zexponential (base 2)c                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_exp2r?   r   rJ   s     r   Úexp2rO   h   ó:   € ô
 	×Ñ˜1˜hÓ'€AÜ�;‰;�x×+Ñ+¨A¯H©HÓ5°q·v±vÓ>Ð>r    znatural logarithmc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Ú
create_logr?   r   rJ   s     r   ÚlogrS   q   rL   r    zlogarithm (base 2)c                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_log2r?   r   rJ   s     r   Úlog2rV   z   rP   r    Úcosinec                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Ú
create_cosr?   r   rJ   s     r   ÚcosrZ   ƒ   rL   r    Úsinec                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Ú
create_sinr?   r   rJ   s     r   Úsinr^   Œ   rL   r    zfast square rootc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_sqrtr?   r   rJ   s     r   Úsqrtra   •   rP   r    z?precise square root (rounding to nearest wrt the IEEE standard)c                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_precise_sqrtr?   r   rJ   s     r   Úsqrt_rnrd   ž   s:   € ô
 	×Ñ˜1˜hÓ'€AÜ�;‰;�x×3Ñ3°A·H±HÓ=¸q¿v¹vÓFÐFr    zinverse square rootc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_rsqrtr?   r   rJ   s     r   Úrsqrtrg   §   ó:   € ô
 	×Ñ˜1˜hÓ'€AÜ�;‰;�x×,Ñ,¨Q¯X©XÓ6¸¿¹Ó?Ð?r    zabsolute valuec                 ó¬  — t        j                  | |«      } | j                  }|j                  «       rut	        j
                  | j                  dt        j                  |¬«      }t	        j                  |j                  | j                  |j                  «      | j                  «      S |j                  «       r9t	        j                  |j                  | j                  «      | j                  «      S |j                  «       r9t	        j                  |j                  | j                  «      | j                  «      S |j!                  «       r| S J d|› �«       ‚)Né   )rC   zUnexpected dtype )r   r<   ÚdtypeÚis_fp8e4b15r   ÚfullÚshapeÚint8r   Ú
create_andr?   r   Úis_floatingÚcreate_fabsÚis_int_signedÚcreate_iabsÚis_int_unsigned)rA   rC   rk   Úmasks       r   Úabsrw   °   sô   € ô 	×Ñ˜1˜hÓ'€AØ�G‰G€EØ×ÑÔÜ�y‰y˜Ÿ™ $¬¯	©	¸HÔEˆÜ�{‰{˜8×.Ñ.¨q¯x©x¸¿¹ÓEÀqÇvÁvÓNÐNØ	×	Ñ	Ô	Ü�{‰{˜8×/Ñ/°·±Ó9¸1¿6¹6ÓBÐBØ	×	Ñ	Ô	Ü�{‰{˜8×/Ñ/°·±Ó9¸1¿6¹6ÓBÐBØ	×	Ñ	Ô	 Øˆà1Ð)¨%¨Ð1Ó1ˆur    zfast divisionc                 ó´   — t        j                  |«      }t        j                  | |«      } t        j                  ||«      }t        j                  | |||«      S r;   )r   Ú_constexpr_to_valuer   r<   Úfdiv)rA   rB   Úieee_roundingrC   s       r   rz   rz   Ã   sM   € ô ×,Ñ,¨]Ó;€MÜ×Ñ˜1˜hÓ'€AÜ×Ñ˜1˜hÓ'€AÜ�=‰=˜˜A˜}¨hÓ7Ð7r    z<precise division (rounding to nearest wrt the IEEE standard)c                 ó  — t        j                  | |«      } t        j                  ||«      }t        j                  | ||«      \  } }t        j                  |j                  | j                  |j                  «      | j                  «      S r;   )r   r<   r   r=   r   Úcreate_precise_divfr?   r   r@   s      r   Údiv_rnr~   Ì   sj   € ô 	×Ñ˜1˜hÓ'€AÜ×Ñ˜1˜hÓ'€AÜ×+Ñ+¨A¨q°(Ó;�D€A€qÜ�;‰;�x×3Ñ3°A·H±H¸a¿h¹hÓGÈÏÉÓPÐPr    zerror functionc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Ú
create_erfr?   r   rJ   s     r   Úerfr�   Ö   rL   r    Úfloorc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_floorr?   r   rJ   s     r   r‚   r‚   ß   rh   r    Úceilc                 ó    — t        j                  | |«      } t        j                  |j	                  | j
                  «      | j                  «      S r;   )r   r<   r   r   Úcreate_ceilr?   r   rJ   s     r   r…   r…   è   rP   r    zfused multiply-addc                 óÀ  — t        j                  | |«      } t        j                  ||«      }t        j                  ||«      }t        j                  | ||«      \  } }t        j                  || |«      \  }} t        j                  |||«      \  }}t        j                  |j                  | j                  |j                  |j                  «      | j                  «      S r;   )r   r<   r   r=   r   Ú
create_fmar?   r   )rA   rB   ÚzrC   s       r   Úfmar‹   ñ   s²   € ô 	×Ñ˜1˜hÓ'€AÜ×Ñ˜1˜hÓ'€AÜ×Ñ˜1˜hÓ'€AÜ×+Ñ+¨A¨q°(Ó;�D€A€qÜ×+Ñ+¨A¨q°(Ó;�D€A€qÜ×+Ñ+¨A¨q°(Ó;�D€A€qÜ�;‰;�x×*Ñ*¨1¯8©8°Q·X±X¸q¿x¹xÓHÈ!Ï&É&ÓQÐQr    r;   )FN)"Ú r   r   Ú	functoolsr   Útypingr   ÚTypeVarr	   Ústrr"   ÚCallabler/   r2   r5   ÚbuiltinrD   Ú_tensor_member_fnrK   rO   rS   rV   rZ   r^   ra   rd   rg   rw   rz   r~   r�   r‚   r…   r‹   r!   r    r   ú<module>r”      sÕ  ðÝ Ý Ý Ý à€D‡L�L�Ó€ð˜˜c™ð  qó ð2 ð ¨¯©°q°c¸1°fÑ(=ó ð ð ¨¯©°q°c¸1°fÑ(=ó ð" ð ¨¯©°q°c¸1°fÑ(=ó ð& ‡�ÙÒ;Ô<ÙÐFÓGòKó Hó =ó ðKð ‡�Ù�f˜fÐ%Ô&Ù�}Ó%Ø×Ñò>ó ó &ó 'ó ð>ð
 ‡�Ù�f˜fÐ%Ô&ÙÐ-Ó.Ø×Ñò?ó ó /ó 'ó ð?ð
 ‡�Ù�f˜fÐ%Ô&ÙÐ*Ó+Ø×Ñò>ó ó ,ó 'ó ð>ð
 ‡�Ù�f˜fÐ%Ô&ÙÐ+Ó,Ø×Ñò?ó ó -ó 'ó ð?ð
 ‡�Ù�f˜fÐ%Ô&Ù�xÓ Ø×Ñò>ó ó !ó 'ó ð>ð
 ‡�Ù�f˜fÐ%Ô&Ù�vÓØ×Ñò>ó ó ó 'ó ð>ð
 ‡�Ù�f˜fÐ%Ô&ÙÐ)Ó*Ø×Ñò?ó ó +ó 'ó ð?ð
 ‡�Ù�f�XÔÙÐXÓYØ×ÑòGó ó Zó ó ðGð
 ‡�Ù�f˜fÐ%Ô&ÙÐ,Ó-Ø×Ñò@ó ó .ó 'ó ð@ð
 ×ÑØ‡�ÙÐ'Ó(ò2ó )ó ó ð2ð  ‡�Ù�Ó'ò8ó (ó ð8ð ‡�Ù�f�XÔÙÐUÓVòQó Wó ó ðQð ‡�Ù�f˜fÐ%Ô&ÙÐ'Ó(Ø×Ñò>ó ó )ó 'ó ð>ð
 ‡�Ù�f˜fÐ%Ô&Ù�wÓØ×Ñò@ó ó  ó 'ó ð@ð
 ‡�Ù�f˜fÐ%Ô&Ù�vÓØ×Ñò?ó ó ó 'ó ð?ð
 ‡�ÙÐ+Ó,òRó -ó ñRr    