§
    Ÿ²Åj¤R  ã                   óN  — d dl Z d dlZd dlmZmZmZmZmZmZm	Z	 d dl
Z
d dlmc mc mc mZ d dlmc mc mZ d dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZ dd	lm Z m!Z! e
j"        j        Z# G d
„ de j$        ¦  «        Z%dedededee&ee          f         dee%e%f         f
d„Z'dededee&ee          f         deee	e
j(        e)f         e	e
j(        e*f         f                  fd„Z+dededefd„Z,dedede*fd„Z-dedee*         fd„Z.dedede&fd„Z/de!de&de!fd„Z0de!ddfd„Z1d„ Z2e2de
j(        de
j(        de
j(        fd„¦   «         Z3e2de
j(        de
j(        de
j(        fd„¦   «         Z4e2de
j(        de
j(        de
j(        fd „¦   «         Z5dede6fd!„Z7deded"e*defd#„Z8dS )$é    N)ÚCallableÚDictÚListÚOptionalÚSetÚTupleÚUnion)ÚFakeQuantizeBaseÚObserverBase)Ú_is_activation_post_process)Úgetattr_from_fqn)ÚGraphModule)ÚNodeé   )ÚNSNodeTargetTypeÚNSResultsTypec                   ó¤   — e Zd Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z ej        ¦   «         Z	dS )ÚNodeInputOrOutputTypeN)
Ú__name__Ú
__module__Ú__qualname__ÚenumÚautoÚFP32ÚINT8ÚFP16ÚUNKNOWNÚFP32_OR_INT8© ó    úEC:\Projects\Historical\venv\Lib\site-packages\torch/ao/ns/fx/utils.pyr   r      sQ   € € € € € Øˆ4Œ9‰;Œ;€DØˆ4Œ9‰;Œ;€DØˆ4Œ9‰;Œ;€DØˆdŒi‰kŒk€Gð
 �4”9‘;”;€L€L€Lr    r   ÚnodeÚgmÚ
logger_clsÚnode_type_to_io_type_mapÚreturnc                 ón  ‡— |d         }|d         }|d         }|d         }|d         }|d         }	|d         }
|d         }| j         d	k    rÅ| j        |v rt          j        t          j        fS | j        |v rt          j        t          j        fS | j        |v rt          j        t          j        fS | j        |v rAt          | |d
¦  «        }t          |t          ¦  «        sJ ‚t          ||||¦  «        \  }}||fS t          j
        t          j
        fS | j         dk    �r;| j         dk    sJ ‚t          | j        t          ¦  «        sJ ‚t          || j        ¦  «        Št          ˆfd„|
D ¦   «         ¦  «        }t          ‰|t          t          f¦  «        s|rAt          | |d
¦  «        }t          |t          ¦  «        sJ ‚t          ||||¦  «        \  }}||fS t          ˆfd„|D ¦   «         ¦  «        }t          ˆfd„|	D ¦   «         ¦  «        }|rt          j        t          j        fS |rt          j        t          j        fS t          j
        t          j
        fS | j         dk    �r:| j        dk    rKt          | |d
¦  «        }t          |t          ¦  «        sJ ‚t          ||||¦  «        \  }}|t          j        fS | j        dk    rwt          | |d
¦  «        }t          |t          ¦  «        sJ ‚t          ||||¦  «        \  }}t          | |d¦  «        }|t           j        u sJ |› d�¦   «         ‚|t          j        fS | j        |v rAt          | |d
¦  «        }t          |t          ¦  «        sJ ‚t          ||||¦  «        \  }}||fS t          j
        t          j
        fS t          j
        t          j
        fS )NÚfuns_io_type_fp32Úfuns_io_type_fp16Úfuns_io_type_int8Úfuns_io_type_fp32_or_int8Úmods_io_type_fp32Úmods_io_type_int8Úmods_io_type_fp32_or_int8Úmeths_io_type_fp32_or_int8Úcall_functionr   Úcall_modulec              3   ó8   •K  — | ]}t          ‰|¦  «        V — Œd S ©N©Ú
