+
     þÎjøy  ã                   ó&  € R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIt^ RI	t	^ RI	H
t
 ^ RIHtHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt  ]! ]R4      ! R4      t R t"R t#R t$ ! R R]
PJ                  4      t& ! R R]&4      t'] R 4       t( ! R R]&4      t) ! R R]*4      t+ ! R R]&]PX                  4      t- ! R R]&]PX                  4      t.R'R lt/R'R  lt0R! t1R" t2R#t3R$ t4R(R% lt5R& t6R#   ]! d    R t  Lži ; i))zÑ
A CUDA ND Array is recognized by checking the __cuda_memory__ attribute
on the object.  If it exists and evaluate to True, it must define shape,
strides, dtype and size attributes similar to a NumPy ndarray.
N)Úc_void_p)Ú_devicearray)ÚdevicesÚ
dummyarray)Údriver)ÚtypesÚconfig)Úto_fixed_tuple)Únumpy_version)Únumpy_support)Úprepare_shape_strides_dtype)ÚNumbaPerformanceWarning)ÚwarnÚ	lru_cachec                 ó   € V # ©N© )Úfuncs   &ÚT/opt/data/home/.local/lib/python3.14/site-packages/numba/cuda/cudadrv/devicearray.pyr   r      s   € Øˆó    c                ó   € \        V RR4      # )z$Check if an object is a CUDA ndarrayÚ__cuda_ndarray__F)Úgetattr©Úobjs   &r   Úis_cuda_ndarrayr   #   s   € ä�3Ð*¨EÓ2Ð2r   c                ó¦   a € \        S 4       V 3R lpV! R\        4       V! R\        4       V! R\        P                  4       V! R\        4       R# )z,Verify the CUDA ndarray interface for an objc                 óž   <€ \        SV 4      '       g   \        V 4      h\        \        SV 4      V4      '       g   \        V : R V: 24      hR# )z must be of type N)ÚhasattrÚAttributeErrorÚ
isinstancer   )ÚattrÚtypr   s   &&€r   Úrequires_attrÚ4verify_cuda_ndarray_interface.<locals>.requires_attr,   sD   ø€ Ü�s˜D×!Ò!Ü  Ó&Ð&Üœ' # tÓ,¨c×2Ò2Ü »DÂ#Ð!FÓGÐGñ 3r   ÚshapeÚstridesÚdtypeÚsizeN)Úrequire_cuda_ndarrayÚtupleÚnpr'   Úint)r   r#   s   f r   Úverify_cuda_ndarray_interfacer-   (   s?   ø€ ä˜ÔõHñ �'œ5Ô!Ù�)œUÔ#Ù�'œ2Ÿ8™8Ô$Ù�&œ#Ör   c                ó>   € \        V 4      '       g   \        R4      hR# )z9Raises ValueError is is_cuda_ndarray(obj) evaluates Falsezrequire an cuda ndarray objectN)r   Ú
ValueErrorr   s   &r   r)   r)   8   s   € ä˜3×ÒÜÐ9Ó:Ð:ñ  r   c                   ó  a € ] tR t^>t o RtRtRtRR lt]R 4       t	RR lt
]R 4       tRR ltR	 t]R
 4       t]R 4       t]P"                  RR l4       t]P"                  RR l4       tRR ltR tR tRR ltR t]R 4       tRtV tR# )ÚDeviceNDArrayBasez$A on GPU NDArray representation
    TNc                ór  € \        V\        4      '       d   V3p\        V\        4      '       d   V3p\        P                  ! V4      p\	        V4      V n        \	        V4      V P
                  8w  d   \        R4      h\        P                  P                  ^ WVP                  4      V n        \        V4      V n        \        V4      V n        W0n        \        \        P                   ! \"        P$                  V P                  ^4      4      V n        V P&                  ^ 8”  d•   Vfu   \(        P*                  ! V P                  V P                  V P                  P                  4      V n        \.        P0                  ! 4       P3                  V P,                  4      pM�\(        P4                  ! V4      V n        Mt\(        P6                  '       d!   \(        P8                  P;                  ^ 4      pM\=        ^ 4      p\(        P>                  ! \.        P0                  ! 4       V^ R7      p^ V n        WPn         W@n!        R# )zÍ
Args
----

shape
    array shape.
strides
    array strides.
dtype
    data type as np.dtype coercible object.
stream
    cuda stream.
gpu_data
    user provided device memory for the ndarray data buffer
