o
    پi                     @   sH   d dl Z d dl mZmZ d dlZG dd deZG dd de jdZdS )    N)ABCabstractmethodc                   @   s$   e Zd ZedejdefddZdS )
Serializertreturnc                 C      t )aZ  
        Serialize a pytorch tensor to bytes. The serialized bytes should contain
        both the data and the metadata (shape, dtype, etc.) of the tensor.

        Input:
            t: the input pytorch tensor, can be on any device, in any shape,
               with any dtype

        Returns:
            bytes: the serialized bytes
        NotImplementedError)selfr    r   T/home/ubuntu/.local/lib/python3.10/site-packages/sglang/srt/connector/serde/serde.pyto_bytes   s   zSerializer.to_bytesN)__name__
__module____qualname__r   torchTensorbytesr   r   r   r   r   r   	   s    r   c                   @   s,   e Zd Zdd ZededejfddZdS )Deserializerc                 C   s
   || _ d S )N)dtype)r
   r   r   r   r   __init__   s   
zDeserializer.__init__bsr   c                 C   r   )z
        Deserialize a pytorch tensor from bytes.

        Input:
            bytes: a stream of bytes

        Output:
            torch.Tensor: the deserialized pytorch tensor
        r   )r
   r   r   r   r   
from_bytes    s   zDeserializer.from_bytesN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    r   )	metaclass)abcr   r   r   r   ABCMetar   r   r   r   r   <module>   s
   