o
    0 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   d/home/app/PaddleOCR-VL-test/.venv_paddleocr/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   )Z_where).typeboolintfloatcomplexnumpyemptyr	   copytor   Z_FusionVarScalarr   Z_ScalarProxycan_cast
isinstanceZndarrayZisscalarsize
ValueErroritem	TypeErrorZ
_is_fusingr   Zelementwise_copyZ_call_ufuncr   Z_where_ufuncall	itertoolszip_longestreversedshapendimZsqueezetuplerange_can_memcpydataZcopy_from_asyncnbytesdevicer   Z	getDeviceZ	setDeviceidcopy)dstsrcr
   whereZsrc_is_scalarZsrc_typeZdst_arrr   Z	src_dtypeZsqueeze_ndimr+   Z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/   r2   r3   r   r   r   r(   s   s
   
r(   )r   N)r!   r   Zcupyr   Z
cupy._corer   r   Zcupy._sortingr   Zcupy_backends.cuda.apir   r   r(   r   r   r   r   <module>   s    
g