zstrides not match ndimN)ÚcontextÚpointerr(   )"r    r,   r+   r'   ÚlenÚndimr/   r   ÚArrayÚ	from_descÚitemsizeÚ_dummyr*   r%   r&   Ú	functoolsÚreduceÚoperatorÚmulr(   Ú_driverÚmemory_size_from_infoÚ
alloc_sizer   Úget_contextÚmemallocÚdevice_memory_sizeÚUSE_NV_BINDINGÚbindingÚCUdeviceptrr   ÚMemoryPointerÚgpu_dataÚstream)Úselfr%   r&   r'   rJ   rI   Únulls   &&&&&& r   Ú__init__ÚDeviceNDArrayBase.__init__D   s‹  € ô  �eœS×!Ò!Ø�HˆEÜ�gœs×#Ò#Ø�jˆGÜ—’˜“ˆÜ˜“JˆŒ	Üˆw‹<˜4Ÿ9™9Ô$ÜÐ5Ó6Ð6Ü ×&Ñ&×0Ñ0°°EØ16·±óAˆŒä˜5“\ˆŒ
Ü˜W“~ˆŒØŒ
Üœ	×(Ò(¬¯©°t·z±zÀ1ÓEÓFˆŒ	à�9‰9�qŒ=ØÒÜ")×"?Ò"?Ø—J‘J §¡¨d¯j©j×.AÑ.Aó#C�”ä"×.Ò.Ó0×9Ñ9¸$¿/¹/ÓJ‘ä")×"<Ò"<¸XÓ"F�•ô ×%×%Ð%Ü—‘×2Ñ2°1Ó5‘ä “{�Ü×,Ò,´W×5HÒ5HÓ5JØ59ÀôCˆHàˆDŒOà ŒØŽr   c                óê  € \         P                  '       d(   V P                  e   \        V P                  4      pM4^ pM1V P                  P                  e   V P                  P                  pM^ pR\        V P                  4      R\        V 4      '       d   R M\        V P                  4      RVR3RV P                  P                  RV P                  ^ 8w  d   \        V P                  4      R^/# R R^/# )Nr%   r&   ÚdataFÚtypestrrJ   Úversion)r?   rE   Údevice_ctypes_pointerr,   Úvaluer*   r%   Úis_contiguousr&   r'   ÚstrrJ   )rK   Úptrs   & r   Ú__cuda_array_interface__Ú*DeviceNDArrayBase.__cuda_array_interface__w   sÕ   € ä×!×!Ð!Ø×)Ñ)Ò5Ü˜$×4Ñ4Ó5‘à‘à×)Ñ)×/Ñ/Ò;Ø×0Ñ0×6Ñ6‘à�ð ”U˜4Ÿ:™:Ó&Øœ}¨T×2Ò2‘t¼¸d¿l¹lÓ8KØ�S˜%�LØ�t—z‘z—~‘~Ø¨$¯+©+¸Ô*:”c˜$Ÿ+™+Ó&Ø�qð
ð 	
ð
 AEØ�qð
ð 	
r   c                ó>   € \         P                   ! V 4      pWn        V# )zoBind a CUDA stream to this object so that all subsequent operation
on this array defaults to the given stream.
)ÚcopyrJ   )rK   rJ   Úclones   && r   ÚbindÚDeviceNDArrayBase.bind�   s   € ô —	’	˜$“ˆØŒØˆr   c                ó"   € V P                  4       # r   ©Ú	transpose©rK   s   &r   ÚTÚDeviceNDArrayBase.T•   s   € à�~‰~ÓÐr   c                óD  € V'       d/   \        V4      \        \        V P                  4      4      8X  d   V # V P                  ^8w  d   Rp\        V4      hVe<   \	        V4      \	        \        V P                  4      4      8w  d   \        RV: 24      h^ RIHp V! V 4      # )é   z2transposing a non-2D DeviceNDArray isn't supportedzinvalid axes list r`   )r*   Úranger6   ÚNotImplementedErrorÚsetr/   Únumba.cuda.kernels.transposera   )rK   ÚaxesÚmsgra   s   &&  r   ra   ÚDeviceNDArrayBase.transpose™   sx   € ß”E˜$“K¤5¬¨t¯y©yÓ)9Ó#:Ô:ØˆKØ�Y‰Y˜!Œ^ØFˆCÜ% cÓ*Ð*ØÒ¤# d£)¬s´5¸¿¹Ó3CÓ/DÔ"DÝ²tÐ=Ó>Ð>å>Ù˜T“?Ð"r   c                ó.   € V'       g   V P                   # T# r   ©rJ   )rK   rJ   s   &&r   Ú_default_streamÚ!DeviceNDArrayBase._default_stream¥   s   € ß"(ˆt�{‰{Ð4¨fÐ4r   c                ó6  € ^ V P                   9   pV P                  R,          '       d   V'       g   RpM&V P                  R,          '       d   V'       g   RpMRp\        P                  ! V P                  4      p\
        P                  ! W0P                  V4      # )úV
Magic attribute expected by Numba to get the numba type that
represents this object.
ÚC_CONTIGUOUSÚCÚF_CONTIGUOUSÚFÚA)r&   Úflagsr   Ú
from_dtyper'   r   r7   r6   )rK   Ú	broadcastÚlayoutr'   s   &   r   Ú_numba_type_ÚDeviceNDArrayBase._numba_type_¨   sl   € ð( ˜Ÿ™Ñ%ˆ	Ø�:‰:�n×%Ô%¯iØ‰FØ�Z‰Z˜×'Ô'·	Ø‰FàˆFä×(Ò(¨¯©Ó4ˆÜ�{Š{˜5§)¡)¨VÓ4Ð4r   c                óÊ   € V P                   fA   \        P                  '       d    \        P                  P	                  ^ 4      # \        ^ 4      # V P                   P                  # )z:Returns the ctypes pointer to the GPU data buffer
        )rI   r?   rE   rF   rG   r   rS   rb   s   &r   rS   Ú'DeviceNDArrayBase.device_ctypes_pointerÇ   sI   € ð �=‰=Ò Ü×%×%Ð%Ü—‘×2Ñ2°1Ó5Ð5ä “{Ð"à—=‘=×6Ñ6Ð6r   c                óH  € VP                   ^ 8X  d   R# \        V 4       V P                  V4      p\        V 4      \        V4      rC\        P
                  ! V4      '       d<   \        V4       \        W44       \        P                  ! WV P                  VR7       R# \        P                  ! TVP                  R,          '       d   RMRR\        R	8  d   VP                  R,          '       * MRR7      p\        W44       \        P                  ! WV P                  VR7       R# )
z‡Copy `ary` to `self`.

If `ary` is a CUDA memory, perform a device-to-device transfer.
Otherwise, perform a a host-to-device transfer.
Nro   rt   ru   rw   TÚ	WRITEABLE)ÚorderÚsubokr[   ©rf   é    )r(   Úsentry_contiguousrp   Ú
array_corer?   Úis_device_memoryÚcheck_array_compatibilityÚdevice_to_devicerA   r+   Úarrayry   r
   Úhost_to_device)rK   ÚaryrJ   Ú	self_coreÚary_cores   &&&  r   Úcopy_to_deviceÚ DeviceNDArrayBase.copy_to_deviceÓ   sÙ   € ð �8‰8�qŒ=áä˜$ÔØ×%Ñ% fÓ-ˆä(¨Ó.´
¸3³�8Ü×#Ò# C×(Ò(Ü˜cÔ"Ü% iÔ:Ü×$Ò$ T°·±È×Oô —x’xØØ&Ÿ_™_¨^×<Ô<‘cÀ#Øä  6Ô)ð #Ÿ.™.¨Õ5Õ5Ø/3ô5ˆHô & iÔ:Ü×"Ò" 4°4·?±?Ø*0÷2r   c                ó$  € \         ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      '       d'   Rp\        VP                  V P                  4      4      hV P                  ^ 8¼  g   Q R4       hV P                  V4      pVf2   \        P                  ! V P                  \        P                  R7      pM\        W4       TpV P                  ^ 8w  d$   \        P                  ! W@V P                  VR7       Vfy   V P                  ^ 8X  d0   \        P                  ! V P                  V P                  VR7      pV# \        P                  ! V P                  V P                  V P                  VR	7      pV# )
aö  Copy ``self`` to ``ary`` or create a new Numpy ndarray
if ``ary`` is ``None``.

If a CUDA ``stream`` is given, then the transfer will be made
asynchronously as part as the given stream.  Otherwise, the transfer is
synchronous: the function returns after the copy is finished.

Always returns the host array.

Example::

    import numpy as np
    from numba import cuda

    arr = np.arange(1000)
    d_arr = cuda.to_device(arr)

    my_kernel[100, 100](d_arr)

    result_array = d_arr.copy_to_host()
c              3   ó*   "  € T F	  q^ 8  x € K  	  R# 5i©r†   Nr   )Ú.0Úss   & r   Ú	<genexpr>Ú1DeviceNDArrayBase.copy_to_host.<locals>.<genexpr>
  s   é € Ð+™l˜�1Žu›lùs   ‚TFz2D->H copy not implemented for negative strides: {}zNegative memory size©r%   r'   ro   )r%   r'   Úbuffer)r%   r'   r&   r›   )Úanyr&   rh   ÚformatrA   rp   r+   ÚemptyÚbyterŠ   r?   Údevice_to_hostr(   Úndarrayr%   r'   )rK   rŽ   rJ   rl   Úhostarys   &&&  r   Úcopy_to_hostÚDeviceNDArrayBase.copy_to_hostó   s"  € ÷. ‹3Ñ+˜dŸlšlÓ+�3�3Š3Ñ+˜dŸlšlÓ+×+Ò+ØFˆCÜ% c§j¡j°·±Ó&>Ó?Ð?Ø�‰ !Ô#Ð;Ð%;Ó;Ð#Ø×%Ñ% fÓ-ˆØŠ;Ü—h’h T§_¡_¼B¿G¹GÔD‰Gä% dÔ0ØˆGà�?‰?˜aÔÜ×"Ò" 7°$·/±/Ø*0õ2ð Š;Ø�y‰y˜AŒ~ÜŸ*š*¨4¯:©:¸T¿Z¹ZØ,3ô5�ð
 ˆô Ÿ*š*¨4¯:©:¸T¿Z¹ZØ-1¯\©\À'ôK�àˆr   c           	   #  ó�  "  € V P                  V4      pV P                  ^8w  d   \        R4      hV P                  ^ ,          V P                  P
                  8w  d   \        R4      h\        \        P                  ! \        V P                  4      V,          4      4      pV P                  pV P                  P
                  p\        V4       Fs  pWa,          p\        Wq,           V P                  4      pW‡,
          3p	V P                  P                  Wu,          W…,          4      p
\        W”V P                  VV
R7      x € Ku  	  R# 5i)z†Split the array into equal partition of the `section` size.
If the array cannot be equally divided, the last section will be
smaller.
zonly support 1d arrayzonly support unit stride©r'   rJ   rI   N)rp   r6   r/   r&   r'   r9   r,   ÚmathÚceilÚfloatr(   rg   ÚminrI   ÚviewÚDeviceNDArray)rK   ÚsectionrJ   Únsectr&   r9   ÚiÚbeginÚendr%   rI   s   &&&        r   ÚsplitÚDeviceNDArrayBase.split"  sò   é € ð
 ×%Ñ% fÓ-ˆØ�9‰9˜Œ>ÜÐ4Ó5Ð5Ø�<‰<˜�?˜dŸj™j×1Ñ1Ô1ÜÐ7Ó8Ð8Ü”D—I’Iœe D§I¡IÓ.°Õ8Ó9Ó:ˆØ—,‘,ˆØ—:‘:×&Ñ&ˆÜ�u–ˆAØ•KˆEÜ�e•o t§y¡yÓ1ˆCØ•[�NˆEØ—}‘}×)Ñ)¨%Õ*:¸C½NÓKˆHÜ °d·j±jÈØ)1ô3ô 3ó ùs   ‚EEc                ó   € V P                   # )zEReturns a device memory object that is used as the argument.
        )rI   rb   s   &r   Úas_cuda_argÚDeviceNDArrayBase.as_cuda_arg7  s   € ð �}‰}Ðr   c                óÎ   € \         P                  ! 4       P                  V P                  4      p\	        V P
                  V P                  V P                  R7      p\        WR7      # )z¬