isinstance©Ú.0Útarget_typeÚmods     €r!   ú	<genexpr>z7get_node_first_input_and_output_type.<locals>.<genexpr>N   s>   øè è € ð 1
ð 1
Ø-8�J�s˜KÑ(Ô(ð1
ð 1
ð 1
ð 1
ð 1
ð 1
r    c              3   ó8   •K  — | ]}t          ‰|¦  «        V — Œd S r3   r4   r6   s     €r!   r:   z7get_node_first_input_and_output_type.<locals>.<genexpr>`   ó>   øè è € ð )
ð )
Ø-8�J�s˜KÑ(Ô(ð)
ð )
ð )
ð )
ð )
ð )
r    c              3   ó8   •K  — | ]}t          ‰|¦  «        V — Œd S r3   r4   r6   s     €r!   r:   z7get_node_first_input_and_output_type.<locals>.<genexpr>c   r<   r    Úcall_methodÚ
dequantizeÚtor   z handling needs to be added)ÚopÚtargetr   r   r   r   Úget_normalized_nth_inputr5   r   Ú$get_node_first_input_and_output_typer   Ústrr   Úanyr   r
   ÚtorchÚfloat16)r"   r#   r$   r%   ÚFUNS_IO_TYPE_FP32ÚFUNS_IO_TYPE_FP16ÚFUNS_IO_TYPE_INT8ÚFUNS_IO_TYPE_FP32_OR_INT8ÚMODS_IO_TYPE_FP32ÚMODS_IO_TYPE_INT8ÚMODS_IO_TYPE_FP32_OR_INT8ÚMETHS_IO_TYPE_FP32_OR_INT8Ú	first_argÚ_prev_node_input_typeÚprev_node_output_typeÚ"is_known_fp32_or_int8_input_moduleÚis_known_fp32_input_moduleÚis_known_int8_input_moduleÚ	prev_nodeÚcur_node_dtype_targetr9   s                       @r!   rD   rD   &   s¬  ø€ ð 1Ð1DÔEÐØ0Ð1DÔEÐØ0Ð1DÔEÐØ 8Ð9TÔ UÐØ0Ð1DÔEÐØ0Ð1DÔEÐØ 8Ð9TÔ UÐØ!9Ð:VÔ!WÐà„w�/Ò!Ð!ØŒ;Ð+Ð+Ð+Ý)Ô.Õ0EÔ0JÐKÐKØŒ;Ð+Ð+Ð+Ý)Ô.Õ0EÔ0JÐKÐKØŒ[Ð-Ð-Ð-Ý)Ô.Õ0EÔ0JÐKÐKØŒ[Ð5Ð5Ð5Ý0°°r¸1Ñ=Ô=ˆIÝ˜i­Ñ.Ô.Ð.Ð.Ð.õ 5Ø˜2˜zÐ+Cñô ñØ%Ø%ð *Ð+@ÐAÐAå)Ô1Õ3HÔ3PÐQÐQà	Œ�MÒ	!Ñ	!ØŒw˜-Ò'Ð'Ð'Ð'Ý˜$œ+¥sÑ+Ô+Ð+Ð+Ð+Ý˜r 4¤;Ñ/Ô/ˆÝ-0ð 1
ð 1
ð 1
ð 1
Ø<Uð1
ñ 1
ô 1
ñ .
ô .
Ð*õ �s˜Z­Õ7GÐHÑIÔIð	Bà1ð	Bõ 1°°r¸1Ñ=Ô=ˆIÝ˜i­Ñ.Ô.Ð.Ð.Ð.õ 5Ø˜2˜zÐ+Cñô ñØ%Ø%ð *Ð+@ÐAÐAÝ%(ð )
ð )
ð )
ð )
Ø<Mð)
ñ )
ô )
ñ &
ô &
Ð"õ &)ð )
ð )
ð )
ð )
Ø<Mð)
ñ )
ô )
ñ &
ô &
Ð"ð &ð 	RÝ)Ô.Õ0EÔ0JÐKÐKØ'ð 	RÝ)Ô.Õ0EÔ0JÐKÐKå)Ô1Õ3HÔ3PÐQÐQà	Œ�MÒ	!Ñ	!ØŒ;˜,Ò&Ð&õ 1°°r¸1Ñ=Ô=ˆIÝ˜i­Ñ.Ô.Ð.Ð.Ð.õ 5Ø˜2˜zÐ+Cñô ñØ%Ø%ð *Õ+@Ô+EÐFÐFàŒ[˜DÒ Ð õ
 1°°r¸1Ñ=Ô=ˆIÝ˜i­Ñ.Ô.Ð.Ð.Ð.õ 5Ø˜2˜zÐ+Cñô ñØ%Ø%õ
 %=¸TÀ2ÀqÑ$IÔ$IÐ!à%­¬Ð6Ð6Ð6Ø'ÐDÐDÐDñ 7Ô6Ð6ð *Õ+@Ô+EÐFÐFàŒ[Ð6Ð6Ð6Ý0°°r¸1Ñ=Ô=ˆIÝ˜i­Ñ.Ô.Ð.Ð.Ð.õ 5Ø˜2˜zÐ+Cñô ñØ%Ø%ð *Ð+@ÐAÐAå%Ô-Õ/DÔ/LÐMÐMå%Ô-Õ/DÔ/LÐMÐMr    c                 óv  ‡— t          | |d¦  «        }t          |t          ¦  «        sdS |d         }d„ }|j        dk    rh|j        t
          j        k    r |||dd¦  «        S |j        t          j        t          j	        t          j
        t          j        fv r |||dd¦  «        S dS |j        d	k    �r…t          |j        t          ¦  «        sJ ‚t          ||j        ¦  «        Št          ‰t          j        t          j        t          j        t$          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j        t          j         t          j!        t$          j"        t$          j#        t$          j$        t$          j        t$          j%        t$          j&        f¦  «        r‰j'        ‰j(        fS tS          ˆfd
„|D ¦   «         ¦  «        }|rtU          |||¦  «        S dS )z{
    Returns the qparams (scale, zero_point) of the first input to `node`,
    if they can be inferred from the graph.
    r   Nr.   c                 óf  — t          | ||¦  «        }t          | ||¦  «        }t          |t          ¦  «        rt          |j        t          ¦  «        sJ ‚t          |t          ¦  «        rt          |j        t          ¦  «        sJ ‚t          ||j        ¦  «        }t          ||j        ¦  «        }||fS r3   )rC   r5   r   rB   rE   r   )r"   r#   Úscale_arg_idxÚ
zp_arg_idxÚ
scale_nodeÚzp_nodeÚ	scale_objÚzp_objs           r!   Ú _get_scale_zp_from_function_argsz@get_node_input_qparams.<locals>._get_scale_zp_from_function_args±   s¡   € Ý-¨d°B¸ÑFÔFˆ
Ý*¨4°°ZÑ@Ô@ˆÝ˜*¥dÑ+Ô+ÐRµ
¸:Ô;LÍcÑ0RÔ0RÐRÐRÐRÝ˜'¥4Ñ(Ô(ÐL­Z¸¼ÍÑ-LÔ-LÐLÐLÐLÝ$ R¨Ô):Ñ;Ô;ˆ	Ý! " g¤nÑ5Ô5ˆØ˜6Ð"Ð"r    r0   r   é   é   r1   c              3   ó8   •K  — | ]}t          ‰|¦  «        V — Œd S r3   r4   )r7   r8   Ú
module_objs     €r!   r:   z)get_node_input_qparams.<locals>.<genexpr>è   s>   øè è € ð 1
ð 1
Ø4?�J�z ;Ñ/Ô/ð1
ð 1
ð 1
ð 1
ð 1
ð 1
r    )+rC   r5   r   rA   rB   rG   Úquantize_per_tensorÚtoqÚaddÚadd_reluÚmulÚmul_relurE   r   ÚnnqÚLinearÚConv1dÚConv2dÚnniqÚ
ConvReLU2dÚConv3dÚBatchNorm2dÚBatchNorm3dÚConvTranspose1dÚConvTranspose2dÚELUÚ	GroupNormÚInstanceNorm1dÚInstanceNorm2dÚInstanceNorm3dÚ	LayerNormÚ	HardswishÚ	LeakyReLUÚReLU6ÚBNReLU2dÚBNReLU3dÚ
ConvReLU1dÚ
ConvReLU3dÚ
LinearReLUÚscaleÚ
zero_pointrF   Úget_node_input_qparams)r"   r#   r%   rW   rO   ra   rT   re   s          @r!   r‡   r‡   ¡   s÷  ø€ õ )¨¨r°1Ñ5Ô5€Iå�i¥Ñ&Ô&ð Øˆtà 8Ð9TÔ UÐð#ð #ð #ð „|�Ò&Ð&àÔ�uÔ8Ò8Ð8Ø3Ð3°I¸rÀ1ÀaÑHÔHÐHØÔ¥#¤'­3¬<½¼Å#Ä,Ð!OÐOÐOØ3Ð3°I¸rÀ1ÀaÑHÔHÐHàˆtð 
Œ˜Ò	&Ñ	&å˜)Ô*­CÑ0Ô0Ð0Ð0Ð0Ý% b¨)Ô*:Ñ;Ô;ˆ
ÝØå”
Ý”
Ý”
Ý”Ý”
Ý”Ý”ÝÔ#ÝÔ#Ý”Ý”ÝÔ"ÝÔ"ÝÔ"Ý”Ý”Ý”Ý”	Ý”Ý”Ý”Ý”Ý”Ý”ð1ñ
ô 
ð 	=ð: Ô$ jÔ&;Ð<Ð<å-0ð 1
ð 1
ð 1
ð 1
ØC\ð1
ñ 1
ô 1
ñ .
ô .
Ð*ð .ð 	SÝ)¨)°RÐ9QÑRÔRÐRàˆ4r    c                 ó  — | j         dk    röt          || j        ¦  «        }t          |¦  «        rÒt	          | j        ¦  «        dk    sJ ‚t          | j        d         t          ¦  «        sJ ‚| j        d         } t          | j        t          ¦  «        sJ ‚t          || j        ¦  «        }t          |¦  «        rIt	          | j        ¦  «        dk    sJ ‚t          | j        d         t          ¦  «        sJ ‚| j        d         } | S )a‡  
    If node is not an observer, returns it.  If node is an observer,
    navigates up the graph and returns the first parent which is not an
    observer.  For example,

    graph: (node_non_obs), node = node_non_obs : returns node_non_obs
    graph: (node_non_obs -> obs0), node = obs0 : returns node_non_obs
    graph: (node_non_obs -> obs0 -> fq0), node = fq0 : returns node_non_obs
    r1   r   r   )	rA   r   rB   r   ÚlenÚargsr5   r   rE   ©r"   r#   Únode_objs      r!   Úreturn_first_non_observer_noder�   ñ   sð   € ð „w�-ÒÐÝ# B¨¬Ñ4Ô4ˆÝ& xÑ0Ô0ð 
	$Ý�t”y‘>”> QÒ&Ð&Ð&Ð&Ý˜dœi¨œl­DÑ1Ô1Ð1Ð1Ð1Ø”9˜Q”<ˆDå˜dœk­3Ñ/Ô/Ð/Ð/Ð/Ý'¨¨D¬KÑ8Ô8ˆHÝ*¨8Ñ4Ô4ð $Ý˜4œ9‘~”~¨Ò*Ð*Ð*Ð*Ý! $¤)¨A¤,µÑ5Ô5Ð5Ð5Ð5Ø”y ”|�Ø€Kr    c                 ó~   — | j         dk    r1t          || j        ¦  «        }t          |t          j        ¦  «        rdS dS )aO  
    Assumes that all non-param args occur first. Returns the number of
    non-param args expected for a node.  For example, for

      F.linear(x, weight, bias)

    Returns 1, because x is a non-param arg and weight and bias are params.
    For

      lstm_mod(x, hid)

    Returns 2, because both x and hid are non-param args.
    r1   rb   r   )rA   r   rB   r5   ÚnnÚLSTMr‹   s      r!   Úget_number_of_non_param_argsr‘     sB   € ð" „w�-ÒÐÝ# B¨¬Ñ4Ô4ˆÝ�h¥¤Ñ(Ô(ð 	Ø�1ð ˆ1r    c                 ó^  ‡ — t          ‰ j        ¦  «        dk    rg S ‰ j        dk    r…‰ j        t          j        t          j        j        j        t          j        fv s4‰ j        t          j	        t          j        j        j	        t          j	        fv rˆ fd„t          d¦  «        D ¦   «         }|S dgS )a-  
    Returns the indices of args of the node which we should attach
    loggers to, if input logging is enabled.

    For example,
    * for (x + y), returns [0, 1]
    * for (1 + y), returns [1]
    * for (x + 1), returns [0]
    * for (linear(x, w, b)) returns [0]
    * by default, returns [0]
    r   r0   c                 óZ   •— g | ]'}t          ‰j        |         ¦  «        t          k    ¯%|‘Œ(S r   )ÚtyperŠ   r   )r7   Úir"   s     €r!   ú
<listcomp>z4get_arg_indices_of_inputs_to_log.<locals>.<listcomp>;  s1   ø€ ÐDÐDÐD˜­¨d¬i¸¬lÑ);Ô);½tÒ)CÐ)C�!Ð)CÐ)CÐ)Cr    rb   )r‰   rŠ   rA   rB   rG   rh   ÚopsÚ	quantizedÚoperatorrj   Úrange)r"   Úresults   ` r!   Ú get_arg_indices_of_inputs_to_logrœ   (  s•   ø€ õ ˆ4Œ9�~„~˜ÒÐØˆ	Ø„w�/Ò!Ð!àŒ�œ	¥5¤9Ô#6Ô#:½H¼LÐIÐIÐIØŒ;�5œ9¥e¤iÔ&9Ô&=½x¼|ÐLÐLÐLàDÐDÐDÐD�U 1™XœXÐDÑDÔDˆØˆØˆ3€Jr    c                 óð   — d}| j         dv rt          j        | j        ¦  «        }nP| j         dk    rEt	          | j        t
          ¦  «        sJ ‚t          || j        ¦  «        }t          j        |¦  «        }|S )zˆ
    Returns a string representation of the type of the function or module
    pointed to by this node, or '' for other node types.
    Ú )r0   r>   r1   )rA   rG   ÚtypenamerB   r5   rE   r   )r"   r#   r8   Ú
