ó
    ýZhØ(  ã                   ó¨  • S SK r S SKJrJrJrJrJrJrJrJ	r	J
r
  S SKr\R                  " S\R                  4S\R                  4/SS9r\	" \5      r\R                   =rr\R                   (       + r\
" \\\S9S 5       r\
" \\\S9S	 5       r\
" \\\S9S
 5       r\
" \\\S9S 5       r\
" \\\S9S 5       r\
" \\\S9S 5       r\
" \\\S9S 5       r\
" \\\S9S 5       r\R                  " S\ R8                  -  5      r\R
                  " S\ R8                  -  5      r\
" \\\S9S 5       r\
" \\\S9S 5       r \
" \\\S9S 5       r!SS jr"SS jr#g)é    N)	ÚconfigÚcudaÚfloat32Úfloat64Úuint32Úint64Úuint64Ú
from_dtypeÚjitÚs0Ús1T)Úalign)ÚforceobjÚloopliftÚnopythonc                 óø   • [        U5      n[        U5      nU[        S5      -   nX3[        S5      -	  -  [        S5      -  nX3[        S5      -	  -  [        S5      -  nX3[        S5      -	  -  nX0U   S'   X0U   S'   g	)
a�  Use SplitMix64 to generate an xoroshiro128p state from 64-bit seed.

This ensures that manually set small seeds don't result in a predictable
initial sequence from the random number generator.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: uint64
:param index: offset in states to update
:type seed: int64
:param seed: seed value to use when initializing state
l   |”~åf»q	 é   l   ¹eÉ9´Âz é   l   ëb&ì&‚&	 é   r   r   N)r   r	   r   )ÚstatesÚindexÚseedÚzs       Ú`/home/gothic/public_html/Fooocus/fooocus_env/lib64/python3.13/site-packages/numba/cuda/random.pyÚinit_xoroshiro128p_stater   .   s„   € ô �%‹L€EÜ�$‹<€DàŒvÐ(Ó)Ñ)€AØ	
”6˜"“:‰oÑ	¤&Ð);Ó"<Ñ<€AØ	
”6˜"“:‰oÑ	¤&Ð);Ó"<Ñ<€AØ	”&˜“*‰_Ñ€Aàˆ5�M�$ÑØˆ5�M�$Òó    c                 óZ   • [        U 5      n [        U5      nX-  U [        SU-
  5      -	  -  $ )zLeft rotate x by k bits.é@   )r	   r   )ÚxÚks     r   Úrotlr!   H   s0   € ô 	ˆq‹	€AÜˆq‹	€AØ‰F�qœF 2¨¡6›NÑ*Ñ+Ð+r   c                 óø   • [        U5      nX   S   nX   S   nX#-   nX2-  n[        [        U[        S5      5      5      U-  U[        S5      -  -  X   S'   [        [        U[        S5      5      5      X   S'   U$ )zåReturn the next random uint64 and advance the RNG in states[index].

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
:rtype: uint64
r   r   é7   é   é$   )r   r	   r!   r   )r   r   r   r   Úresults        r   Úxoroshiro128p_nextr'   P   sƒ   € ô �%‹L€EØ	‰�tÑ	€BØ	‰�tÑ	€BØ‰W€Fà�H€BÜ ¤ b¬&°«*Ó!5Ó6¸Ñ;¸rÄVÈBÃZÑ?OÑP€F�M�$ÑÜ ¤ b¬&°«*Ó!5Ó6€F�M�$Ñà€Mr   c                 óV  • [        U5      n[        S5      [        S5      4n[        S5      n[        S5      n[        S5       HU  n[        S5       HC  nX%   [        S5      [        U5      -  -  (       a  X0U   S   -  nX@U   S   -  n[	        X5        ME     MW     X0U   S'   X@U   S'   g	)
zÇAdvance the RNG in ``states[index]`` by 2**64 steps.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
l   ËzKWŸ`u l   "U.XC r   é   r   é   r   r   N)r   r	   Úranger   r'   )r   r   Újumpr   r   ÚiÚbs          r   Úxoroshiro128p_jumpr/   f   s¬   € ô �%‹L€EäÐ%Ó&¬Ð/AÓ(BÐC€Dä	�‹€BÜ	�‹€Bä�1ŽXˆÜ�r–ˆAØ‰wœ& ›)¤v¨a£yÑ0×1Ø˜U‘m DÑ)Ñ)�Ø˜U‘m DÑ)Ñ)�Ü˜vÖ-ó	 ñ ð ˆ5�M�$ÑØˆ5�M�$Òr   c                 ó|   • [        U 5      n U [        S5      -	  [        S5      [        S5      [        S5      -  -  -  $ )z7Convert uint64 to float64 value in the range [0.0, 1.0)é   r*   é5   )r	   r   r   ©r   s    r   Úuint64_to_unit_float64r4   �   s6   € ô 	ˆq‹	€AØ”˜“‰O¤¨£
¬f°Q«i¼6À"»:Ñ.EÑ FÑGÐGr   c                 ó@   • [        U 5      n [        [        U 5      5      $ )z7Convert uint64 to float32 value in the range [0.0, 1.0))r	   r   r4   r3   s    r   Úuint64_to_unit_float32r6   ˆ   s   € ô 	ˆq‹	€AÜÔ)¨!Ó,Ó-Ð-r   c                 ó@   • [        U5      n[        [        X5      5      $ )zæReturn a float32 in range [0.0, 1.0) and advance ``states[index]``.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
:rtype: float32
)r   r6   r'   ©r   r   s     r   Úxoroshiro128p_uniform_float32r9   �   ó   € ô �%‹L€EÜ!Ô"4°VÓ"CÓDÐDr   c                 ó@   • [        U5      n[        [        X5      5      $ )zæReturn a float64 in range [0.0, 1.0) and advance ``states[index]``.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
:rtype: float64
)r   r4   r'   r8   s     r   Úxoroshiro128p_uniform_float64r<   �   r:   r   r)   c                 óò   • [        U5      n[        X5      n[        X5      n[        R                  " [	        S5      * [        R
                  " U5      -  5      [        R                  " [        U-  5      -  nU$ )av  Return a normally distributed float32 and advance ``states[index]``.

The return value is drawn from a Gaussian of mean=0 and sigma=1 using the
Box-Muller transform.  This advances the RNG sequence by two steps.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
:rtype: float32
ç       @)r   r9   ÚmathÚsqrtr   ÚlogÚcosÚTWO_PI_FLOAT32©r   r   Úu1Úu2Úz0s        r   Úxoroshiro128p_normal_float32rH   ¯   ó\   € ô �%‹L€Eä	& vÓ	5€BÜ	& vÓ	5€Bä	�Š”G˜C“L�=¤4§8¢8¨B£<Ñ/Ó	0´4·8²8¼NÈRÑ<OÓ3PÑ	P€Bð €Ir   c                 óò   • [        U5      n[        X5      n[        X5      n[        R                  " [	        S5      * [        R
                  " U5      -  5      [        R                  " [        U-  5      -  nU$ )av  Return a normally distributed float32 and advance ``states[index]``.

The return value is drawn from a Gaussian of mean=0 and sigma=1 using the
Box-Muller transform.  This advances the RNG sequence by two steps.

:type states: 1D array, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type index: int64
:param index: offset in states to update
:rtype: float64
r>   )r   r9   r?   r@   r   rA   rB   ÚTWO_PI_FLOAT64rD   s        r   Úxoroshiro128p_normal_float64rL   È   rI   r   c                 ó   • U R                   S   n[        U5      n[        U5      nUS:¼  aS  [        U SU5        [        U5       H  n[	        U S5        M     [        SU5       H  nXS-
     X'   [	        X5        M     g g )Nr   r*   )Úshaper	   r   r+   r/   )r   r   Úsubsequence_startÚnÚ_r-   s         r   Úinit_xoroshiro128p_states_cpurR   á   s   € à�‰�Q‰€AÜ�$‹<€DÜÐ0Ó1ÐàˆAƒvÜ  ¨¨DÔ1ô Ð(Ö)ˆAÜ˜v qÖ)ñ *ô �q˜!–ˆAØ 1™u™ˆF‰IÜ˜vÖ)ò ð r   c                 ó€   • [         R                  " U R                  [        S9n[	        XAU5        U R                  XCS9  g)a…  Initialize RNG states on the GPU for parallel generators.

This initializes the RNG states so that each state in the array corresponds
subsequences in the separated by 2**64 steps from each other in the main
sequence.  Therefore, as long no CUDA thread requests more than 2**64
random numbers, all of the RNG states produced by this function are
guaranteed to be independent.

The subsequence_start parameter can be used to advance the first RNG state
by a multiple of 2**64 steps.

:type states: 1D DeviceNDArray, dtype=xoroshiro128p_dtype
:param states: array of RNG states
:type seed: uint64
:param seed: starting seed for list of generators
)rN   Údtype)ÚstreamN)ÚnpÚemptyrN   Úxoroshiro128p_dtyperR   Úcopy_to_device)r   r   rO   rU   Ú
states_cpus        r   Úinit_xoroshiro128p_statesr[   ô   s5   € ô& —’ §¡Ô4GÑH€JÜ! *Ð4EÔFà
×Ñ˜*ÐÒ4r   c                 óR   • [         R                  " U [        US9n[        XAX#5        U$ )aõ  Returns a new device array initialized for n random number generators.

This initializes the RNG states so that each state in the array corresponds
subsequences in the separated by 2**64 steps from each other in the main
sequence.  Therefore, as long no CUDA thread requests more than 2**64
random numbers, all of the RNG states produced by this function are
guaranteed to be independent.

The subsequence_start parameter can be used to advance the first RNG state
by a multiple of 2**64 steps.

:type n: int
:param n: number of RNG states to create
:type seed: uint64
:param seed: starting seed for list of generators
:type subsequence_start: uint64
:param subsequence_start:
:type stream: CUDA stream
:param stream: stream to run initialization kernel on
)rT   rU   )r   Údevice_arrayrX   r[   )rP   r   rO   rU   r   s        r   Úcreate_xoroshiro128p_statesr^     s)   € ô* ×Ò˜qÔ(;ÀFÑK€FÜ˜fÐ,=ÔFØ€Mr   )r   r   )$r?   Únumbar   r   r   r   r   r   r	   r
   r   ÚnumpyrV   rT   rX   Úxoroshiro128p_typeÚENABLE_CUDASIMÚ	_forceobjÚ	_loopliftÚ	_nopythonr   r!   r'   r/   r4   r6   r9   r<   ÚpirC   rK   rH   rL   rR   r[   r^   © r   r   Ú<module>rh      sý  ðÛ ÷$÷ $õ $ó ð4 —h’h  r§y¡yÐ 1°D¸"¿)¹)Ð3DÐEØ%)ñ+Ð áÐ 3Ó4Ð ð ×-Ñ-Ð -€	ˆIØ×%Ñ%Ô%€	ñ ˆi )°iÑ@ñó Aðñ2 ˆi )°iÑ@ñ,ó Að,ñ ˆi )°iÑ@ñó Aðñ* ˆi )°iÑ@ñó Aðñ4 ˆi )°iÑ@ñHó AðHñ ˆi )°iÑ@ñ.ó Að.ñ ˆi )°iÑ@ñ
Eó Að
Eñ ˆi )°iÑ@ñ
Eó Að
Eð —’˜A §¡™KÓ(€Ø—’˜A §¡™KÓ(€ñ ˆi )°iÑ@ñó Aðñ0 ˆi )°iÑ@ñó Aðñ0 ˆi )°iÑ@ñ*ó Að*ô$5õ2r   