Returns a *IpcArrayHandle* object that is safe to serialize and transfer
to another process to share the local allocation.

Note: this feature is only available on Linux.
)r%   r&   r'   )Ú
ipc_handleÚ
array_desc)	r   rB   Úget_ipc_handlerI   Údictr%   r&   r'   ÚIpcArrayHandle)rK   ÚipchÚdescs   &  r   rº   Ú DeviceNDArrayBase.get_ipc_handle<  sF   € ô ×"Ò"Ó$×3Ñ3°D·M±MÓBˆÜ˜$Ÿ*™*¨d¯l©lÀ$Ç*Á*ÔMˆÜ¨Ô?Ð?r   c                óÌ   € V P                   P                  VR7      w  r4\        VP                  VP                  V P
                  V P                  V4      V P                  R7      # )a¸  
Remove axes of size one from the array shape.

Parameters
----------
axis : None or int or tuple of ints, optional
    Subset of dimensions to remove. A `ValueError` is raised if an axis
    with size greater than one is selected. If `None`, all axes with
    size one are removed.
stream : cuda stream or 0, optional
    Default stream for the returned view of the array.

Returns
-------
DeviceNDArray
    Squeezed view into the array.

)Úaxis©r%   r&   r'   rJ   rI   )r:   Úsqueezer¬   r%   r&   r'   rp   rI   )rK   rÁ   rJ   Ú	new_dummyÚ_s   &&&  r   rÃ   ÚDeviceNDArrayBase.squeezeG  sV   € ð& —{‘{×*Ñ*°Ð*Ó5‰ˆ	ÜØ—/‘/Ø×%Ñ%Ø—*‘*Ø×'Ñ'¨Ó/Ø—]‘]ô
ð 	
r   c                ó  € \         P                  ! V4      p\        V P                  4      p\        V P                  4      pV P                  P
                  VP
                  8w  d�   V P                  4       '       g   \        R4      h\        VR,          V P                  P
                  ,          VP
                  4      w  VR&   pV^ 8w  d   \        R4      hVP
                  VR&   \        VVVV P                  V P                  R7      # )zUReturns a new object by reinterpretting the dtype without making a
