U
    /e                     @  s   d dl mZ d dlZd dlZd dlZd dlZd dlmZmZ d dl	m
Z
mZ eedreejdd Zeejdd	 Zeejd
d Ze
ejdd ZdS )    )annotationsN)cuda_deserializecuda_serialize)dask_deserializedask_serializeDeviceBufferc                 C  s    | j  }d|d< | g}||fS )N)   strides)Z__cuda_array_interface__copyxheaderframes r   </tmp/pip-unpacked-wheel-g426oqom/distributed/protocol/rmm.py cuda_serialize_rmm_device_buffer   s    
r   c                 C  s   |\}t |tjst|S )N)
isinstancermmr   AssertionError)r   r   arrr   r   r   "cuda_deserialize_rmm_device_buffer   s    r   c                 C  s"   t | \}}dd |D }||fS )Nc                 S  s   g | ]}t j| jqS r   )numbaZcudaZas_cuda_arrayZcopy_to_hostdata).0fr   r   r   
<listcomp>#   s     z4dask_serialize_rmm_device_buffer.<locals>.<listcomp>)r   r   r   r   r    dask_serialize_rmm_device_buffer    s    r   c                 C  s:   |\}t t|}|jd d }|j}tj||d}|S )Nr   r   )ptrsize)numpyZasarray
memoryviewZ__array_interface__nbytesr   r   )r   r   framer   r   r   bufr   r   r   "dask_deserialize_rmm_device_buffer&   s    r$   )
__future__r   r   Z
numba.cudar   r   Zdistributed.protocol.cudar   r   Zdistributed.protocol.serializer   r   hasattrregisterr   r   r   r   r$   r   r   r   r   <module>   s   








