Ë
    7^(hú  ã                   ó¼  — d dl mZ ddlmZ ddlmZ dZeefdej                  fd„«       Zeefdej                  fd„«       Z	eefdej                  fd	„«       Z
eefdej                  fd
„«       Zed„ «       Zeefdej                  fd„«       Zeefdej                  fd„«       Zed„ «       Zeefdej                  fd„«       Zeefdej                  fd„«       Zy)é   )Újité   )Úcore)Úmathé
   Ún_roundsc                 ó@  — | j                   t        j                  k(  r	d}d}d}	d}
n9t        j                  | j                   t        j                  k(  d«       d}d}d}	d	}
t        j
                  |«      D ]¢  }|	}|
}| |}}t        j                  ||«      |z  |z  } t        j                  ||«      |z  |z  }t        j                  ||d
¬«      }t        j                  ||d
¬«      }t        j                  ||d
¬«      }t        j                  ||d
¬«      }Œ¤ | |||fS )zV
    Run `n_rounds` rounds of Philox for state (c0, c1, c2, c3) and key (k0, k1).
    l   ¹yn< l   ….Ïv l   S¢$ l   W= z"dtype not supported in philox_impll   |”~åf»q	 l   ;'•	:=[ l   “l˜B;: l   W$*Ž	ÔR F)Úsanitize_overflow)
ÚdtypeÚtlÚuint32Ústatic_assertÚuint64Ústatic_ranger   ÚumulhiÚmulÚadd)Úc0Úc1Úc2Úc3Úk0Úk1r   ÚPHILOX_KEY_AÚPHILOX_KEY_BÚPHILOX_ROUND_AÚPHILOX_ROUND_BÚ_ÚAÚBÚ_c0Ú_c2s                   úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/triton/language/random.pyÚphilox_implr$      s  € ð
 
‡x�x”2—9‘9ÒØ%/ˆØ%/ˆØ'1ˆØ'1‰ä
×Ñ˜Ÿ™¤R§Y¡YÑ.Ð0TÔUØ%7ˆØ%7ˆØ'9ˆØ'9ˆä�_‰_˜XÓ&ò ?ˆð ˆØˆØ�rˆSˆÜ�[‰[˜˜CÓ  2Ñ%¨Ñ*ˆÜ�[‰[˜˜CÓ  2Ñ%¨Ñ*ˆÜ�V‰V�A�s¨eÔ4ˆÜ�V‰V�A�s¨eÔ4ˆä�V‰V�B˜¸Ô>ˆÜ�V‰V�B˜¸Ô>‰ð?ð ˆr�2�rˆ>Ðó    c           	      ó  — t        j                  | «      } t        j                  | j                  j	                  «       «       | j                  t         j                  «      } t        j                  |«      }t        j                  |«      }t        j                  |«      }t        j                  |«      }t        j                  |j                  j                  «      dk(  rXt         j                  }| dz	  dz  j                  t         j                  «      }| dz  j                  t         j                  «      }njt        j                  t        j                  |j                  j                  «      dk(  d«       t         j                  }t        j                  dd|¬«      }| }|j                  |d¬	«      }|j                  |d¬	«      }|j                  |d¬	«      }|j                  |d¬	«      }t        |||||||«      S )
Né    l   ÿÿ é@   z bitwidth not supported in philox)r   é    )r   T©Úbitcast)r   Ú	to_tensorr   r   Úis_intÚtor   Ú	constexprÚprimitive_bitwidthr   Úfullr$   )	Úseedr   r   r   r   r   Ú	int_dtypeÚseed_hiÚseed_los	            r#   Úphiloxr6   -   sw  € ä�<‰<˜Ó€DÜ×Ñ�T—Z‘Z×&Ñ&Ó(Ô)Ø�7‰7”2—9‘9Ó€DÜ	�‰�bÓ	€BÜ	�‰�bÓ	€BÜ	�‰�bÓ	€BÜ	�‰�bÓ	€BÜ	‡|�|�B—H‘H×/Ñ/Ó0°BÒ6Ü—I‘Iˆ	Ø˜B‘J *Ñ,×0Ñ0´·±Ó;ˆØ˜*Ñ$×(Ñ(¬¯©Ó3‰ä
×ÑœŸ™ b§h¡h×&AÑ&AÓBÀbÑHÐJlÔmÜ—I‘Iˆ	Ü—'‘'˜% ¨)Ô4ˆØˆØ	�‰ˆy $ˆÓ	'€BØ	�‰ˆy $ˆÓ	'€BØ	�‰ˆy $ˆÓ	'€BØ	�‰ˆy $ˆÓ	'€BÜ�r˜2˜r 2 w°¸ÓBÐBr%   c                 ó*   — t        | ||«      \  }}}}|S )aq  
    Given a :code:`seed` scalar and an :code:`offset` block, returns a single
    block of random :code:`int32`.

    If you need multiple streams of random numbers,
    using `randint4x` is likely to be faster than calling `randint` 4 times.

    :param seed: The seed for generating random numbers.
    :param offset: The offsets to generate random numbers for.
    )Ú	randint4x)r2   Úoffsetr   Úretr   s        r#   Úrandintr;   F   s   € ô ˜T 6¨8Ó4�L€CˆˆAˆqØ€Jr%   c                 ó,   — |dz  }t        | |||||«      S )aU  
    Given a :code:`seed` scalar and an :code:`offset` block, returns four
    blocks of random :code:`int32`.

    This is the maximally efficient entry point
    to Triton's Philox pseudo-random number generator.

    :param seed: The seed for generating random numbers.
    :param offsets: The offsets to generate random numbers for.
    r)   )r6   )r2   r9   r   Ú_0s       r#   r8   r8   V   s"   € ð 
