o
    3Ih
                     @   sJ   d dl 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)Fusion)helper)	OnnxModelc                       s*   e Zd Zdef fddZdd Z  ZS )FusionQuickGelumodelc                    s   t  |ddg d S )N	QuickGeluMul)super__init__)selfr   	__class__ i/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/onnxruntime/transformers/fusion_quickgelu.pyr
      s   zFusionQuickGelu.__init__c           
      C   sT  |j dkrtd d S |}|jd }| j|dgdg}|d u r(td d S |d }| j|dgdg}|d u rAtd d S |d }| j|jd  }t|d d	kr_td
 d S |jd |krmtd d S t	j
d|g|jd g| jdd}	d|	_|	jt	d|g | j|||g | j|	 | j| j|	j< | d d S )Nr   z/fuse_quickgelu: failed to match second Mul noder   Sigmoid   z,fuse_quickgelu: failed to match Sigmoid nodez.fuse_quickgelu: failed to match first Mul nodeg     <?gMbP?z3fuse_quickgelu: failed to match approximation valuezFfuse_quickgelu: failed to match root input with first Mul node's inputr   )inputsoutputsnamezcom.microsoftalpha)op_typeloggerdebuginputr   match_parent_pathget_constant_valueitemabsr   	make_nodeoutputcreate_node_namedomain	attributeextendmake_attributenodes_to_removenodes_to_addappendthis_graph_namenode_name_to_graph_namer   increase_counter)
r   nodeinput_name_to_nodesoutput_name_to_nodesecond_mul_node
root_inputsigmoid_nodefirst_mul_nodeapproximation_valuenew_noder   r   r   fuse   sD   








zFusionQuickGelu.fuse)__name__
__module____qualname__r   r
   r4   __classcell__r   r   r   r   r      s    r   )loggingfusion_baser   onnxr   
onnx_modelr   	getLoggerr5   r   r   r   r   r   r   <module>   s   