copy of the data.
zHTo change to a dtype of a different size, the array must be C-contiguouszuWhen changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.rÂ   éÿÿÿÿ)r+   r'   Úlistr%   r&   r9   Úis_c_contiguousr/   Údivmodr¬   rJ   rI   )rK   r'   r%   r&   Úrems   &&   r   r«   ÚDeviceNDArrayBase.viewc  sã   € ô —’˜“ˆÜ�T—Z‘ZÓ ˆÜ�t—|‘|Ó$ˆà�:‰:×Ñ %§.¡.Ô0Ø×'Ñ'×)Ò)Ü ð6óð ô
 $Ø�b•	˜DŸJ™J×/Ñ/Õ/Ø—‘ó‰NˆE�"‰I�sð
 �aŒxÜ ð6óð ð  Ÿ.™.ˆG�B‰KäØØØØ—;‘;Ø—]‘]ô
ð 	
r   c                óP   € V P                   P                  V P                  ,          # r   )r'   r9   r(   rb   s   &r   ÚnbytesÚDeviceNDArrayBase.nbytesˆ  s   € ð
 �z‰z×"Ñ" T§Y¡YÕ.Ð.r   )	r:   rA   r'   rI   r6   r%   r(   rJ   r&   r•   ©r†   r   )Nr†   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__cuda_memory__r   rM   ÚpropertyrX   r]   rc   ra   rp   r}   rS   r   Úrequire_contextr‘   r£   r²   rµ   rº   rÃ   r«   rÏ   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r1   r1   >   sÞ   ø‡ € ñà€OØÐô1ðf ñ
ó ð
ô*ð ñ ó ð ô
#ò5ð ñ5ó ð5ð< ñ	7ó ð	7ð ×Ñó2ó ð2ð> ×Ñó,ó ð,ô\3ò*ò
	@ô
ò8#
ðJ ñ/ó ö/r   r1   c                   ó  a a€ ] tR tRt oRtRV 3R llt]R 4       t]R 4       t]	P                  R 4       t]	P                  RR l4       tRR lt]	P                  R	 4       t]	P                  RR
 l4       tRR ltRtVtV ;t# )ÚDeviceRecordi�  z
An on-GPU record type
c                ó:   <€ RpRp\         \        V `  WEWV4       R # ©Nr   )Úsuperrß   rM   )rK   r'   rJ   rI   r%   r&   Ú	__class__s   &&&&  €r   rM   ÚDeviceRecord.__init__”  s#   ø€ ØˆØˆÜŒl˜DÑ*¨5¸5Ø+3ö	5r   c                ó@   € \        V P                  P                  4      # ©z×
For `numpy.ndarray` compatibility. Ideally this would return a
`np.core.multiarray.flagsobj`, but that needs to be constructed
with an existing `numpy.ndarray` (as the C- and F- contiguous flags
aren't writeable).
©r»   r:   ry   rb   s   &r   ry   ÚDeviceRecord.flagsš  ó   € ô �D—K‘K×%Ñ%Ó&Ð&r   c                óB   € \         P                  ! V P                  4      # )rs   )r   rz   r'   rb   s   &r   r}   ÚDeviceRecord._numba_type_¤  s   € ô ×'Ò'¨¯
©
Ó3Ð3r   c                ó$   € V P                  V4      # r   ©Ú_do_getitem©rK   Úitems   &&r   Ú__getitem__ÚDeviceRecord.__getitem__¬  ó   € à×Ñ Ó%Ð%r   c                ó$   € V P                  W4      # ©z0Do `__getitem__(item)` with CUDA stream
        rí   ©rK   rð   rJ   s   &&&r   ÚgetitemÚDeviceRecord.getitem°  ó   € ð ×Ñ Ó-Ð-r   c                óì  € V P                  V4      pV P                  P                  V,          w  r4V P                  P	                  V4      pVP
                  R8X  d`   VP                  e   \        W2VR7      # \        P                  ! ^VR7      p\        P                  ! WeVP                  VR7       V^ ,          # \        VP
                  R VP                  ^ ,          R4      w  rxp	\        WxW•VR7      # )Nr¦   ©r'   ©ÚdstÚsrcr(   rJ   ru   ©r%   r&   r'   rI   rJ   r   )rp   r'   ÚfieldsrI   r«   r%   Únamesrß   r+   rž   r?   r    r9   r   Úsubdtyper¬   )
rK   rð   rJ   r"   ÚoffsetÚnewdatar¢   r%   r&   r'   s
   &&&       r   rî   ÚDeviceRecord._do_getitem¶  sÜ   € Ø×%Ñ% fÓ-ˆØ—j‘j×'Ñ'¨Õ-‰ˆØ—-‘-×$Ñ$ VÓ,ˆà�9‰9˜Œ?Ø�y‰yÒ$Ü#¨#Ø-4ô6ð 6ô Ÿ(š( 1¨CÔ0�Ü×&Ò&¨7Ø,/¯L©LØ.4õ6ð ˜1•:Ðô ,¨C¯I©IØ,0Ø,/¯L©L¸­O¸SóBñ "ˆE˜Eô ! uØ',Ø(.ô0ð 0r   c                ó$   € V P                  W4      # r   ©Ú_do_setitem©rK   ÚkeyrT   s   &&&r   Ú__setitem__ÚDeviceRecord.__setitem__Î  ó   € à×Ñ Ó+Ð+r   c                ó(   € V P                  WVR7      # ©z6Do `__setitem__(key, value)` with CUDA stream
        ro   r  ©rK   r
  rT   rJ   s   &&&&r   ÚsetitemÚDeviceRecord.setitemÒ  ó   € ð ×Ñ °6ÐÓ:Ð:r   c                ó  € V P                  V4      pV'       * pV'       d&   \        P                  ! 4       pVP                  4       pV P                  P
                  V,          w  rgV P                  P                  V4      p\        V 4      ! WcVR 7      p	\        V	P                  P                  V4      VR7      w  r«\        P                  ! WšV
