o
    
jd                     @   sV   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 	e
ZG dd deZdS )    N)AttentionMask)FusionConformerAttention)FusionOptions)BertOnnxModelc                       sH   e Zd Z fddZddedB def fddZd	d
 Zdd Z  Z	S )ConformerOnnxModelc                    s4   t  ||| t| | _t| | j| j| j| _d S N)super__init__r   attention_maskr   hidden_size	num_headsattention_fusion)selfmodelr   r   	__class__ `/home/kuhnn/.local/lib/python3.10/site-packages/onnxruntime/transformers/onnx_model_conformer.pyr	      s   
zConformerOnnxModel.__init__NFoptionsadd_dynamic_axesc                    s>   |d u rdn|j | j_ |d u rdn|j| j_t || d S NF)use_multi_head_attentionr   !disable_multi_head_attention_biasr   optimize)r   r   r   r   r   r   r      s   zConformerOnnxModel.optimizec                 C   s   | j   d S r   )r   applyr   r   r   r   fuse_attention   s   z!ConformerOnnxModel.fuse_attentionc                 C   s   |    d S r   )adjust_reshape_and_expandr   r   r   r   
preprocess   s   zConformerOnnxModel.preprocessr   )
__name__
__module____qualname__r	   r   boolr   r   r   __classcell__r   r   r   r   r      s
    r   )loggingfusion_attentionr   fusion_conformer_attentionr   fusion_optionsr   onnx_model_bertr   	getLoggerr   loggerr   r   r   r   r   <module>   s   
