o
    XÛ·iÎ
  ã                   @  sD   d dl mZ d dlZd dlmZ dZG dd„ dƒZG dd„ dƒZdS )	é    )ÚannotationsN)Úcudaé   c                   @  s$   e Zd Z	ddd„Zedd„ ƒZdS )	Ú!DummyObjectWithCudaArrayInterfacer   FNc                 C  sf   |t ttd ƒƒv sJ ‚d | _t|tjƒr|| _n|\| _| _| _	| _
| _|| _|| _|| _|| _d S )Né   )ÚtupleÚrangeÚ max_cuda_array_interface_versionÚaÚ
isinstanceÚcupyÚndarrayÚshapeÚstridesÚtypestrÚdescrÚdataÚverÚinclude_stridesÚmaskÚstream)Úselfr
   r   r   r   r   © r   úT/home/ubuntu/vllm_env/lib/python3.10/site-packages/cupy/testing/_protocol_helpers.pyÚ__init__   s   
z*DummyObjectWithCudaArrayInterface.__init__c                 C  s:  | j d ur?| j j| j jj| j jj| j jjdf| jdœ}| j jj	r8| j
du r,| j j|d< n8| j
d u r6d |d< n.	 n,| j j|d< n%| j| j| j| jdf| jdœ}| j
du rY| j|d< n| j
d u rcd |d< n	 | jd urn| j|d< | jd ur›| jtjju r‚tjj|d< |S tjjs•| jtjju r•tjj|d< |S | jj|d< |S )NF)r   r   r   r   ÚversionTr   r   r   )r
   r   ÚdtypeÚstrr   r   Úptrr   ÚflagsÚc_contiguousr   r   r   r   r   r   ÚStreamÚnullÚruntimeÚstreamLegacyÚis_hipÚptdsÚstreamPerThread)r   Údescr   r   r   Ú__cuda_array_interface__   sH   
û



û





üÿz:DummyObjectWithCudaArrayInterface.__cuda_array_interface__)r   FNN)Ú__name__Ú
__module__Ú__qualname__r   Úpropertyr)   r   r   r   r   r   
   s
    
ÿr   c                   @  s   e Zd Zdd„ Zdd„ ZdS )ÚDummyObjectWithCuPyGetNDArrayc                 C  s
   || _ d S ©N©r
   )r   r
   r   r   r   r   L   s   
z&DummyObjectWithCuPyGetNDArray.__init__c                 C  s   | j S r/   r0   )r   r   r   r   Ú__cupy_get_ndarray__O   s   z2DummyObjectWithCuPyGetNDArray.__cupy_get_ndarray__N)r*   r+   r,   r   r1   r   r   r   r   r.   J   s    r.   )Ú
__future__r   r   r   r	   r   r.   r   r   r   r   Ú<module>   s    @