P                  P                  V4       V'       d   VP                  4        R# R# )r¦   ro   N)rp   r   rB   Úget_default_streamr'   r   rI   r«   ÚtypeÚauto_devicer?   r‹   r9   Úsynchronize)rK   r
  rT   rJ   ÚsynchronousÚctxr"   r  r  ÚlhsÚrhsrÅ   s   &&&&        r   r  ÚDeviceRecord._do_setitemØ  sÅ   € à×%Ñ% fÓ-ˆð
 !”jˆßÜ×%Ò%Ó'ˆCØ×+Ñ+Ó-ˆFð —j‘j×'Ñ'¨Õ,‰ˆØ—-‘-×$Ñ$ VÓ,ˆä�4Œj˜s¸GÔDˆô ˜SŸY™YŸ^™^¨EÓ2¸6ÔB‰ˆô 	× Ò  ¨3¯9©9×+=Ñ+=¸vÔFçØ×ÑÖ ñ r   r   r•   rÑ   )rÒ   rÓ   rÔ   rÕ   rÖ   rM   rØ   ry   r}   r   rÙ   rñ   r÷   rî   r  r  r  rÚ   rÛ   Ú__classcell__)rã   rÝ   s   @@r   rß   rß   �  s®   ù‡ € ñ÷5ð ñ'ó ð'ð ñ4ó ð4ð ×Ññ&ó ð&ð ×Ñó.ó ð.ô
0ð0 ×Ññ,ó ð,ð ×Ñó;ó ð;÷
!ô !r   rß   c                óx   a a€ ^ RI Ho S ^ 8X  d   SP                  R 4       pV# SP                  VV 3R l4       pV# )zÉ
A separate method so we don't need to compile code every assignment (!).

:param ndim: We need to have static array sizes for cuda.local.array, so
    bake in the number of dimensions into the kernel
)Úcudac                 ó   € VR,          V R&   R # rá   r   )r  r  s   &&r   ÚkernelÚ_assign_kernel.<locals>.kernel  s   € à˜"•gˆC�‹Gr   c                 ót  <€ SP                  ^4      p^p\        V P                  4       F  pW0P                  V,          ,          pK  	  W#8¼  d   R# SP                  P                  ^S3\        P                  R7      p\        S^,
          RR4       Fs  pW P                  V,          ,          V^ V3&   W P                  V,          ,          VP                  V,          ^8„  ,          V^V3&   W P                  V,          ,          pKu  	  V\        V^,          S4      ,          V \        V^ ,          S4      &   R# )é   Nrš   rÈ   )	Úgridrg   r6   r%   ÚlocalrŒ   r   Úint64r	   )r  r  ÚlocationÚ
n_elementsr¯   Úidxr   r6   s   &&    €€r   r"  r#    sý   ø€ à—9‘9˜Q“<ˆàˆ
Ü�s—x‘x–ˆAØŸ)™) A�,Õ&ŠJñ !àÔ!ñ ð �j‰j×ÑØ�d�)Ü—+‘+ð ó ˆô �t˜a•x  RÖ(ˆAØ §9¡9¨Q¥<Õ/ˆC��1�‰IØ!§I¡I¨a¥LÕ0°S·Y±Y¸qµ\ÀAÑ5EÕFˆC��1�‰IØŸ™ 1�Õ%ŠHñ )ð
 -0´¸sÀ1½vÀtÓ0LÕ,MˆŒN˜3˜q�6 4Ó(Ó)r   )Únumbar   Újit)r6   r"  r   s   f @r   Ú_assign_kernelr.  ÷  sI   ù€ õ àˆq„yà	�‰ñ	ó 
ð	àˆà	‡X�XõNó ðNð. €Mr   c                   ó  a € ] tR tRt o RtR t]R 4       tR tRR lt	R t
R	 tRR
 lt]P                  R 4       t]P                  RR l4       tRR lt]P                  R 4       t]P                  RR l4       tRR ltRtV tR# )r¬   i#  z
An on-GPU array type
c                ó.   € V P                   P                  # )z1
Return true if the array is Fortran-contiguous.
)r:   Úis_f_contigrb   s   &r   Úis_f_contiguousÚDeviceNDArray.is_f_contiguous'  ó   € ð �{‰{×&Ñ&Ð&r   c                ó@   € \        V P                  P                  4      # ræ   rç   rb   s   &r   ry   ÚDeviceNDArray.flags-  ré   r   c                ó.   € V P                   P                  # )z+
Return true if the array is C-contiguous.
)r:   Úis_c_contigrb   s   &r   rÊ   ÚDeviceNDArray.is_c_contiguous7  r4  r   Nc                óŒ   € V'       d    V P                  4       P                  V4      # V P                  4       P                  4       # )z5
:return: an `numpy.ndarray`, so copies to the host.
)r£   Ú	__array__)rK   r'   s   &&r   r;  ÚDeviceNDArray.__array__=  s9   € ÷ Ø×$Ñ$Ó&×0Ñ0°Ó7Ð7à×$Ñ$Ó&×0Ñ0Ó2Ð2r   c                ó(   € V P                   ^ ,          # rÑ   )r%   rb   s   &r   Ú__len__ÚDeviceNDArray.__len__F  s   € Ø�z‰z˜!�}Ðr   c                ó  € \        V4      ^8X  d-   \        V^ ,          \        \        34      '       d
   V^ ,          p\	        V 4      pWP
                  8X  d5   V! V P
                  V P                  V P                  V P                  R7      # V P                  P                  ! V/ VB w  rEWPP                  P                  .8X  d5   V! VP
                  VP                  V P                  V P                  R7      # \        R4      h)z—
