Ë
    ÏÍ:jç  ã                   óø  — 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«      d4d„«       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed«      ej                   d4d„«       «       «       «       Zej                   e	ddg¬«       ed «      ej                   d4d!„«       «       «       «       Zej                   e	dg¬«       ed"«      ej                   d4d#„«       «       «       «       Zej                   e	ddg¬«       ed$«      ej                   d4d%„«       «       «       «       Zej                   ej                   ed&«      d4d'„«       «       «       Zej                   ed(«      d5d)„«       «       Zej                   e	dg¬«       ed*«      d4d+„«       «       «       Zej                   e	ddg¬«       ed,«      ej                   d4d-„«       «       «       «       Zej                   e	ddg¬«       ed.«      ej                   d4d/„«       «       «       «       Zej                   e	ddg¬«       ed0«      ej                   d4d1„«       «       «       «       Zej                   ed2«      d4d3„«       «       Z y)6é   )Úcoreé    ©Ú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        €€úi/home/mcse/projects/srt_converter/srt-converter-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>._decorator2   s#   ø€ ðˆð —}‘}¨$�}Ó/ˆŒØˆr   r,   r-   s   ` r   Ú_add_math_2arg_docstrr1   0   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>._decoratorC   s#   ø€ ð	ˆð —}‘}¨$�}Ó/ˆŒØˆr   r,   r-   s   ` r   Ú_add_math_3arg_docstrr4   A   s   ø€ ðœð œqõ ð Ðr   )Úint32Úint64Úuint32Úuint64)r	   z-most significant N bits of the 2N-bit productNc                 ó  — |j                  | «      } |j                  |«      }t        j                  | ||«      \  } }t        j                  |j                  j                  | j                  |j                  «      | j                  «      S ©N)Ú	to_tensorr   Úbinary_op_type_legalizationr   ÚbuilderÚcreate_umulhiÚhandler   ©ÚxÚyÚ	_semantics      r   ÚumulhirD   T   sl   € ð 	×Ñ˜AÓ€AØ×Ñ˜AÓ€AÜ×+Ñ+¨A¨q°)Ó<�D€A€qÜ�;‰;�y×(Ñ(×6Ñ6°q·x±xÀÇÁÓJÈAÏFÉFÓSÐSr   Úfp32Úfp64Úexponentialc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Ú
create_expr?   r   ©rA   rC   s     r   ÚexprK   ^   ó>   € ð
 	×Ñ˜AÓ€AÜ�;‰;�y×(Ñ(×3Ñ3°A·H±HÓ=¸q¿v¹vÓFÐFr   zexponential (base 2)c                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_exp2r?   r   rJ   s     r   Úexp2rO   g   ó>   € ð
 	×Ñ˜AÓ€AÜ�;‰;�y×(Ñ(×4Ñ4°Q·X±XÓ>ÀÇÁÓGÐGr   znatural logarithmc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Ú
create_logr?   r   rJ   s     r   ÚlogrS   p   rL   r   zlogarithm (base 2)c                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_log2r?   r   rJ   s     r   Úlog2rV   y   rP   r   Úcosinec                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Ú
create_cosr?   r   rJ   s     r   ÚcosrZ   ‚   rL   r   Úsinec                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Ú
create_sinr?   r   rJ   s     r   Úsinr^   ‹   rL   r   zfast square rootc                 óª   — |j                  | «      } t        j                  |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                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_precise_sqrtr?   r   rJ   s     r   Úsqrt_rnrd   �   s>   € ð
 	×Ñ˜AÓ€AÜ�;‰;�y×(Ñ(×<Ñ<¸Q¿X¹XÓFÈÏÉÓOÐOr   zinverse square rootc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_rsqrtr?   r   rJ   s     r   Úrsqrtrg   ¦   ó>   € ð
 	×Ñ˜AÓ€AÜ�;‰;�y×(Ñ(×5Ñ5°a·h±hÓ?ÀÇÁÓHÐHr   zabsolute valuec                 óÞ  — |j                  | «      } | j                  }|j                  «       rt        j                  | j
                  dt        j                  |¬«      }t        j                  |j                  j                  | j                  |j                  «      | j                  «      S |j                  «       rCt        j                  |j                  j                  | j                  «      | j                  «      S |j                  «       rCt        j                  |j                  j                  | j                  «      | j                  «      S |j!                  «       r| S J d|› �«       ‚)Né   )rC   zUnexpected dtype )r;   ÚdtypeÚis_fp8e4b15r   ÚfullÚshapeÚint8r   r=   Ú
create_andr?   r   Úis_floatingÚcreate_fabsÚis_int_signedÚcreate_iabsÚis_int_unsigned)rA   rC   rk   Úmasks       r   Úabsrw   ¯   s  € ð 	×Ñ˜AÓ€AØ�G‰G€EØ×ÑÔÜ�y‰y˜Ÿ™ $¬¯	©	¸YÔGˆÜ�{‰{˜9×,Ñ,×7Ñ7¸¿¹À$Ç+Á+ÓNÐPQ×PVÑPVÓWÐWØ	×	Ñ	Ô	Ü�{‰{˜9×,Ñ,×8Ñ8¸¿¹ÓBÀAÇFÁFÓKÐKØ	×	Ñ	Ô	Ü�{‰{˜9×,Ñ,×8Ñ8¸¿¹ÓBÀAÇFÁFÓKÐKØ	×	Ñ	Ô	 Øˆà1Ð)¨%¨Ð1Ó1ˆur   zfast divisionc                 ó–   — t        j                  |«      }|j                  | «      } |j                  |«      }|j                  | ||«      S r:   )r   Ú_unwrap_if_constexprr;   Úfdiv)rA   rB   Úieee_roundingrC   s       r   rz   rz   Â   sG   € ô ×-Ñ-¨mÓ<€MØ×Ñ˜AÓ€AØ×Ñ˜AÓ€AØ�>‰>˜!˜Q Ó.Ð.r   z<precise division (rounding to nearest wrt the IEEE standard)c                 ó  — |j                  | «      } |j                  |«      }t        j                  | ||«      \  } }t        j                  |j                  j                  | j                  |j                  «      | j                  «      S r:   )r;   r   r<   r   r=   Úcreate_precise_divfr?   r   r@   s      r   Údiv_rnr~   Ë   so   € ð 	×Ñ˜AÓ€AØ×Ñ˜AÓ€AÜ×+Ñ+¨A¨q°)Ó<�D€A€qÜ�;‰;�y×(Ñ(×<Ñ<¸Q¿X¹XÀqÇxÁxÓPÐRS×RXÑRXÓYÐYr   zerror functionc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Ú
create_erfr?   r   rJ   s     r   Úerfr�   Õ   rL   r   Úfloorc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_floorr?   r   rJ   s     r   r‚   r‚   Þ   rh   r   Úceilc                 óª   — |j                  | «      } t        j                  |j                  j	                  | j
                  «      | j                  «      S r:   )r;   r   r   r=   Úcreate_ceilr?   r   rJ   s     r   r…   r…   ç   rP   r   zfused multiply-addc                 ó¶  — |j                  | «      } |j                  |«      }|j                  |«      }t        j                  | ||«      \  } }t        j                  || |«      \  }} t        j                  |||«      \  }}t        j                  |j                  j                  | j                  |j                  |j                  «      | j                  «      S r:   )r;   r   r<   r   r=   Ú
