
    fPid                     z    d dl Z d dlmZ d dlmZ d dlmZ d dlmZ  e j	        e
          Z G d de          ZdS )    N)AttentionMask)FusionConformerAttention)FusionOptions)BertOnnxModelc                   F     e Zd Z fdZd	dedz  def fdZd Zd Z xZ	S )
ConformerOnnxModelc                     t                                          |||           t          |           | _        t	          | | j        | j        | j                  | _        d S N)super__init__r   attention_maskr   hidden_size	num_headsattention_fusion)selfmodelr   r   	__class__s       /home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/onnxruntime/transformers/onnx_model_conformer.pyr   zConformerOnnxModel.__init__   sV    	;777+D11 8t?OQUQ_aeat u u    NFoptionsadd_dynamic_axesc                     |dn|j         | j        _         |dn|j        | j        _        t                                          ||           d S NF)use_multi_head_attentionr   !disable_multi_head_attention_biasr   optimize)r   r   r   r   s      r   r   zConformerOnnxModel.optimize   sV    BI/W^Ww6_EE'*S 	? 	"233333r   c                 8    | j                                          d S r
   )r   applyr   s    r   fuse_attentionz!ConformerOnnxModel.fuse_attention   s    ##%%%%%r   c                 .    |                                   d S r
   )adjust_reshape_and_expandr   s    r   
preprocesszConformerOnnxModel.preprocess   s    &&(((((r   r   )
__name__
__module____qualname__r   r   boolr   r    r#   __classcell__)r   s   @r   r   r      s        v v v v v
4 4 4 4t 4 4 4 4 4 4& & &) ) ) ) ) ) )r   r   )loggingfusion_attentionr   fusion_conformer_attentionr   fusion_optionsr   onnx_model_bertr   	getLoggerr$   loggerr    r   r   <module>r1      s   
  * * * * * * ? ? ? ? ? ? ( ( ( ( ( ( ) ) ) ) ) )		8	$	$) ) ) ) ) ) ) ) ) )r   