Reshape the array without changing its contents, similarly to
:meth:`numpy.ndarray.reshape`.

Example::

    d_arr = d_arr.reshape(20, 50, order='F')
)r%   r&   r'   rI   úoperation requires copying)r5   r    r*   rÉ   r  r%   r&   r'   rI   r:   ÚreshapeÚextentrh   )rK   ÚnewshapeÚkwsÚclsÚnewarrÚextentss   &*,   r   rB  ÚDeviceNDArray.reshapeI  sÎ   € ô ˆx‹=˜AÔ¤*¨X°a­[¼5Ä$¸-×"HÒ"HØ •{ˆHä�4‹jˆØ—z‘zÔ!á˜TŸZ™Z°·±Ø!ŸZ™Z°$·-±-ôAð Að Ÿ+™+×-Ò-¨xÐ?¸3Ñ?‰ˆà—{‘{×)Ñ)Ð*Ô*Ù˜VŸ\™\°6·>±>Ø!ŸZ™Z°$·-±-ôAð Aô &Ð&BÓCÐCr   c                ó,  € V P                  V4      p\        V 4      pV P                  P                  VR7      w  rEWPP                  P                  .8X  d6   V! VP
                  VP                  V P                  V P                  VR7      # \        R4      h)z™
Flattens a contiguous array without changing its contents, similar to
:meth:`numpy.ndarray.ravel`. If the array is not contiguous, raises an
exception.
)rƒ   rÿ   rA  )
rp   r  r:   ÚravelrC  r%   r&   r'   rI   rh   )rK   rƒ   rJ   rF  rG  rH  s   &&&   r   rK  ÚDeviceNDArray.ravelc  s€   € ð ×%Ñ% fÓ-ˆÜ�4‹jˆØŸ+™+×+Ñ+°%Ð+Ó8‰ˆà—{‘{×)Ñ)Ð*Ô*Ù˜VŸ\™\°6·>±>Ø!ŸZ™Z°$·-±-Ø$ô&ð &ô
 &Ð&BÓCÐCr   c                ó$   € V P                  V4      # r   rí   rï   s   &&r   rñ   ÚDeviceNDArray.__getitem__u  ró   r   c                ó$   € V P                  W4      # rõ   rí   rö   s   &&&r   r÷   ÚDeviceNDArray.getitemy  rù   r   c                ó(  € V P                  V4      pV P                  P                  V4      p\        VP	                  4       4      p\        V 4      p\        V4      ^8X  dæ   V P                  P                  ! V^ ,          !  pVP                  '       g‰   V P                  P                  e   \        V P                  VVR7      # \        P                  ! ^V P                  R7      p\        P                   ! WvV P                  P"                  VR7       V^ ,          # V! VP$                  VP&                  V P                  WbR7      # V P                  P                  ! VP(                  !  pV! VP$                  VP&                  V P                  WbR7      # )r%  r¦   rû   rü   rÿ   )rp   r:   rñ   rÉ   Úiter_contiguous_extentr  r5   rI   r«   Úis_arrayr'   r  rß   r+   rž   r?   r    r9   r%   r&   rC  )rK   rð   rJ   ÚarrrH  rF  r  r¢   s   &&&     r   rî   ÚDeviceNDArray._do_getitem  s;  € Ø×%Ñ% fÓ-ˆà�k‰k×%Ñ% dÓ+ˆÜ�s×1Ñ1Ó3Ó4ˆÜ�4‹jˆÜˆw‹<˜1ÔØ—m‘m×(Ò(¨'°!­*Ñ5ˆGà—<—<�<à—:‘:×#Ñ#Ò/Ü'¨d¯j©jÀØ18ô:ð :ô !Ÿhšh q°·
