§
    1@Äj‘7  ã                   ó0  — d Z ddlmZ ddlmZ ddlZdZdZdZ	 G d„ de
¦  «        Z G d„ d	e¦  «        Z G d
„ de¦  «        Zd„ Zd„ Zd„ Zd„ Zd d„Zed„ ¦   «         Zd„ Zej        ddfd„Zej        ddfd„Zd„ Zd„ Zd„ Zd!d„Zd„ Zd"d„Zd„ Zd„ Z d„ Z!dS )#zz
The Device Array API is not implemented in the simulator. This module provides
stubs to allow tests to import correctly.
é    )Úcontextmanager)Únumpy_versionNz™Array contains non-contiguous buffer and cannot be transferred as a single memory region. Please ensure contiguous buffer with numpy .ascontiguousarray()c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )Ú	FakeShapezº
    The FakeShape class is used to provide a shape which does not allow negative
    indexing, similar to the shape in CUDA Python. (Numpy shape arrays allow
    negative indexing)
    c                 ó¨   •— t          |t          ¦  «        r|dk     rt          d¦  «        ‚t          t          | ¦  «                             |¦  «        S )Nr   ztuple index out of range)Ú
isinstanceÚintÚ
IndexErrorÚsuperr   Ú__getitem__)ÚselfÚkÚ	__class__s     €úYC:\Projects\Historical\venv\Lib\site-packages\numba/cuda/simulator/cudadrv/devicearray.pyr   zFakeShape.__getitem__   sJ   ø€ Ý�a�ÑÔð 	9 ! a¢% %ÝÐ7Ñ8Ô8Ð8Ý•Y Ñ%Ô%×1Ò1°!Ñ4Ô4Ð4ó    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__)r   s   @r   r   r      sB   ø€ € € € € ðð ð5ð 5ð 5ð 5ð 5ð 5ð 5ð 5ð 5r   r   c                   óB   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
S )ÚFakeWithinKernelCUDAArrayaG  
    Created to emulate the behavior of arrays within kernels, where either
    array.item or array['item'] is valid (that is, give all structured
    arrays `numpy.recarray`-like semantics). This behaviour does not follow
    the semantics of Python and NumPy with non-jitted code, and will be
    deprecated and removed.
    c                 óH   — t          |t          ¦  «        sJ ‚|| j        d<   d S )NÚ_item)r   ÚFakeCUDAArrayÚ__dict__©r   Úitems     r   Ú__init__z"FakeWithinKernelCUDAArray.__init__+   s*   € Ý˜$¥Ñ.Ô.Ð.Ð.Ð.Ø!%ˆŒ�gÑÐÐr   c                 óN   — t          |t          ¦  «        rt          |¦  «        S |S ©N)r   r   r   r   s     r   Ú__wrap_if_fakez(FakeWithinKernelCUDAArray.__wrap_if_fake/   s'   € Ý�d�MÑ*Ô*ð 	Ý,¨TÑ2Ô2Ð2àˆKr   c                 óh  — 	 |t          | j        j        ¦  «        v r-|                      t	          | j        j        |¦  «        ¦  «        S |                      | j                             |¦  «        ¦  «        S # t          $ r0}t          |t          ¦  «        st          |¦  «        |‚Y d }~d S d }~ww xY wr!   )	Údirr   Ú_aryÚ(_FakeWithinKernelCUDAArray__wrap_if_fakeÚgetattrr   Ú	Exceptionr   ÚAttributeError)r   ÚattrnameÚes      r   Ú__getattr__z%FakeWithinKernelCUDAArray.__getattr__5   sÃ   € ð	6Ø�3˜tœzœÑ/Ô/Ð/Ð/Ø×*Ò*­7°4´:´?ÀHÑ+MÔ+MÑNÔNÐNà×*Ò*¨4¬:×+AÒ+AÀ(Ñ+KÔ+KÑLÔLÐLøÝð 	6ð 	6ð 	6Ý˜a¥Ñ0Ô0ð 6Ý$ XÑ.Ô.°AÐ5ð6ð 6ð 6ð 6ð 6ð 6øøøøð	6øøøs   ‚AA7 Á
