o
    g                     @   sL   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 )    )	getLogger)FusionAttentionClip)
ModelProto)BertOnnxModelc                       s<   e Zd Zddededef fddZdd Zd	d
 Z  ZS )ClipOnnxModelr   model	num_headshidden_sizec                    s(   t  j|||d t| | j| j| _d S )N)r   r	   )super__init__r   r	   r   clip_attention_fusion)selfr   r   r	   	__class__ _/var/www/visachat/venv/lib/python3.10/site-packages/onnxruntime/transformers/onnx_model_clip.pyr      s   zClipOnnxModel.__init__c                 C   s@   i }g d}|D ]}|  |}t|||< qtd|  |S )z8
        Returns node count of fused operators.
        )	AttentionGeluLayerNormalization	QuickGeluSkipLayerNormalizationzOptimized operators:)get_nodes_by_op_typelenloggerinfo)r   op_countopsopnodesr   r   r   get_fused_operator_statistics   s   
z+ClipOnnxModel.get_fused_operator_statisticsc                 C   s   | j   d S )N)r   apply)r   r   r   r   fuse_attention'   s   zClipOnnxModel.fuse_attention)r   r   )	__name__
__module____qualname__r   intr   r   r!   __classcell__r   r   r   r   r      s    r   N)loggingr   fusion_attention_clipr   onnxr   onnx_model_bertr   r"   r   r   r   r   r   r   <module>   s   