±
Ô;�GÜ×*Ò*¨wØ04·±×0DÑ0DØ28õ:ð ˜q•zÐ!á §¡°C·K±KØ!%§¡°gôNð Nð —m‘m×(Ò(¨#¯*©*Ñ5ˆGÙ˜SŸY™Y°·±Ø!ŸZ™Z°'ôJð Jr   c                ó$   € V P                  W4      # r   r  r	  s   &&&r   r  ÚDeviceNDArray.__setitem__œ  r  r   c                ó(   € V P                  WVR7      # r  r  r  s   &&&&r   r  ÚDeviceNDArray.setitem   r  r   c                óÞ  € V P                  V4      pV'       * pV'       d&   \        P                  ! 4       pVP                  4       pV P                  P                  V4      pV P                  P                  ! VP                  !  p\        V\        P                  4      '       d   R
pR
p	MVP                  pVP                  p	\        V 4      ! VV	V P                  VVR 7      p
\!        W#RR7      w  r¼VP"                  V
P"                  8”  d)   \%        RVP"                  : RV
P"                  : R24      h\&        P(                  ! V
P"                  \&        P*                  R7      pVP                  WÚP"                  VP"                  ,
          R% VP,                  ! V!  p\/        \1        V
P                  VP                  4      4       F-  w  pw  ppV^8w  g   K  VV8w  g   K  \%        RVWï3,          4      h	  \2        P4                  ! \6        P8                  V
P                  ^4      p\;        V
P"                  4      P=                  VVR	7      ! W«4       V'       d   VP?                  4        R# R# )rÿ   T)rJ   Úuser_explicitzCan't assign z-D array to z-D selfrû   NzCCan't copy sequence with size %d to array axis %d with dimension %dro   r   ) rp   r   rB   r  r:   rñ   rI   r«   rC  r    r   ÚElementr%   r&   r  r'   r  r6   r/   r+   Úonesr(  rB  Ú	enumerateÚzipr;   r<   r=   r>   r.  Úforallr  )rK   r
  rT   rJ   r  r  rT  r  r%   r&   r  r  rÅ   Ú	rhs_shaper¯   ÚlÚrr*  s   &&&&              r   r  ÚDeviceNDArray._do_setitem¦  sã  € à×%Ñ% fÓ-ˆð
 !”jˆßÜ×%Ò%Ó'ˆCØ×+Ñ+Ó-ˆFð �k‰k×%Ñ% cÓ*ˆØ—-‘-×$Ò$ c§j¡jÑ1ˆä�cœ:×-Ñ-×.Ò.àˆEØ‰Gà—I‘IˆEØ—k‘kˆGä�4ŒjØØØ—*‘*ØØôˆô ˜UÀÔF‰ˆØ�8‰8�c—h‘hÔÝØ—”Ø—”ðó ð ô —G’G˜CŸH™H¬B¯H©HÔ5ˆ	à*-¯)©)ˆ	—(‘(˜SŸX™XÕ%Ð&Ð'Ø�kŠk˜9Ñ%ˆÜ"¤3 s§y¡y°#·)±)Ó#<Ö=‰IˆA‰v��1Ø�AŽv˜!˜qž&Ü ð "=ØABÀA¸zõ"Jó Kð Kñ >ô ×%Ò%¤h§l¡l°C·I±I¸qÓAˆ
Ü�s—x‘xÓ ×'Ñ'¨
¸6Ð'ÔBÀ3ÔLßØ×ÑÖ ñ r   r   r   )ru   r†   rÑ   )rÒ   rÓ   rÔ   rÕ   rÖ   r2  rØ   ry   rÊ   r;  r>  rB  rK  r   rÙ   rñ   r÷   rî   r  r  r  rÚ   rÛ   rÜ   s   @r   r¬   r¬   #  s¶   ø‡ € ñò'ð ñ'ó ð'ò'ô3òòDô4Dð$ ×Ññ&ó ð&ð ×Ñó.ó ð.ô
Jð: ×Ññ,ó ð,ð ×Ñó;ó ð;÷
5!ò 5!r   r¬   c                   óB   a € ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
r¼   iÞ  aê  
An IPC array handle that can be serialized and transfer to another process
in the same machine for share a GPU allocation.

On the destination process, use the *.open()* method to creates a new
*DeviceNDArray* object that shares the allocation from the original process.
To release the resources, call the *.close()* method.  After that, the
destination can no longer use the shared array object.  (Note: the
underlying weakref to the resource is now dead.)

This object implements the context-manager interface that calls the
*.open()* and *.close()* method automatically::

    with the_ipc_array_handle as ipc_array:
        # use ipc_array here as a normal gpu array object
        some_code(ipc_array)
    # ipc_array is dead at this point
c                ó   € W n         Wn        R # r   ©Ú_array_descÚ_ipc_handle)rK   r¸   r¹   s   &&&r   rM   ÚIpcArrayHandle.__init__ñ  s   € Ø%ÔØ%Ör   c                óŒ   € V P                   P                  \        P                  ! 4       4      p\	        RRV/V P
                  B # )z€
Returns a new *DeviceNDArray* that shares the allocation from the
original process.  Must not be used on the original process.
rI   r   )ri  Úopenr   rB   r¬   rh  )rK   Údptrs   & r   rl  ÚIpcArrayHandle.openõ  s<   € ð
 ×Ñ×$Ñ$¤W×%8Ò%8Ó%:Ó;ˆÜÑ? dÐ?¨d×.>Ñ.>Ñ?Ð?r   c                ó:   € V P                   P                  4        R# )z%
Closes the IPC handle to the array.
N)ri  Úcloserb   s   &r   rp  ÚIpcArrayHandle.closeý  s   € ð 	×Ñ×ÑÖ r   c                ó"   € V P                  4       # r   )rl  rb   s   &r   Ú	__enter__ÚIpcArrayHandle.__enter__  s   € Ø�y‰y‹{Ðr   c                ó&   € V P                  4        R # r   )rp  )rK   r  rT   Ú	tracebacks   &&&&r   Ú__exit__ÚIpcArrayHandle.__exit__  s   € Ø�
‰
Žr   rg  N)rÒ   rÓ   rÔ   rÕ   rÖ   rM   rl  rp  rs  rw  rÚ   rÛ   rÜ   s   @r   r¼   r¼   Þ  s)   ø‡ € ñò$&ò@ò!ò÷ð r   r¼   c                   ó.   a € ] tR tRt o RtRR ltRtV tR# )ÚMappedNDArrayi
  z,
A host array that uses CUDA mapped memory.
c                ó   € Wn         W n        R # r   ©rI   rJ   ©rK   rI   rJ   s   &&&r   Údevice_setupÚMappedNDArray.device_setup  ó   € Ø ŒØŽr   r|  NrÑ   ©rÒ   rÓ   rÔ   rÕ   rÖ   r~  rÚ   rÛ   rÜ   s   @r   rz  rz  
  ó   ø‡ € ñ÷ò r   rz  c                   ó.   a € ] tR tRt o RtRR ltRtV tR# )ÚManagedNDArrayi  z-
