
    `iA                     L    S SK r SSKJr  SSKJrJr  S SK Jr    " S S\5      rg)	    N   )QuantOperatorBase   )attribute_to_kwarg	ms_domain)onnx_pbc                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )AttentionQuant
   c                 $   > [         TU ]  X5        g )N)super__init__)selfonnx_quantizer	onnx_node	__class__s      q/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnxruntime_tools/quantization/operators/attention.pyr   AttentionQuant.__init__   s    3    c                 ~   U R                   nUR                  S:X  d   eU R                  R                  USS/5      u  p#pEUR                  S:X  a  SOUR                  S-   n/ nUR                  U5        UR                  UR                  S   /5        UR                  U5        UR                  [        UR                  5      S:  a  UR                  S   OS/5        UR                  U5        UR                  [        UR                  5      S:  a  UR                  S   OS/5        0 nUR                   H  n	UR                  [        U	5      5        M     [        US	'   [        R                  R                  " S
XqR                  U40 UD6n
UR!                  U
5        U R                  =R"                  U-  sl        g)z
parameter node: Attention node.
parameter new_nodes_list: List of new nodes created before processing this node.
return: a list of nodes in topological order that represents quantized Attention node.
	Attentionr   r    _quantr         domain
QAttentionN)nodeop_type	quantizerquantize_inputsnameextendinputlen	attributeupdater   r   onnxhelper	make_nodeoutputappend	new_nodes)r   r   quantized_input_nameszero_point_namesscale_namesnodesqattention_nameinputskwargsr&   qattention_nodes              r   quantizeAttentionQuant.quantize   sd    yy+,+ NN**4!Q8 	F	+ !%		R"TYY5I+,tzz!}o&k"DJJ!(;tzz!}DE&'DJJ!(;tzz!}DEIMM,Y78 ($x++//fkkSbmflm_%  E) r    )__name__
__module____qualname____firstlineno__r   r6   __static_attributes____classcell__)r   s   @r   r
   r
   
   s    4* *r   r
   )	r(   base_operatorr   quant_utilsr   r   r   
onnx_protor
   r8   r   r   <module>rB      s#     , 7 &
!*& !*r   