target_mods       r!   Úget_target_type_strr¡   @  su   € ð
 €KØ„wÐ2Ð2Ð2Ý”n T¤[Ñ1Ô1ˆˆØ	Œ�MÒ	!Ð	!Ý˜$œ+¥sÑ+Ô+Ð+Ð+Ð+Ý% b¨$¬+Ñ6Ô6ˆ
Ý”n ZÑ0Ô0ˆØÐr    ÚresultsÚ
model_namec                 ó
  — i }|                       ¦   «         D ]k\  }}d}|                     ¦   «         D ]B}|                      ¦   «         D ]+\  }}||k    r t          |¦  «        sJ ‚|d         d         }Œ+Œ,ŒC|�|||<   Œf|||<   Œl|S )a	  
    Rekeys the layer name of a results dictionary to use node names
    from `model_name`.

    For example, transforms

        {'base_op_1_0': {'node_output': {'model_a':
          [{'ref_node_name': 'linear1', ...}]}}}

    into

        {'linear1': {'node_output': {'model_a':
          [{'ref_node_name': 'linear1', ...}]}}}

    Note: we cannot use these node names directly because they are not
    guaranteed to be consistent across models. This is why we extract
    the results first and rekey afterwards.
    Nr   Úref_node_name)ÚitemsÚvaluesr‰   )	r¢   r£   Únew_resultsÚold_layer_nameÚresult_type_to_resultsÚnew_layer_nameÚmodel_name_to_resultsÚcur_model_nameÚlist_of_resultss	            r!   Ú'rekey_logger_info_on_node_name_of_modelr¯   O  sÉ   € ð, €KØ29·-²-±/´/ð Að AÑ.ˆÐ.ØˆØ%;×%BÒ%BÑ%DÔ%Dð 	ð 	Ð!Ø3H×3NÒ3NÑ3PÔ3Pð ð Ñ/� Ø! ZÒ/Ð/Ý˜Ñ/Ô/Ð/Ð/Ð/Ø%4°QÔ%7¸Ô%H�N�Nàðð Ð%Ø*@ˆK˜Ñ'Ð'à*@ˆK˜Ñ'Ð'ØÐr    c                 ó
  — d}|                       ¦   «         D ]X}|                      ¦   «         D ]A}|                     ¦   «         D ]*\  }}t          |¦  «        dk    r|d         d         �|} nŒ+  |r�|                       ¦   «         D ]|}|                      ¦   «         D ]c}||         }|                     ¦   «         D ]D\  }}||k    rŒt          t          |¦  «        ¦  «        D ]}||         d         }|||         d<   ŒŒEŒdŒ{dS dS )ay  
    If `fqn` entries are filled in for one of the models in `results`, copies
    them over to any models which do not have them filled out.

    A common use case benefitting from this is comparing a model prepared by
    quantization to a quantized model. In this case, the model prepared by
    quantization would have `fqn` entries, and the quantized model would not.
    Nr   Úfqn)r§   r¦   r‰   rš   )	r¢   Úmodel_name_with_fqnsrª   r¬   r£   Úmodel_resultsÚref_model_resultsr•   r±   s	            r!   Úmaybe_add_missing_fqnsrµ   v  sq  € ð  ÐØ")§.¢.Ñ"2Ô"2ð ð ÐØ%;×%BÒ%BÑ%DÔ%Dð 	ð 	Ð!Ø-B×-HÒ-HÑ-JÔ-Jð ð Ñ)�
˜MÝ�}Ñ%Ô%¨Ò)Ð)Ø$ QÔ'¨Ô.Ð:Ø/9Ð,Ø˜øØØàð 	6Ø&-§n¢nÑ&6Ô&6ð 	6ð 	6Ð"Ø)?×)FÒ)FÑ)HÔ)Hð 6ð 6Ð%Ø$9Ð:NÔ$OÐ!Ø1F×1LÒ1LÑ1NÔ1Nð 6ð 6Ñ-�J Ø!Ð%9Ò9Ð9Ø Ý"¥3 }Ñ#5Ô#5Ñ6Ô6ð 6ð 6˜Ø/°Ô2°5Ô9˜Ø25˜ aÔ(¨Ñ/Ð/ð6ð6ð6ð	6ð 	6ð	6ð 	6r    c                 ó   ‡ ‡— ˆ ˆfd„Š‰S )Nc                  óx  •— | ^}}}t          |t          ¦  «        rt          |t          ¦  «        s*t          |t          ¦  «        rQt          |t          ¦  «        r<g }t          ||¦  «        D ]'\  }}||g|¢R }|                      ‰
|i |¤Ž¦  «         Œ(|S t          |t
          j        ¦  «        rPt          |t
          j        ¦  «        r6|j        r|                     ¦   «         }|j        r|                     ¦   «         }|j	        t
          j
        k    s|j	        t
          j
        k    rd S ||g|¢R } ‰	|i |¤ŽS r3   )r5   ÚtupleÚlistÚzipÚappendrG   ÚTensorÚis_quantizedr?   ÚdtypeÚfloat)rŠ   ÚkwargsÚa0Úa1Úa_otherr¢   Úel0Úel1Únew_argsÚfÚinners            €€r!   rÈ   zGmaybe_dequantize_first_two_tensor_args_and_handle_tuples.<locals>.inner™  sS  ø€ ØÐˆˆB�å�r�5Ñ!Ô!ð 	%¥j°µUÑ&;Ô&;ð 	%Ý�r�4Ñ Ô ð	%Ý%/°µDÑ%9Ô%9ð	%ð ˆGÝ  B™KœKð ;ð ;‘��SØ Ð/ wÐ/Ð/�Ø—’˜u˜u hÐ9°&Ð9Ð9Ñ:Ô:Ð:Ð:ØˆNå˜�EœLÑ)Ô)ð 	%­j¸½U¼\Ñ.JÔ.Jð 	%ØŒð %Ø—]’]‘_”_�ØŒð %Ø—]’]‘_”_�ð Œ8•u”{Ò"Ð" b¤hµ%´+Ò&=Ð&=Ø�4à˜Ð%˜WÐ%Ð%ˆØˆq�(Ð%˜fÐ%Ð%Ð%r    r   )rÇ   rÈ   s   `@r!   Ú8maybe_dequantize_first_two_tensor_args_and_handle_tuplesrÉ   ˜  s)   øø€ ð&ð &ð &ð &ð &ð &ð2 €Lr    ÚxÚyc                 óŒ   — t          j        | ¦  «        }t          j        | |z
  ¦  «        }dt          j        ||z  ¦  «        z  S )zµ
    Computes the SQNR between `x` and `y`.

    Args:
        x: Tensor or tuple of tensors
        y: Tensor or tuple of tensors

    Return:
        float or tuple of floats
    é   )rG   ÚnormÚlog10)rÊ   rË   ÚPsÚPns       r!   Úcompute_sqnrrÒ   µ  s=   € õ 
Œ�A‰Œ€BÝ	Œ�A˜‘EÑ	Ô	€BØ•”˜B ™GÑ$Ô$Ñ$Ð$r    c                 óŠ   — t          j        | |z
  dz                       ¦   «         | dz                       ¦   «         z  ¦  «        S )zÄ
    Computes the normalized L2 error between `x` and `y`.

    Args:
        x: Tensor or tuple of tensors
        y: Tensor or tuple of tensors

    Return:
        float or tuple of floats
    rb   )rG   ÚsqrtÚsum©rÊ   rË   s     r!   Úcompute_normalized_l2_errorr×   Æ  s9   € õ Œ:˜˜A™ !‘|×(Ò(Ñ*Ô*¨a°©d¯ZªZ©\¬\Ñ9Ñ:Ô:Ð:r    c                 ó¤   — |                       dd¦  «        } |                      dd¦  «        }t          j        j                             | |¦  «        S )zÂ
    Computes the cosine similarity between `x` and `y`.

    Args:
        x: Tensor or tuple of tensors
        y: Tensor or tuple of tensors

    Return:
        float or tuple of floats
    r   éÿÿÿÿ)ÚreshaperG   r�   Ú
functionalÚcosine_similarityrÖ   s     r!   Úcompute_cosine_similarityrÝ   Õ  sE   € ð 	
�	Š	�!�RÑÔ€AØ	�	Š	�!�RÑÔ€AÝŒ8Ô×0Ò0°°AÑ6Ô6Ð6r    c                 ó¶   — | j         dk    rM| j        t          j        t          j        t
          j        t
          j        t          j        t          j        fv rdS dS )Nr0   FT)rA   rB   rG   rh   rj   r™   ÚcatÚstack)r"   s    r!   Úop_type_supports_shadowingrá   é  sM   € Ø„w�/Ò!Ð!ØŒ;ÝŒIÝŒIÝŒLÝŒLÝŒIÝŒKð
ð 
ð 
ð �5Øˆ4r    Úidxc                 óŽ  — 	 |                       |d¬¦  «        }|�l|\  }}t          |¦  «        t          |¦  «        z   |k    sJ ‚|t          |¦  «        k     r||         S t          |                     ¦   «         ¦  «        |         S t          | j        ¦  «        t          | j        ¦  «        z   |k    sJ ‚|t          | j        ¦  «        k     r| j        |         S |t          | j        ¦  «        z   }t          | j                             ¦   «         ¦  «        |         S # t          $ rœ t          | j        ¦  «        t          | j        ¦  «        z   |k    sJ ‚|t          | j        ¦  «        k     r| j        |         cY S |t          | j        ¦  «        z   }t          | j                             ¦   «         ¦  «        |         cY S w xY w)zu
    Given a node, gets the n'th input to that node, normalizing
    args and kwargs to the best of its ability.
    T)Únormalize_to_only_use_kwargs)Únormalized_argumentsr‰   r¹   r§   rŠ   rÀ   ÚRuntimeError)r"   r#   râ   Únorm_args_and_kwargsÚ	norm_argsÚnorm_kwargsÚ
kwargs_idxs          r!   rC   rC   ø  s¶  € ð
:Ø#×8Ò8Ø¨Tð  9ñ  
ô  
Ðð  Ð+Ø%9Ñ"ˆI�{Ý�y‘>”>¥C¨Ñ$4Ô$4Ñ4°sÒ:Ð:Ð:Ð:Ø•S˜‘^”^Ò#Ð#Ø  ”~Ð%õ ˜K×.Ò.Ñ0Ô0Ñ1Ô1°#Ô6Ð6å�t”y‘>”>¥C¨¬Ñ$4Ô$4Ñ4°sÒ:Ð:Ð:Ð:Ø•S˜œ‘^”^Ò#Ð#Ø”y ”~Ð%à ¥3 t¤y¡>¤>Ñ1�
Ý˜DœK×.Ò.Ñ0Ô0Ñ1Ô1°*Ô=Ð=øÝð 	:ð 	:ð 	:õ �4”9‰~Œ~¥ D¤KÑ 0Ô 0Ñ0°3Ò6Ð6Ð6Ð6Ø•�T”Y‘”ÒÐØ”9˜S”>Ð!Ð!Ð!à�s 4¤9™~œ~Ñ-ˆJÝ˜œ×*Ò*Ñ,Ô,Ñ-Ô-¨jÔ9Ð9Ð9Ð9ð	:øøøs.   ‚AD Á &D ÂAD ÃAD ÄAGÅ>AGÇG)9r   r™   Útypingr   r   r   r   r   r   r	   rG   Útorch.ao.nn.intrinsic.quantizedÚaor�   Ú	intrinsicr˜   rp   Útorch.ao.nn.quantizedrl   Útorch.nnÚtorch.ao.quantizationr
   r   Útorch.ao.quantization.observerr   Útorch.ao.quantization.utilsr   Útorch.fxr   Útorch.fx.graphr   Úns_typesr   r   r—   rg   ÚEnumr   rE   rD   r¼   r¿   Úintr‡   r�   r‘   rœ   r¡   r¯   rµ   rÉ   rÒ   r×   rÝ   Úboolrá   rC   r   r    r!   ú<module>rú      sp  ðð €€€Ø €€€Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ Dà €€€Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø FÐ FÐ FÐ FÐ FÐ FØ 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5ð „iÔ€ð
	ð 	ð 	ð 	ð 	˜DœIñ 	ô 	ð 	ðxNØ
ðxNàðxNð ðxNð # 3¨Ð,<Ô(=Ð#=Ô>ð	xNð
 Ð Ð"7Ð7Ô8ðxNð xNð xNð xNðvMØ
ðMàðMð # 3¨Ð,<Ô(=Ð#=Ô>ðMð ˆe�E˜%œ,¨Ð-Ô.°°e´lÀCÐ6GÔ0HÐHÔIÔJð	Mð Mð Mð Mð`Ø
ðàðð 
ðð ð ð ð:Ø
ðàðð 	ðð ð ð ð4¨4ð °D¸´Ið ð ð ð ð0˜dð ¨ð ¸ð ð ð ð ð$Øð$àð$ð ð$ð $ð $ð $ðN6 Mð 6°dð 6ð 6ð 6ð 6ðDð ð ð: :ð%�E”Lð % U¤\ð %°e´lð %ð %ð %ñ :Ô9ð%ð  :ð; 5¤<ð ;°E´Lð ;ÀUÄ\ð ;ð ;ð ;ñ :Ô9ð;ð :ð7 ¤ð 7°%´,ð 7À5Ä<ð 7ð 7ð 7ñ :Ô9ð7ð& Tð ¨dð ð ð ð ð!: 4ð !:¨[ð !:¸sð !:Àtð !:ð !:ð !:ð !:ð !:ð !:r    