,A7 Á7
B1Â%B,Â,B1c                 ó<   — | j                              ||¦  «         d S r!   ©r   Ú__setitem__)r   ÚnmÚvals      r   Ú__setattr__z%FakeWithinKernelCUDAArray.__setattr__?   s    € ØŒ
×Ò˜r 3Ñ'Ô'Ð'Ð'Ð'r   c                 ó\   — |                       | j                             |¦  «        ¦  «        S r!   )r&   r   r   )r   Úidxs     r   r   z%FakeWithinKernelCUDAArray.__getitem__B   s&   € Ø×"Ò" 4¤:×#9Ò#9¸#Ñ#>Ô#>Ñ?Ô?Ð?r   c                 ó<   — | j                              ||¦  «         d S r!   r.   ©r   r4   r1   s      r   r/   z%FakeWithinKernelCUDAArray.__setitem__E   s    € ØŒ
×Ò˜s CÑ(Ô(Ð(Ð(Ð(r   c                 ó*   — t          | j        ¦  «        S r!   )Úlenr   ©r   s    r   Ú__len__z!FakeWithinKernelCUDAArray.__len__H   s   € Ý�4”:‰ŒÐr   c                 óÚ   ‡— t          ||¦  «        }d„ Š|                     d¦  «        }|rt          ˆfd„|D ¦   «         ¦  «        |d<   t          ˆfd„|D ¦   «         ¦  «        } ||i |¤ŽS )Nc                 óH   — t          | t          ¦  «        r| j        j        } | S r!   )r   r   r   r%   ©Úobjs    r   Úconvert_fakesz@FakeWithinKernelCUDAArray.__array_ufunc__.<locals>.convert_fakesU   s#   € Ý˜#Õ8Ñ9Ô9ð %Ø”i”n�àˆJr   Úoutc              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S r!   © )Ú.0Úor?   s     €r   ú	<genexpr>z<FakeWithinKernelCUDAArray.__array_ufunc__.<locals>.<genexpr>]   s-   øè è € Ð!@Ð!@°q - -°Ñ"2Ô"2Ð!@Ð!@Ð!@Ð!@Ð!@Ð!@r   c              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S r!   rB   )rC   Úar?   s     €r   rE   z<FakeWithinKernelCUDAArray.__array_ufunc__.<locals>.<genexpr>^   s-   øè è € Ð4Ð4¨!�]�] 1Ñ%Ô%Ð4Ð4Ð4Ð4Ð4Ð4r   )r'   ÚgetÚtuple)r   ÚufuncÚmethodÚargsÚkwargsÚcallr@   r?   s          @r   Ú__array_ufunc__z)FakeWithinKernelCUDAArray.__array_ufunc__K   sœ   ø€ õ �u˜fÑ%Ô%ˆð	ð 	ð 	ð �jŠj˜ÑÔˆØð 	AÝ!Ð!@Ð!@Ð!@Ð!@¸CÐ!@Ñ!@Ô!@Ñ@Ô@ˆF�5‰MÝÐ4Ð4Ð4Ð4¨tÐ4Ñ4Ô4Ñ4Ô4ˆØˆt�TÐ$˜VÐ$Ð$Ð$r   N)r   r   r   r   r   r&   r,   r2   r   r/   r:   rO   rB   r   r   r   r   "   s™   € € € € € ðð ð&ð &ð &ðð ð ð6ð 6ð 6ð(ð (ð (ð@ð @ð @ð)ð )ð )ðð ð ð%ð %ð %ð %ð %r   r   c                   ó.  — e Zd ZdZdZd'd„Zed„ ¦   «         Zed„ ¦   «         Zd„ Z	d'd„Z
ed	„ ¦   «         Zd(d„Zd„ Zd„ Zd)d„Zd'd„Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d „ Z!d!„ Z"d"„ Z#d#„ Z$d$„ Z%d%„ Z&d'd&„Z'd
S )*r   zj
    Implements the interface of a DeviceArray/DeviceRecord, but mostly just
    wraps a NumPy array.
    Tr   c                 ó"   — || _         || _        d S r!   )r%   Ústream©r   ÚaryrR   s      r   r   zFakeCUDAArray.__init__j   s   € ØˆŒ	ØˆŒˆˆr   c                 ó   — | j         j        S r!   ©r%   Únbytesr9   s    r   Ú
