o
    áÙ·iC  ã                   @   sp   d dl Z d dlmZ dee dedee fdd„Zde jd	edeee  fd
d„Z	de jde
de jfdd„ZdS )é    N©Úmaybe_prefixÚweightsÚprefixÚreturnc                    s   ‡ fdd„| D ƒS )z:
    Add a prefix to the names of the loaded weights.
    c                    s   h | ]}t ˆ |ƒ’qS © r   )Ú.0Úname©r   r   úY/home/ubuntu/.local/lib/python3.10/site-packages/vllm_omni/model_executor/models/utils.pyÚ	<setcomp>	   s    z/add_prefix_to_loaded_weights.<locals>.<setcomp>r   )r   r   r   r
   r   Úadd_prefix_to_loaded_weights   s   r   ÚlstÚintervalc                 C   st   |   ¡ dkrg S |  ¡  ¡  ¡ }tt | ¡ ¡ ƒ}dd„ t|| d ƒD ƒ}|D ]}t|| ƒ}||  	|¡ q(|S )Nr   c                 S   s   g | ]}g ‘qS r   r   )r   Ú_r   r   r   Ú
<listcomp>   s    z*split_list_into_ranges.<locals>.<listcomp>é   )
ÚnumelÚdetachÚcpuÚtolistÚintÚtorchÚmaxÚitemÚrangeÚappend)r   r   Ú	data_listÚmax_valÚrangesÚnumÚindexr   r   r   Úsplit_list_into_ranges   s   r"   ÚtensorÚshapec                 C   s   | du rdS |   |¡S )z"
    Reshape a tensor safely.
    N)Úreshape)r#   r$   r   r   r   Úsafe_tensor_reshape!   s   
r&   )r   Ú vllm.model_executor.models.utilsr   ÚsetÚstrr   ÚTensorr   Úlistr"   Útupler&   r   r   r   r   Ú<module>   s
     