o
    i                     @   s   U d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 ee
Zed ZeeZeedf ed< ed ZeeZeedf ed	< eG d
d dZdS )    )AnyLiteralget_args)config)init_logger)	safe_hash)CLSLASTMEAN.SEQ_POOLING_TYPES)ALLSTEPTOK_POOLING_TYPESc                   @   s  e Zd ZU dZdZeeB dB ed< 	 dZedB ed< 	 dZ	edB ed< 	 dZ
edB ed< 	 dZedB ed< 	 dZedB ed< 	 dZedB ed	< 	 dZedB ed
< 	 dZedB ed< 	 dZee dB ed< 	 dddZdefddZdefddZdefddZdS )PoolerConfigz:Controls the behavior of output pooling in pooling models.Npooling_typeseq_pooling_typetok_pooling_typeuse_activation
dimensionsenable_chunked_processingmax_embed_len
logit_biasstep_tag_idreturned_token_idsreturnc                 C   sz   | j  }r;| jd urtd| jd urtd|tv r'td|| || _d S |tv r7td|| || _d S t|d S )Nz5Cannot set both `pooling_type` and `seq_pooling_type`z5Cannot set both `pooling_type` and `tok_pooling_type`z4Resolved `pooling_type=%r` to `seq_pooling_type=%r`.z4Resolved `pooling_type=%r` to `tok_pooling_type=%r`.)	r   r   
ValueErrorr   r   loggerdebugr   NotImplementedError)selfr    r    H/home/ubuntu/vllm_env/lib/python3.10/site-packages/vllm/config/pooler.py__post_init__^   s2   




zPoolerConfig.__post_init__c                 C      | j d us	J d| j S Nz!Should be resolved by ModelConfig)r   r   r    r    r!   get_seq_pooling_typez      z!PoolerConfig.get_seq_pooling_typec                 C   r#   r$   )r   r%   r    r    r!   get_tok_pooling_type~   r'   z!PoolerConfig.get_tok_pooling_typec                 C   s    g }t t| dd }|S )a  
        WARNING: Whenever a new field is added to this config,
        ensure that it is included in the factors list if
        it affects the computation graph.

        Provide a hash that uniquely identifies all the configs
        that affect the structure of the computation
        graph from input ids/embeddings to the final hidden states,
        excluding anything before input ids/embeddings and after
        the final hidden states.
        F)usedforsecurity)r   strencode	hexdigest)r   factorshash_strr    r    r!   compute_hash   s   zPoolerConfig.compute_hash)r   N)__name__
__module____qualname____doc__r   SequencePoolingTypeTokenPoolingType__annotations__r   r   r   boolr   intr   r   r   floatr   r   listr"   r&   r(   r*   r/   r    r    r    r!   r      s4   
 	
r   N)typingr   r   r   vllm.config.utilsr   vllm.loggerr   vllm.utils.hashingr   r0   r   r4   r   tupler6   r5   r   r   r    r    r    r!   <module>   s   