alloc_sizezFakeCUDAArray.alloc_sizen   s   € àŒyÔÐr   c                 ó   — | j         j        S r!   rV   r9   s    r   rW   zFakeCUDAArray.nbytesr   s   € ð ŒyÔÐr   c                 ó€   — 	 t          | j        |¦  «        }|S # t          $ r}d|z  }t          |¦  «        |‚d }~ww xY w)Nz#Wrapped array has no attribute '%s')r'   r%   r)   )r   r*   Úattrr+   Úmsgs        r   r,   zFakeCUDAArray.__getattr__w   sV   € ð	-Ý˜4œ9 hÑ/Ô/ˆDØˆKøÝð 	-ð 	-ð 	-Ø7¸(ÑBˆCÝ  Ñ%Ô%¨1Ð,øøøøð	-øøøs   ‚ ™
=£8¸=c                 ó,   — t          | j        |¦  «        S r!   ©r   r%   )r   rR   s     r   ÚbindzFakeCUDAArray.bind   s   € Ý˜TœY¨Ñ/Ô/Ð/r   c                 ó*   — |                       ¦   «         S r!   )Ú	transposer9   s    r   ÚTzFakeCUDAArray.T‚   s   € à�~Š~ÑÔÐr   Nc                 óR   — t          t          j        | j        |¬¦  «        ¦  «        S )N)Úaxes)r   Únpra   r%   )r   rd   s     r   ra   zFakeCUDAArray.transpose†   s!   € Ý�Rœ\¨$¬)¸$Ð?Ñ?Ô?Ñ@Ô@Ð@r   c                 ó´   — | j                              |¦  «        }t          |¦  «        t          j        t          j        fvr|S t          || j        ¬¦  «        S )N©rR   )r%   r   Útypere   ÚndarrayÚvoidr   rR   )r   r4   Úrets      r   r   zFakeCUDAArray.__getitem__‰   sK   € ØŒi×#Ò# CÑ(Ô(ˆÝ�‰9Œ9�RœZ­¬Ð1Ð1Ð1ØˆJå  ¨T¬[Ð9Ñ9Ô9Ð9r   c                 ó8   — | j                              ||¦  «        S r!   )r%   r/   r6   s      r   r/   zFakeCUDAArray.__setitem__�   s   € ØŒy×$Ò$ S¨#Ñ.Ô.Ð.r   c                 ó’   — |€t          j        | j        ¦  «        }nt          | |¦  «         t          j        || j        ¦  «         |S r!   )re   Ú
empty_liker%   Úcheck_array_compatibilityÚcopytorS   s      r   Úcopy_to_hostzFakeCUDAArray.copy_to_host“   sC   € Øˆ;Ý”- ¤	Ñ*Ô*ˆCˆCå% d¨CÑ0Ô0Ð0Ý
Œ	�#�t”yÑ!Ô!Ð!Øˆ
r   c                 ó†  — t          | ¦  «         t          | ¦  «        t          |¦  «        }}t          |t          ¦  «        r t          |¦  «         t	          ||¦  «         nDt          j        ||j        d         rdnddt          dk     rdnd¬¦  «        }t	          ||¦  «         t          j	        |j
        |¦  «         dS )	a  
        Copy from the provided array into this array.

        This may be less forgiving than the CUDA Python implementation, which
        will copy data up to the length of the smallest of the two arrays,
        whereas this expects the size of the arrays to be equal.
        ÚC_CONTIGUOUSÚCÚFT©é   r   FN)ÚorderÚsubokÚcopy)Úsentry_contiguousÚ