�!‰€BÜ�$˜  B¨¨HÓ5Ð5r%   c                 ó€  — t        j                  | j                  t         j                  k(  «      s0t        j                  | j                  t         j                  k(  «      r$| j                  t         j                  d¬«      } d}n˜t        j                  t        j                  | j                  t         j                  k(  «      xs0 t        j                  | j                  t         j                  k(  «      «       | j                  t         j                  d¬«      } d}t        j                  | dk  |  dz
  | «      } | |z  S )zo
    Numerically stable function to convert a random uint into a random float uniformly sampled in [0, 1).
    Tr*   gýïÿÿÿ=g   Àÿÿÿ;r)   r   )
r   r/   r   r   Úint32r.   r   r   Úint64Úwhere)ÚxÚscales     r#   Úuint_to_uniform_floatrD   t   sÓ   € ô 
‡|�|�A—G‘GœrŸy™yÑ(Ô)¬R¯\©\¸!¿'¹'ÄRÇXÁXÑ:MÔ-Nà�D‰D”—‘ 4ˆDÓ(ˆØ ‰ä
×ÑœŸ™ a§g¡g´·±Ñ&:Ó;Ò`¼r¿|¹|ÈAÏGÉGÔWY×W_ÑW_ÑL_Ó?`ÔaØ�D‰D”—‘ 4ˆDÓ(ˆØ&ˆÜ
�‰��Q‘˜˜˜Q™ Ó"€AØˆu‰9Ðr%   c                 ó2   — t        | ||«      }t        |«      S )zþ
    Given a :code:`seed` scalar and an :code:`offset` block,
    returns a block of random :code:`float32` in :math:`U(0, 1)`.

    :param seed: The seed for generating random numbers.
    :param offsets: The offsets to generate random numbers for.
    )r;   rD   )r2   r9   r   Úsources       r#   ÚrandrG   ˆ   s   € ô �T˜6 8Ó,€FÜ  Ó(Ð(r%   c                 óŠ   — t        | ||«      \  }}}}t        |«      }t        |«      }t        |«      }	t        |«      }
|||	|
fS )a   
    Given a :code:`seed` scalar and an :code:`offsets` block,
    returns 4 blocks of random :code:`float32` in :math:`U(0, 1)`.

    :param seed: The seed for generating random numbers.
    :param offsets: The offsets to generate random numbers for.
    )r8   rD   )r2   Úoffsetsr   Úi1Úi2Úi3Úi4Úu1Úu2Úu3Úu4s              r#   Úrand4xrR   •   sP   € ô ˜t W¨hÓ7�N€BˆˆB�Ü	˜rÓ	"€BÜ	˜rÓ	"€BÜ	˜rÓ	"€BÜ	˜rÓ	"€BØˆr�2�rˆ>Ðr%   c                 óî   — t        j                  d| «      } d|z  }t        j                  dt        j                  | «      z  «      }|t        j
                  |«      z  |t        j                  |«      z  fS )zBox-Muller transformgH¯¼šò×z>g-DTû!@g       À)r   Úmaximumr   ÚsqrtÚlogÚcosÚsin)rN   rO   ÚthÚrs       r#   Úpair_uniform_to_normalr[   «   s^   € ô 
�‰�F˜BÓ	€BØ	˜RÑ	€BÜ�	‰	�$œŸ™ "›Ñ%Ó&€AØŒt�x‰x˜‹|Ñ˜Q¤§¡¨"£Ñ-Ð-Ð-r%   c                 ót   — t        | ||«      \  }}}}t        |«      }t        |«      }t        ||«      \  }}|S )a  
    Given a :code:`seed` scalar and an :code:`offset` block,
    returns a block of random :code:`float32` in :math:`\mathcal{N}(0, 1)`.

    :param seed: The seed for generating random numbers.
    :param offsets: The offsets to generate random numbers for.
    )r8   rD   r[   )	r2   r9   r   rJ   rK   r   rN   rO   Ún1s	            r#   Úrandnr^   ´   sC   € ô ˜T 6¨8Ó4�L€BˆˆAˆqÜ	˜rÓ	"€BÜ	˜rÓ	"€BÜ" 2 rÓ*�E€BˆØ€Ir%   c                 ón   — t        | ||«      \  }}}}t        ||«      \  }}t        ||«      \  }	}
|||	|
fS )a	  
    Given a :code:`seed` scalar and an :code:`offset` block,
    returns 4 blocks of random :code:`float32` in :math:`\mathcal{N}(0, 1)`.

    :param seed: The seed for generating random numbers.
    :param offsets: The offsets to generate random numbers for.
    )rR   r[   )r2   r9   r   rN   rO   rP   rQ   r]   Ún2Ún3Ún4s              r#   Úrandn4xrc   Ä   sH   € ô ˜D &¨(Ó3�N€BˆˆB�Ü# B¨Ó+�F€BˆÜ# B¨Ó+�F€BˆØˆr�2�rˆ>Ðr%   N)Úruntime.jitr   Ú r   r   r   ÚN_ROUNDS_DEFAULTr/   r$   r6   r;   r8   rD   rG   rR   r[   r^   rc   © r%   r#   ú<module>rh      sP  ðÝ Ý Ý àÐ ð ØAQñ °"·,±,ò ó ðð@ Ø:Jñ C¨2¯<©<ò Có ðCð0 Ø3Cñ  B§L¡Lò ó ðð Ø5Eñ 6 b§l¡lò 6ó ð6ð: ñó ðð& Ø0@ñ 	) §¡ò 	)ó ð	)ð Ø3Cñ  B§L¡Lò ó ðð* ñ.ó ð.ð Ø1Añ  "§,¡,ò ó ðð Ø3Cñ  B§L¡Lò ó ñr%   