o
    ְi                     @   sb   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 ddd	Zd
d ZdS )    N)_core)_fusion_interface)fusion)search)runtime	same_kindc              	   C   sF  d}t |}|ttttfv r#tjd| jd}tj|||d d}d}nG|t	j
tjfv r9|j}t|| j|}d}n1t|tjsDt|r_|jdkrMtd|j}t|| j|}| }d}n|j}t|| j|}|svtd|| j|f t	 r|d	u rt||  d	S t	tj||| |  d	S |std
d tjt|jt| jddD std|j d| j |j | j  }	|	dkr|!t"t#|	}|d	urtj|| |d d	S | jdkrd	S |rt||  d	S t$| |r| j%&|j%|j' d	S | j(}
t)* }zt)+|
j, |j(|
kr|- }t||  W t)+| d	S t)+| w )a  Copies values from one array to another with broadcasting.

    This function can be called for arrays on different devices. In this case,
    casting, ``where``, and broadcasting is not supported, and an exception is
    raised if these are used.

    Args:
        dst (cupy.ndarray): Target array.
        src (cupy.ndarray): Source array.
        casting (str): Casting rule. See :func:`numpy.can_cast` for detail.
        where (cupy.ndarray of bool): If specified, this array acts as a mask,
            and an element is copied only if the corresponding element of
            ``where`` is True.

    .. seealso:: :func:`numpy.copyto`

    F )dtype)castingT   z2non-scalar numpy.ndarray cannot be used for copytoz'Cannot cast %s to %s in %s casting modeNc                 S   s   g | ]
\}}||d fv qS )r   r   ).0sdr   r   L/home/ubuntu/.local/lib/python3.10/site-packages/cupy/_manipulation/basic.py
<listcomp>L   s    
zcopyto.<locals>.<listcomp>)	fillvaluez+could not broadcast input array from shape z into shape r   )_where).typeboolintfloatcomplexnumpyemptyr	   copytor   _FusionVarScalarr   _ScalarProxycan_cast
isinstancendarrayisscalarsize
ValueErroritem	TypeError
_is_fusingr   elementwise_copy_call_ufuncr   _where_ufuncall	itertoolszip_longestreversedshapendimsqueezetuplerange_can_memcpydatacopy_from_asyncnbytesdevicer   	getDevice	setDeviceidcopy)dstsrcr
   wheresrc_is_scalarsrc_typedst_arrr   	src_dtypesqueeze_ndimr6   prev_devicer   r   r   r      s   



r   c                 C   s@   | j jo|j j}| j jo|j j}|s|o| j|jko| j|jkS )N)flagsc_contiguousf_contiguousr	   r!   )r;   r<   rE   rF   r   r   r   r2   s   s
   
r2   )r   N)r*   r   cupyr   
cupy._corer   r   cupy._sortingr   cupy_backends.cuda.apir   r   r2   r   r   r   r   <module>   s    
g