create_fmar?   r   )rA   rB   ÚzrC   s       r   Úfmar‹   ð   sµ   € ð 	×Ñ˜AÓ€AØ×Ñ˜AÓ€AØ×Ñ˜AÓ€AÜ×+Ñ+¨A¨q°)Ó<�D€A€qÜ×+Ñ+¨A¨q°)Ó<�D€A€qÜ×+Ñ+¨A¨q°)Ó<�D€A€qÜ�;‰;�y×(Ñ(×3Ñ3°A·H±H¸a¿h¹hÈÏÉÓQÐST×SYÑSYÓZÐZr   r:   )FN)!Ú r   Ú	functoolsr   Útypingr   ÚTypeVarr   Ústrr!   ÚCallabler.   r1   r4   Ú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òTó Hó =ó ðTð ‡�Ù�f˜fÐ%Ô&Ù�}Ó%Ø×ÑòGó ó &ó 'ó ðGð
 ‡�Ù�f˜fÐ%Ô&ÙÐ-Ó.Ø×ÑòHó ó /ó 'ó ðHð
 ‡�Ù�f˜fÐ%Ô&ÙÐ*Ó+Ø×ÑòGó ó ,ó 'ó ðGð
 ‡�Ù�f˜fÐ%Ô&ÙÐ+Ó,Ø×ÑòHó ó -ó 'ó ðHð
 ‡�Ù�f˜fÐ%Ô&Ù�xÓ Ø×ÑòGó ó !ó 'ó ðGð
 ‡�Ù�f˜fÐ%Ô&Ù�vÓØ×ÑòGó ó ó 'ó ðGð
 ‡�Ù�f˜fÐ%Ô&ÙÐ)Ó*Ø×ÑòHó ó +ó 'ó ðHð
 ‡�Ù�f�XÔÙÐXÓYØ×ÑòPó ó Zó ó ðPð
 ‡�Ù�f˜fÐ%Ô&ÙÐ,Ó-Ø×ÑòIó ó .ó 'ó ðIð
 ×ÑØ‡�ÙÐ'Ó(ò2ó )ó ó ð2ð  ‡�Ù�Ó'ò/ó (ó ð/ð ‡�Ù�f�XÔÙÐUÓVòZó Wó ó ðZð ‡�Ù�f˜fÐ%Ô&ÙÐ'Ó(Ø×ÑòGó ó )ó 'ó ðGð
 ‡�Ù�f˜fÐ%Ô&Ù�wÓØ×ÑòIó ó  ó 'ó ðIð
 ‡�Ù�f˜fÐ%Ô&Ù�vÓØ×ÑòHó ó ó 'ó ðHð
 ‡�ÙÐ+Ó,ò[ó -ó ñ[r   