o
    W۷i'                     @  s6   d dl mZ d dlZd dlmZ dd ZdddZdS )	    )annotationsN)_corec                 C  sp  zt |}W n ty   |f}Y nw t|}|dt|kr.t| tjr.tj| d|dS tj| d|d}||jk rDd|j|  | }t dd t	|j
|D }|jdkr^tj||jd	S g }g }t	|j
|D ]6\}}	|	dkr{|| || qh|dkr|| ||	 qh|d || ||	 || qhtj||jd	}
|
jrt|||
 |
|S )
a   Construct an array by repeating A the number of times given by reps.

    Args:
        A (cupy.ndarray): Array to transform.
        reps (int or tuple): The number of repeats.

    Returns:
        cupy.ndarray: Transformed array with repeats.

    .. seealso:: :func:`numpy.tile`

       T)copyndminF)r   c                 s  s    | ]	\}}|| V  qd S N ).0str   r   O/home/ubuntu/vllm_env/lib/python3.10/site-packages/cupy/_manipulation/tiling.py	<genexpr>#   s    ztile.<locals>.<genexpr>r   )dtype)tuple	TypeErrorlencount
isinstancecupyndarrayarrayndimzipshapesizeemptyr   appendr   elementwise_copyreshape)Arepstupdc	shape_outc_shape	ret_shapedim_innrepretr   r   r   tile   s>   








r*   c                 C  s   |  ||S )a+  Repeat arrays along an axis.

    Args:
        a (cupy.ndarray): Array to transform.
        repeats (int, list or tuple): The number of repeats.
        axis (int): The axis to repeat.

    Returns:
        cupy.ndarray: Transformed array with repeats.

    .. seealso:: :func:`numpy.repeat`

    )repeat)arepeatsaxisr   r   r   r+   :   s   r+   r   )
__future__r   r   r   r*   r+   r   r   r   r   <module>   s
    3