o
    
۾i                     @   s`   d dl mZ d dlmZ d dlZd dlZd dlmZ er"d dlm	Z	 ddde
d	ejfd
dZdS )    )BytesIO)TYPE_CHECKINGN)VLLMValidationError)ModelConfigmodel_configr   embedreturnc                 C   s   | j s	tdddtj 1 tjttj|dddt	dd}t
|tjr2|jtjtjtjfv s4J | }W d    n1 sBw   Y  | dkrZ|d	}| dksZJ |S )
Nz?You must set `--enable-prompt-embeds` to input `prompt_embeds`.prompt_embeds)	parameterT)validatecpu)weights_onlymap_location   r   )enable_prompt_embedsr   torchsparsecheck_sparse_tensor_invariantsloadr   pybase64	b64decodedevice
isinstanceTensordtypefloat32bfloat16float16to_densedimsqueeze)r   r   tensor r"   N/home/ubuntu/.local/lib/python3.10/site-packages/vllm/renderers/embed_utils.pysafe_load_prompt_embeds   s,   


r$   )ior   typingr   r   r   vllm.exceptionsr   vllm.configr   bytesr   r$   r"   r"   r"   r#   <module>   s   