array_corer   r   ro   re   ÚarrayÚflagsr   rp   r%   )r   rT   rR   Ú	self_coreÚary_cores        r   Úcopy_to_devicezFakeCUDAArray.copy_to_device›   sË   € õ 	˜$ÑÔÐÝ(¨Ñ.Ô.µ
¸3±´�8ˆ	Ý�c�=Ñ)Ô)ð 		;Ý˜cÑ"Ô"Ð"Ý% i°Ñ:Ô:Ð:Ð:å”xØØ&œ_¨^Ô<ÐE�c�cÀ#ØÝ+¨fÒ4Ð4�U�U¸$ð	@ñ @ô @ˆHõ
 & i°Ñ:Ô:Ð:Ý
Œ	�)”. (Ñ+Ô+Ð+Ð+Ð+r   c                 ó4   — t          | j        j        ¦  «        S r!   )r   r%   Úshaper9   s    r   rƒ   zFakeCUDAArray.shape±   s   € å˜œœÑ)Ô)Ð)r   c                 ó@   — t           | j        j        |i |¤Ž¦  «        S r!   )r   r%   Úravel©r   rL   rM   s      r   r…   zFakeCUDAArray.ravelµ   s#   € Ý˜_˜TœYœ_¨dÐ=°fÐ=Ð=Ñ>Ô>Ð>r   c                 ó@   — t           | j        j        |i |¤Ž¦  «        S r!   )r   r%   Úreshaper†   s      r   rˆ   zFakeCUDAArray.reshape¸   s%   € ÝÐ.˜TœYÔ.°Ð?¸Ð?Ð?Ñ@Ô@Ð@r   c                 ó@   — t           | j        j        |i |¤Ž¦  «        S r!   )r   r%   Úviewr†   s      r   rŠ   zFakeCUDAArray.view»   s#   € Ý˜^˜TœYœ^¨TÐ<°VÐ<Ð<Ñ=Ô=Ð=r   c                 ó$   — | j         j        j        S r!   )r%   r~   Úc_contiguousr9   s    r   Úis_c_contiguouszFakeCUDAArray.is_c_contiguous¾   ó   € ØŒyŒÔ+Ð+r   c                 ó$   — | j         j        j        S r!   )r%   r~   Úf_contiguousr9   s    r   Úis_f_contiguouszFakeCUDAArray.is_f_contiguousÁ   rŽ   r   c                 ó*   — t          | j        ¦  «        S r!   )Ústrr%   r9   s    r   Ú__str__zFakeCUDAArray.__str__Ä   ó   € Ý�4”9‰~Œ~Ðr   c                 ó*   — t          | j        ¦  «        S r!   )Úreprr%   r9   s    r   Ú__repr__zFakeCUDAArray.__repr__Ç   s   € Ý�D”I‰ŒÐr   c                 ó*   — t          | j        ¦  «        S r!   )r8   r%   r9   s    r   r:   zFakeCUDAArray.__len__Ê   r•   r   c                 ó2   — t          | j        |k    ¦  «        S r!   r^   ©r   Úothers     r   Ú__eq__zFakeCUDAArray.__eq__Ï   ó   € Ý˜TœY¨%Ò/Ñ0Ô0Ð0r   c                 ó2   — t          | j        |k    ¦  «        S r!   r^   r›   s     r   Ú__ne__zFakeCUDAArray.__ne__Ò   rž   r   c                 ó2   — t          | j        |k     ¦  «        S r!   r^   r›   s     r   Ú__lt__zFakeCUDAArray.__lt__Õ   ó   € Ý˜TœY¨Ò.Ñ/Ô/Ð/r   c                 ó2   — t          | j        |k    ¦  «        S r!   r^   r›   s     r   Ú__le__zFakeCUDAArray.__le__Ø   rž   r   c                 ó2   — t          | j        |k    ¦  «        S r!   r^   r›   s     r   Ú__gt__zFakeCUDAArray.__gt__Û   r£   r   c                 ó2   — t          | j        |k    ¦  «        S r!   r^   r›   s     r   Ú__ge__zFakeCUDAArray.__ge__Þ   rž   r   c                 ó0   — t          | j        |z   ¦  «        S r!   r^   r›   s     r   Ú__add__zFakeCUDAArray.__add__á   ó   € Ý˜TœY¨Ñ.Ñ/Ô/Ð/r   c                 ó0   — t          | j        |z
  ¦  «        S r!   r^   r›   s     r   Ú__sub__zFakeCUDAArray.__sub__ä   r¬   r   c                 ó0   — t          | j        |z  ¦  «        S r!   r^   r›   s     r   Ú__mul__zFakeCUDAArray.__mul__ç   r¬   r   c                 ó0   — t          | j        |z  ¦  «        S r!   r^   r›   s     r   Ú__floordiv__zFakeCUDAArray.__floordiv__ê   ó   € Ý˜TœY¨%Ñ/Ñ0Ô0Ð0r   c                 ó0   — t          | j        |z  ¦  «        S r!   r^   r›   s     r   Ú__truediv__zFakeCUDAArray.__truediv__í   r¬   r   c                 ó0   — t          | j        |z  ¦  «        S r!   r^   r›   s     r   Ú__mod__zFakeCUDAArray.__mod__ð   r¬   r   c                 ó0   — t          | j        |z  ¦  «        S r!   r^   r›   s     r   Ú__pow__zFakeCUDAArray.__pow__ó   r³   r   c           
      ó‚   — d„ t          j        | j        t          |t	          | ¦  «        |¦  «        ¦  «        D ¦   «         S )Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS rB   )r   )rC   rG   s     r   ú