A host array that uses CUDA managed memory.
c                ó   € Wn         W n        R # r   r|  r}  s   &&&r   r~  ÚManagedNDArray.device_setup  r€  r   r|  NrÑ   r�  rÜ   s   @r   r„  r„    r‚  r   r„  c                ó^   € \        V P                  V P                  V P                  VVR7      # )z/Create a DeviceNDArray object that is like ary.©rJ   rI   )r¬   r%   r&   r'   )rŽ   rJ   rI   s   &&&r   Úfrom_array_liker‰    s&   € ä˜Ÿ™ C§K¡K°·±À6Ø"*ô,ð ,r   c                ó0   € \        V P                  WR7      # )z.Create a DeviceRecord object that is like rec.rˆ  )rß   r'   )ÚrecrJ   rI   s   &&&r   Úfrom_record_likerŒ  $  s   € ä˜Ÿ	™	¨&ÔDÐDr   c                óâ   € V P                   '       d   V P                  '       g   V # . pV P                    F&  pTP                  V^ 8X  d   ^ M
\        R4      4       K(  	  V \	        V4      ,          # )a/  
Extract the repeated core of a broadcast array.

Broadcast arrays are by definition non-contiguous due to repeated
dimensions, i.e., dimensions with stride 0. In order to ascertain memory
contiguity and copy the underlying data from such arrays, we must create
a view without the repeated dimensions.

N)r&   r(   ÚappendÚslicer*   )rŽ   Ú
core_indexÚstrides   &  r   rˆ   rˆ   )  sW   € ð �;�;ˆ;˜cŸhŸh˜hØˆ
Ø€JØ—+”+ˆØ×Ñ˜v¨œ{™!´°d³Ö<ñ àŒu�ZÓ Õ!Ð!r   c                óî   € V P                   P                  p\        \        V P                  4      \        V P
                  4      4       F(  w  r#V^8”  g   K  V^ 8w  g   K  W8w  d    R# W,          pK*  	  R# )z¿
Returns True iff `ary` is C-style contiguous while ignoring
broadcasted and 1-sized dimensions.
As opposed to array_core(), it does not call require_context(),
which can be quite expensive.
FT)r'   r9   r_  Úreversedr%   r&   )rŽ   r(   r%   r‘  s   &   r   rU   rU   ;  sZ   € ð �9‰9×Ñ€DÜœX c§i¡iÓ0´(¸3¿;¹;Ó2GÖH‰ˆØ�1Ž9˜ 1žØŒ~ÚØ�MŠDñ	 Iñ
 r   z™Array contains non-contiguous buffer and cannot be transferred as a single memory region. Please ensure contiguous buffer with numpy .ascontiguousarray()c                 ó¢   € \        V 4      pVP                  R ,          '       g+   VP                  R,          '       g   \        \        4      hR# R# )rt   rv   N)rˆ   ry   r/   Úerrmsg_contiguous_buffer)rŽ   Úcores   & r   r‡   r‡   Q  s=   € Ü�c‹?€DØ�:‰:�n×%Ô%¨d¯j©j¸×.HÔ.HÜÔ1Ó2Ð2ñ /IÑ%r   c                ó¸  € \         P                  ! V 4      '       d   V R3# \        V R4      '       d"   \        P                  P                  V 4      R3# \        V \        P                  4      '       d   \        WR7      pM=\        P                  ! T \        R8  d   RMRRR7      p \        V 4       \        WR7      pV'       d“   \        P                  '       dk   \        P                   '       gU   V'       gM   \        V \"        4      '       g7   \        V \        P$                  4      '       d   Rp\'        \)        V4      4       VP+                  WR7       VR3# )	zª
Create a DeviceRecord or DeviceArray like obj and optionally copy data from
host to device. If obj already represents device memory, it is returned and
no copy is made.
FrX   ro   NT)r[   r„   zGHost array used in CUDA kernel will incur copy overhead to/from device.r…   )r?   r‰   r   r,  r   Úas_cuda_arrayr    r+   ÚvoidrŒ  rŒ   r
   r‡   r‰  r   ÚCUDA_WARN_ON_IMPLICIT_COPYÚDISABLE_PERFORMANCE_WARNINGSr¬   r¡   r   r   r‘   )r   rJ   r[   r[  Údevobjrl   s   &&&&  r   r  r  W  s  € ô ×Ò ×$Ò$Ø�EˆzÐÜ	�Ð0×	1Ò	1Ü�z‰z×'Ñ'¨Ó,¨eÐ3Ð3ä�cœ2Ÿ7™7×#Ò#Ü% cÔ9‰Fô —(’(ØÜ+¨fÔ4‘U¸$ØôˆCô ˜cÔ"Ü$ SÔ8ˆFßä×1×1Ð1Ü×;×;Ð;÷ &Ü# C¬×7Ò7Ü# C¬¯©×4Ò4ð;�CäÔ0°Ó5Ô6Ø×!Ñ! #Ð!Ô5Ø�tˆ|Ðr   c                 óø  € V P                  4       VP                  4       r2V P                  VP                  8w  d(   \        R V P                  : RVP                  : 24      hVP                  VP                  8w  d(   \	        RV P                  : RVP                  : 24      hV P
                  '       dE   VP                  VP                  8w  d(   \	        RV P                  : RVP                  : 24      hR# R# )zincompatible dtype: z vs. zincompatible shape: zincompatible strides: N)rÃ   r'   Ú	TypeErrorr%   r/   r(   r&   )Úary1Úary2Úary1sqÚary2sqs   &&  r   rŠ   rŠ   �  s³   € Ø—\‘\“^ T§\¡\£^ˆFØ‡z�z�T—Z‘ZÔÝØŸœ T§Z£Zð1ó 2ð 	2à‡|�|�v—|‘|Ô#ÝØŸ*œ* d§j£jð2ó 3ð 	3ð ‡y‡y€y�V—^‘^ v§~¡~Ô5ÝØŸ,œ,¨¯«ð6ó 7ð 	7ñ 6�yr   r•   )r†   TF)7rÖ   r§   r;   r=   r[   Úctypesr   Únumpyr+   r,  r   Únumba.cuda.cudadrvr   r   r   r?   Ú
numba.corer   r   Únumba.np.unsafe.ndarrayr	   Únumba.np.numpy_supportr
   Únumba.npr   Únumba.cuda.api_utilr   Únumba.core.errorsr   Úwarningsr   r   r   r   r   r-   r)   ÚDeviceArrayr1   rß   r.  r¬   Úobjectr¼   r¡   rz  r„  r‰  rŒ  rˆ   rU   r•  r‡   r  rŠ   r   r   r   Ú<module>r¯     s%  ðñó Û Û Û Ý ã ã Ý ß 2Ý 0ß $Ý 2Ý 0Ý "Ý ;Ý 5Ý ðÙ˜	 ;Ô/°Ó5€Iò3ò
ò ;ôO/˜×0Ñ0ô O/ôd
d!Ð$ô d!ðN ñ(ó ð(ôVx!Ð%ô x!ôv)�Vô )ôXÐ% r§z¡zô ôÐ&¨¯
©
ô ô,ôEò
"ò$ð 3Ð ò3ô'ôT7øðI ô ôðús   Á"D Ä
DÄD