<listcomp>z'FakeCUDAArray.split.<locals>.<listcomp>÷   s0   € ð 
ð 
ð 
àõ ˜!ÑÔð
ð 
ð 
r   )re   Úsplitr%   Úranger8   )r   ÚsectionrR   s      r   r½   zFakeCUDAArray.splitö   sC   € ð
ð 
å”X˜dœi­¨w½¸D¹	¼	À7Ñ)KÔ)KÑLÔLð
ñ 
ô 
ð 	
r   ©r   r!   )Nr   )(r   r   r   r   Ú__cuda_ndarray__r   ÚpropertyrX   rW   r,   r_   rb   ra   r   r/   rq   r�   rƒ   r…   rˆ   rŠ   r�   r‘   r”   r˜   r:   r�   r    r¢   r¥   r§   r©   r«   r®   r°   r²   rµ   r·   r¹   r½   rB   r   r   r   r   b   sy  € € € € € ðð ð
 Ððð ð ð ð ð ð  ñ „Xð ð ð ð  ñ „Xð ð-ð -ð -ð0ð 0ð 0ð 0ð ð ð  ñ „Xð ðAð Að Að Að:ð :ð :ð/ð /ð /ðð ð ð ð,ð ,ð ,ð ,ð, ð*ð *ñ „Xð*ð?ð ?ð ?ðAð Að Að>ð >ð >ð,ð ,ð ,ð,ð ,ð ,ðð ð ðð ð ðð ð ð
1ð 1ð 1ð1ð 1ð 1ð0ð 0ð 0ð1ð 1ð 1ð0ð 0ð 0ð1ð 1ð 1ð0ð 0ð 0ð0ð 0ð 0ð0ð 0ð 0ð1ð 1ð 1ð0ð 0ð 0ð0ð 0ð 0ð1ð 1ð 1ð
ð 
ð 
ð 
ð 
ð 
r   r   c                 ó¸   — | j         r| j        s| S g }| j         D ],}|                     |dk    rdnt          d¦  «        ¦  «         Œ-| t	          |¦  «                 S )aG  
    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.

    r   N)ÚstridesÚsizeÚappendÚslicerI   )rT   Ú
core_indexÚstrides      r   r|   r|   ý   sn   € ð Œ;ð ˜cœhð Øˆ
Ø€JØ”+ð =ð =ˆØ×Ò˜v¨š{˜{˜!˜!µ°d±´Ñ<Ô<Ð<Ð<Ø�u�ZÑ Ô Ô!Ð!r   c                 óÆ   — | j         j        }t          t          | j        ¦  «        t          | j        ¦  «        ¦  «        D ]\  }}|dk    r|dk    r||k    r dS ||z  }Œ dS )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.
    é   r   FT)ÚdtypeÚitemsizeÚzipÚreversedrƒ   rÄ   )rT   rÅ   rƒ   rÉ   s       r   Úis_contiguousrÐ     so   € ð Œ9Ô€DÝ�X c¤iÑ0Ô0µ(¸3¼;Ñ2GÔ2GÑHÔHð ð ‰ˆˆvØ�1Š9ˆ9˜ 1š˜Ø�vŠ~ˆ~Ø�u�uØ�E‰MˆDøØˆ4r   c                 ó„   — t          | ¦  «        }|j        d         s!|j        d         st          t          ¦  «        ‚d S d S )Nrs   ÚF_CONTIGUOUS)r|   r~   Ú
ValueErrorÚerrmsg_contiguous_buffer)rT   Úcores     r   r{   r{     sM   € Ý�c‰?Œ?€DØŒ:�nÔ%ð 3¨d¬j¸Ô.Hð 3ÝÕ1Ñ2Ô2Ð2ð3ð 3ð 3ð 3r   c                 óp  — |                       ¦   «         |                      ¦   «         }}| j        |j        k    rt          d| j        ›d|j        ›�¦  «        ‚|j        |j        k    rt	          d| j        ›d|j        ›�¦  «        ‚|j        |j        k    rt	          d| j        ›d|j        ›�¦  «        ‚d S )Nzincompatible dtype: z vs. zincompatible shape: zincompatible strides: )ÚsqueezerÌ   Ú	TypeErrorrƒ   rÓ   rÄ   )Úary1Úary2Úary1sqÚary2sqs       r   ro   ro   %  sÈ   € Ø—\’\‘^”^ T§\¢\¡^¤^ˆF€FØ„z�T”ZÒÐÝˆiØœ˜˜ T¤Z Zð1ñ 2ô 2ð 	2à„|�v”|Ò#Ð#ÝˆjØœ*˜*˜* d¤j jð2ñ 3ô 3ð 	3à„~˜œÒ'Ð'ÝˆjØœ,˜,˜,¨¬¨ð6ñ 7ô 7ð 	7ð (Ð'r   Tc           	      óî  — t          j        | t          dk     rdnd d¬¦  «        } t          | ¦  «         |€¨| j        j        dv rt           j        n| j        }t          t          j        t          j	        t          | ¦  «        ¦  «                             |¦  «        | j        | j        | j        ¬¦  «                             t          | ¦  «        ¬¦  «        ¦  «        S |                     | |¬¦  «         d S )	Nrv   FT©rz   ry   ÚMm)ÚbufferrÌ   rƒ   rÄ   )rh   rg   )re   r}   r   r{   rÌ   ÚcharÚint64r   ri   rz   r|   rŠ   rƒ   rÄ   rh   r�   )rT   rR   rz   ÚtoÚbuffer_dtypes        r   Ú	to_devicerå   2  sì   € Ý
Œ(�3Ý!.°Ò!7Ð!7˜˜¸TØðñ ô €Cõ �cÑÔÐØ	€zØ#&¤9¤>°TÐ#9Ð#9•r”x�x¸s¼yˆÝÝŒJÝ”w�z¨#™œÑ/Ô/×4Ò4°\ÑBÔBØ”iØ”iØœð	ñ ô ÷
 Šd�˜S™	œ	ˆdÑ"Ô"ñ
ô 
ð 	
ð 	×Ò˜# fÐÑ-Ô-Ð-Ð-Ð-r   c              #   ó   K  — d V — d S r!   rB   )Úargs    r   Úpinnedrè   E  s   è è € à	€E€E€E€E€Er   c                  óV   — dD ]}||v r|                      |¦  «         Œt          | i |¤ŽS )N)ÚportableÚwc)ÚpopÚdevice_array)rL   rM   Ú
unused_args      r   Úmapped_arrayrï   J  sB   € Ø(ð #ð #ˆ
Ø˜ÐÐØ�JŠJ�zÑ"Ô"Ð"øÝ˜Ð( Ð(Ð(Ð(r   rt   c                 ó2   — t          j        | |||¬¦  «        S ©N)rƒ   rÄ   rÌ   rx   ©re   ri   ©rƒ   rÌ   rÄ   rx   s       r   Úpinned_arrayrô   Q  ó   € ÝŒ:˜E¨7¸%ÀuÐMÑMÔMÐMr   c                 ó2   — t          j        | |||¬¦  «        S rñ   rò   ró   s       r   Úmanaged_arrayr÷   U  rõ   r   c                  óx   — d|v r|                      d¦  «        nd}t          t          j        | i |¤Ž|¬¦  «        S )NrR   r   rg   )rì   r   re   ri   )rL   rM   rR   s      r   rí   rí   Y  sD   € Ø%-°Ð%7Ð%7ˆV�ZŠZ˜Ñ!Ô!Ð!¸Q€FÝ�œ TÐ4¨VÐ4Ð4¸VÐDÑDÔDÐDr   c                 óZ  — | j         d         s| j         d         s| j        dk    rdS d„ t          | j        ¦  «        D ¦   «         }|                     d„ ¬¦  «         dgt          | j        ¦  «        z  }| j        j        }|D ]\  }}|||<   || j        |         z  }Œt          |¦  «        S )	z[
    Given an array, compute strides for a new contiguous array of the same
    shape.
    rs   rÒ   rË   Nc                 ó   — g | ]}|‘ŒS rB   rB   )rC   Úxs     r   r¼   z2_contiguous_strides_like_array.<locals>.<listcomp>o  s   € Ð6Ð6Ð6˜�1Ð6Ð6Ð6r   c                 ó   — | d         S )NrË   rB   )rû   s    r   ú<lambda>z0_contiguous_strides_like_array.<locals>.<lambda>p  s
   €  ! A¤$€ r   )Úkeyr   )
r~   ÚndimÚ	enumeraterÄ   Úsortr8   rÌ   rÍ   rƒ   rI   )rT   Ú
stridepermrÄ   rÉ   Úi_permÚ_s         r   Ú_contiguous_strides_like_arrayr  ^  sÂ   € ð „y�Ô ð  C¤I¨nÔ$=ð ÀÄÈQÂÀØˆtð 7Ð6�i¨¬Ñ4Ô4Ð6Ñ6Ô6€JØ‡O‚O˜˜€OÑ'Ô'Ð'ð ˆc•C˜œÑ$Ô$Ñ$€GØŒYÔ€FØð $ð $‰	ˆ�Ø ˆ�‰Ø�#”)˜FÔ#Ñ#ˆˆÝ�‰>Œ>Ðr   c                 ó>   — | j         d         r| j         d         sdS dS )NrÒ   rs   ru   rt   )r~   )rT   s    r   Ú_order_like_arrayr  {  s)   € Ø
„y�Ô ð ¨¬°>Ô)Bð Øˆsàˆsr   c                 óx   — t          | ¦  «        }t          | ¦  «        }t          | j        | j        ||¬¦  «        S ©Nró   )r  r  rí   rƒ   rÌ   )rT   rR   rÄ   rx   s       r   Údevice_array_liker
  ‚  ó@   € Ý,¨SÑ1Ô1€GÝ˜cÑ"Ô"€EÝ˜cœi¨s¬yÀ'Ø#ð%ñ %ô %ð %r   c                 óx   — t          | ¦  «        }t          | ¦  «        }t          | j        | j        ||¬¦  «        S r	  )r  r  rô   rƒ   rÌ   )rT   rÄ   rx   s      r   Úpinned_array_liker  ‰  r  r   c                 óÖ   — t          | t          ¦  «        r| dfS t          | t          j        ¦  «        s$t          j        | t
          dk     rdnd d¬¦  «        } t          | ||¦  «        dfS )NFrv   TrÞ   )r   r   re   rj   r}   r   rå   )rT   rR   rz   s      r   Úauto_devicer  �  sx   € Ý�#•}Ñ%Ô%ð Ø�EˆzÐå�c�2œ7Ñ#Ô#ð ÝŒhØÝ'¨&Ò0Ð0��°dØðñ ô ˆõ �S˜& $Ñ'Ô'¨Ð-Ð-r   c                 ó$   — t          | dd¦  «        S )z$Check if an object is a CUDA ndarrayrÁ   F)r'   r=   s    r   Úis_cuda_ndarrayr  œ  s   € å�3Ð*¨EÑ2Ô2Ð2r   c                 óÂ   ‡ — t          ‰ ¦  «         ˆ fd„} |dt          ¦  «          |dt          ¦  «          |dt          j        ¦  «          |dt          ¦  «         dS )z,Verify the CUDA ndarray interface for an objc                 óª   •— t          ‰| ¦  «        st          | ¦  «        ‚t          t          ‰| ¦  «        |¦  «        st          | ›d|›�¦  «        ‚d S )Nz must be of type )Úhasattrr)   r   r'   )r[   Útypr>   s     €r   Úrequires_attrz4verify_cuda_ndarray_interface.<locals>.requires_attr¥  se   ø€ Ý�s˜DÑ!Ô!ð 	'Ý  Ñ&Ô&Ð&Ý�' # tÑ,Ô,¨cÑ2Ô2ð 	HÝ ¸D¸D¸DÀ#À#Ð!FÑGÔGÐGð	Hð 	Hr   rƒ   rÄ   rÌ   rÅ   N)Úrequire_cuda_ndarrayrI   re   rÌ   r	   )r>   r  s   ` r   Úverify_cuda_ndarray_interfacer  ¡  s�   ø€ å˜ÑÔÐðHð Hð Hð Hð Hð €M�'�5Ñ!Ô!Ð!Ø€M�)�UÑ#Ô#Ð#Ø€M�'�2œ8Ñ$Ô$Ð$Ø€M�&�#ÑÔÐÐÐr   c                 óB   — t          | ¦  «        st          d¦  «        ‚dS )z9Raises ValueError is is_cuda_ndarray(obj) evaluates Falsezrequire an cuda ndarray objectN)r  rÓ   r=   s    r   r  r  ±  s+   € å˜3ÑÔð ;ÝÐ9Ñ:Ô:Ð:ð;ð ;r   )r   TNrÀ   )r   T)"r   Ú
contextlibr   Únumba.np.numpy_supportr   Únumpyre   ÚDeviceRecordÚfrom_record_likerÔ   rI   r   Úobjectr   r   r|   rÐ   r{   ro   rå   rè   rï   Úfloat64rô   r÷   rí   r  r  r
  r  r  r  r  r  rB   r   r   ú<module>r!     s<  ððð ð &Ð %Ð %Ð %Ð %Ð %Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0à Ð Ð Ð ð €ØÐ ð3Ð ð
5ð 
5ð 
5ð 
5ð 
5�ñ 
5ô 
5ð 
5ð=%ð =%ð =%ð =%ð =% ñ =%ô =%ð =%ð@X
ð X
ð X
ð X
ð X
�Fñ X
ô X
ð X
ðv"ð "ð "ð$ð ð ð 3ð 3ð 3ð
7ð 
7ð 
7ð.ð .ð .ð .ð& ð
ð 
ñ „ð
ð)ð )ð )ð !œj°$¸cð Nð Nð Nð Nð  "œz°4¸sð Nð Nð Nð NðEð Eð Eð
ð ð ð:ð ð ð%ð %ð %ð %ð%ð %ð %ð	.ð 	.ð 	.ð 	.ð3ð 3ð 3ð
ð ð ð ;ð ;ð ;ð ;ð ;r   