+
    –°³j¡z  ã                   óî  € ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHu Hu H	t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHtHtHtHtHtHtHtHt ^ RI H!t!H"t" ^ RI#H$t$ ^RI%H&t&H't'H(t( . R Ot)]t*R	]PV                  ]PX                  PV                  ]PZ                  ]PX                  PZ                  /R
]PX                  PV                  ]P                  PV                  ]PX                  PZ                  ]P                  PZ                  //t.R t/R!R lt0R"R lt1R t2R t3R#R lt4R$R lt5R t6R t7]Pp                  ! ]&4      R%R l4       t9R t:R t;]Pp                  ! ]&4      R&R l4       t<]Pp                  ! ]&4      R]Pz                  RR3R l4       t>]Pp                  ! ]&4      R&R l4       t?]Pp                  ! ]&4      R#R l4       t@]Pp                  ! ]&4      R'R l4       tAR(R ltBR#R ltCR)R ltDR# )*é    N)Ú_FusedModule)Ú_is_activation_post_process)Ú_activation_is_memorylessÚ_add_module_to_qconfig_obs_ctrÚdefault_dynamic_qconfigÚfloat16_dynamic_qconfigÚ!float_qparams_weight_only_qconfigÚ&float_qparams_weight_only_qconfig_4bit)Ú_get_special_act_post_processÚ_has_special_act_post_processÚ)get_default_dynamic_quant_module_mappingsÚget_default_qat_module_mappingsÚ$get_default_qconfig_propagation_listÚ(get_default_static_quant_module_mappingsÚ2get_default_static_quant_reference_module_mappingsÚno_observer_set)ÚDeQuantStubÚQuantWrapper)Útype_before_parametrizations)ÚDEPRECATION_WARNINGÚget_qparam_dictÚ)has_no_children_ignoring_parametrizationsÚ%float_to_observed_custom_module_classÚ)observed_to_quantized_custom_module_classc                 ó   € \         # )z'Defines the default custom config dict.)Ú_DEFAULT_CUSTOM_CONFIG_DICT© ó    Ú_/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/ao/quantization/quantize.pyÚget_default_custom_config_dictr    G   s   € ä&Ð&r   c                óú  € VP                  \        V 4      V4      pVP                  W54      p\        V RV4      p\        P                  P
                  P                  P                  WP4       \        WP4      pW`n        V P                  4        Fi  w  rxV'       d   VR,           V,           MTp	Ve;   WtP                  R. 4      9   d   K;  \        V4      VP                  R. 4      9   d   K]  \        W�Wi4       Kk  	  R# )aº  This is a helper function for `propagate_qconfig_`

Args:
    module: input module
    qconfig_dict: dictionary that maps from name of submodule to quantization
                 configuration
    qconfig_parent: quantization config of parent module, we will fallback to
                   this config when there is no specified config for current
                   module
    prefix: corresponding prefix of the current module, used as key in
            qconfig_dict
    prepare_custom_config_dict: dictionary for custom handling of modules
                                see docs for :func:`~torch.ao.quantization.prepare_fx`

Return:
    None, module is modified inplace with qconfig attached
ÚqconfigÚ.NÚnon_traceable_module_nameÚnon_traceable_module_class)Úgetr   ÚgetattrÚtorchÚaoÚquantizationr"   Ú_assert_valid_qconfigr   Únamed_childrenÚtypeÚ_propagate_qconfig_helper)
ÚmoduleÚqconfig_dictÚqconfig_parentÚprefixÚprepare_custom_config_dictÚmodule_qconfigÚqconfig_with_device_checkÚnameÚchildÚmodule_prefixs
   &&&&&     r   r.   r.   L   sÜ   € ð2 "×%Ñ%Ü$ VÓ,¨nó€Nð "×%Ñ% fÓ=€NÜ˜V Y°Ó?€Nä	‡H�H×Ñ×!Ñ!×7Ñ7¸ÔOä >¸~Ó VÐØ.„Nà×,Ñ,Ö.‰ˆß/5˜ � tÖ+¸4ˆà%Ò-Ø×2Ñ2Ð3NÐPRÓSÖSÜ�E‹{Ø)×-Ñ-Ð.JÈBÓOöPô &ØÐ%>öó /r   c                ó8   € Vf   / pVf   / p\        WVR7       R# )ac  Propagate qconfig through the module hierarchy and assign `qconfig`
attribute on each leaf module

Args:
    module: input module
    qconfig_dict: dictionary that maps from name or type of submodule to
        quantization configuration, qconfig applies to all submodules of a
        given module unless qconfig for the submodules are specified (when
        the submodule already has qconfig attribute)
    prepare_custom_config_dict: dictionary for custom handling of modules
        see docs for :func:`~torch.ao.quantization.prepare_fx`

Return:
    None, module is modified inplace with qconfig attached
N)r3   )r.   )r/   r0   r3   s   &&&r   Úpropagate_qconfig_r:   }   s)   € ð  ÒØˆØ!Ò)Ø%'Ð"ÜØÐ9S÷r   c                ó$   € V P                  V4      # )z.Forward hook that calls observer on the output©Úactivation_post_process)ÚselfÚinputÚoutputs   &&&r   Ú_observer_forward_hookrA   –   s   € à×'Ñ'¨Ó/Ð/r   c                ó2   € V P                  V^ ,          4      # )z2Forward pre hook that calls observer on the outputr<   )r>   r?   s   &&r   Ú_observer_forward_pre_hookrC   ›   s   € à×'Ñ'¨¨a­Ó1Ð1r   Fc                 ó°   € \        V R 4      '       g   \        R4      hV'       d   V P                  \        RR7       R# V P	                  \
        RR7       R# )r=   zGExpect activation_post_process attribute already attached to the moduleT)ÚprependN)ÚhasattrÚAssertionErrorÚregister_forward_pre_hookrC   Úregister_forward_hookrA   )r/   Úpre_hooks   &&r   Ú&_register_activation_post_process_hookrK       sM   € Ü�6Ð4×5Ò5ÜØUó
ð 	
÷ Ø×(Ñ(Ô)CÈTÐ(ÖRà×$Ñ$Ô%;ÀTÐ$ÖJr   c                ó  aaa€ Vf   \        4       pVf   / pSfP   \        V 4      p\        V4      ^8”  d   \        RV 24      h\        V4      ^ 8”  d   \	        \        V4      4      MRoR
R loR oR
VVV3R llpV P                  4        EFÆ  w  rx\        V4      \        P                  J d   K%  \        \        V4      \        P                  \        P                  34      '       dU   S! V4      '       dE   \        VR4      '       g   \        R\        V4       R24      hS! VP                  S4      Vn        K°  K²  \#        V\$        4      '       d   S! V4      '       d   V! V4       Kà  Kâ  Ve-   \        V4      V9   d   S! V4      '       d   V! V4       EK  EK  \'        V4      '       d   \)        V4      p	V! W‰4       EK9  S! V4      '       dq   \        V4      V9   da   V\        V4      ,          p
V
P+                  V4      p\-        WV4       \        V
\/        \1        4       4      4      '       g   V! V4       EK´  EK·  \3        VVVSV4       EKÉ  	  \5        V 4      '       dC   \#        V \6        P                  P8                  4      '       g   \        V 4      V9   d	   V! V 4       \        V R	4      '       dI   \#        V \6        P                  P8                  4      '       g   \        V 4      V9   d   V! V 4       R# R# R# R# )aG  Add observer for the leaf child of the module.

This function insert observer module to all leaf child module that
has a valid qconfig attribute.

Args:
    module: input module with qconfig attributes for all the leaf modules that we want to quantize
    qconfig_propagation_list: a list of quantizable modules that will have observers added to them
        if they are leaf nodes
    device: parent device, if any
    non_leaf_module_list: list of non-leaf modules we want to add observer

Return:
    None, module is modified inplace with added observer modules and forward_hooks
NzR_add_observer_ only works with cpu or single-device CUDA modules, but got devices c                 óf   € Vf   V P                  4       MV! 4       pVe   VP                  V4       V# ©N)Ú
activationÚto)r"   ÚdeviceÚspecial_act_post_processrO   s   &&& r   Úget_activation_post_processÚ3_add_observer_.<locals>.get_activation_post_processÐ   s=   € ð (Ò/ð ×ÑÔ á)Ó+ð 	ð
 ÒØ�M‰M˜&Ô!ØÐr   c                 óF   € \        V R 4      ;'       d    V P                  RJ# ©r"   N©rF   r"   )Úms   &r   Úneeds_observationÚ)_add_observer_.<locals>.needs_observationÚ   s    € Ü�q˜)Ó$×>Ð>¨¯©¸$Ð)>Ð>r   c                óà   <€ S! V 4      '       d_   \        V \        4      '       gG   V P                  RS! V P                  SV4      4       \	        V \        V P                  4      R7       R# R# R# )z]Adds an activation post process module and register
a pre or post hook that calls the module
r=   ©rJ   N)Ú
isinstancer   Ú
add_moduler"   rK   r   )rX   rR   rQ   rS   rY   s   &&€€€r   Úinsert_activation_post_processÚ6_add_observer_.<locals>.insert_activation_post_processÝ   sa   ø€ ñ
 ˜Q×Ò¬
°1´k×(BÒ(Bà�L‰LØ)Ù+Ø—I‘I˜vÐ'?óôô 3ØÔ5°a·i±iÓ@÷ñ )CÑr   r=   zfunctional class z- has no pre-defined `activation_post_process`Úweight_fake_quantrN   )r   Ú_get_unique_devices_ÚlenrG   ÚnextÚiterr,   r   ÚnnÚDropoutÚ
issubclassÚnnqÚFloatFunctionalÚQFunctionalrF   r"   r=   r]   r   r   r   Ú
from_floatÚsetattrÚtupler   Ú_add_observer_r   r(   Ú
Sequential)r/   Úqconfig_propagation_listÚnon_leaf_module_listrQ   Úcustom_module_class_mappingÚdevicesr_   r6   r7   rR   Úobserved_classÚobserved_childrS   rY   s   &&&f&       @@r   ro   ro   «   s³  ú€ ð,  Ò'Ü#GÓ#IÐ à"Ò*Ø&(Ð#ð ‚~Ü& vÓ.ˆÜˆw‹<˜!ÔÜ ØdÐelÐdmÐnóð ô ),¨G«°qÔ(8””d˜7“mÔ$¸dˆôò?÷ñ ð& ×,Ñ,×.‰ˆä'¨Ó.´"·*±*Ó<ÙÜÜ(¨Ó/´#×2EÑ2EÄsÇÁÐ1W÷
ò 
ñ ! ×'Ò'Ü˜uÐ&?×@Ò@Ü(Ø+Ô,HÈÓ,OÐ+PÐP}Ð~óð ñ 1LØ—M‘M 6ó1�Ö-ñ (ô ˜œ|×,Ò,á  ×'Ò'Ù.¨uÖ5ñ (ð !Ò,Ü,¨UÓ3Ð7KÔKá  ×'Ò'Ù.¨u×5ò (ä*¨5×1Ò1Ü'DÀUÓ'KÐ$Ù*¨5×Ká˜e×$Ò$Ü,¨UÓ3Ð7RÔRà8Ü,¨UÓ3õˆNð ,×6Ñ6°uÓ=ˆNÜ�F .Ô1ô ˜n¬e´OÓ4EÓ.F×GÒGÙ.¨~×>ò Hô ØØ(Ø$ØØ+÷ñU /ôj 	2°&×9Ò9Ü˜6¤5§8¡8×#6Ñ#6×7Ò7Ü(¨Ó0Ð4LÔLá& vÔ.ô 	�Ð+×,Ò,Ü˜6¤5§8¡8×#6Ñ#6×7Ò7Ü(¨Ó0Ð4LÔLá& vÖ.ñ Mñ 8ñ 	-r   c                 ó8  € V P                  4        Uu0 uF+  qP                  P                  R 8w  g   K  VP                  kK-  	  upV P                  4        Uu0 uF+  qP                  P                  R 8w  g   K  VP                  kK-  	  up,          # u upi u upi )Úmeta)Ú
parametersrQ   r-   Úbuffers)r/   Úps   & r   rb   rb   6  sy   € Ø$×/Ñ/Ô1ÓMÑ1˜·X±X·]±]ÀfÑ5LŒHˆA�HŒHÑ1ÑMØ Ÿ.™.Ô*óQÙ*�Q¯h©h¯m©m¸vÑ.EŒˆ�ŒÑ*ñQõ ð ùÒMùò Qs   “B´BÁBÁ9Bc                óè   € \        V 4      '       d0   \        V R4      '       d   V P                  '       d   \        V 4      # V P	                  4        F  w  r\        V4      V P                  V&   K  	  V # )aO  Wrap the leaf child module in QuantWrapper if it has a valid qconfig
Note that this function will modify the children of module inplace and it
can return a new module which wraps the input module as well.

Args:
    module: input module with qconfig attributes for all the leaf modules
    that we want to quantize

Return:
    Either the inplace modified module with submodules wrapped in
    `QuantWrapper` based on qconfig or a new `QuantWrapper` module which
    wraps the input module, the latter case only happens when the input
    module is a leaf module and we want to quantize it.
r"   )r   rF   r"   r   r,   Úadd_quant_dequantÚ_modules)r/   r6   r7   s   &  r   r}   r}   <  s]   € ô  	2°&×9Ò9Ü�F˜I×&Ò&Ø�N�NˆNä˜FÓ#Ð#à×,Ñ,Ö.‰ˆÜ 1°%Ó 8ˆ�‰˜Óñ /à€Mr   c                óô  € \         P                  P                  R4       Vf   \        4       pVP	                  R/ 4      pV'       g   \
        P                  ! V 4      p TpVf   \        4       p\        V RR7       \        ;QJ d*    R V P                  4        4       F  '       g   K   RM	  RM! R V P                  4        4       4      '       g   \        P                  ! R^R	7       \        V VVVR
7       V # )a  Prepares a copy of the model for quantization calibration or quantization-aware training.

Quantization configuration should be assigned preemptively
to individual submodules in `.qconfig` attribute.

The model will be attached with observer or fake quant modules, and qconfig
will be propagated.

Args:
    `model`: input model to be modified in-place
    `inplace`: carry out model transformations in-place, the original module is mutated
    `allow_list`: list of quantizable modules
    `observer_non_leaf_module_list`: list of non-leaf modules we want to add observer
    `prepare_custom_config_dict`: customization configuration dictionary for prepare function

.. code-block:: python

   # Example of prepare_custom_config_dict:
   prepare_custom_config_dict = {
       # user will manually define the corresponding observed
       # module class which has a from_float class method that converts
       # float custom module to observed custom module
       "float_to_observed_custom_module_class": {CustomModule: ObservedCustomModule}
   }

z!quantization_api.quantize.prepareNr   ©r0   c              3   ób   "  € T F%  p\        VR 4      ;'       d    VP                  x € K'  	  R# 5irV   rW   )Ú.0rX   s   & r   Ú	<genexpr>Úprepare.<locals>.<genexpr>Š  s&   é € ÐL¹O°qŒw�q˜)Ó$×2Ð2¨¯©Ô2»Oùs   ‚/š/TFz¬None of the submodule got qconfig applied. Make sure you passed correct configuration through `qconfig_dict` or by assigning the `.qconfig` attribute directly on submodules)Ú
stacklevel)rs   )r(   Ú_CÚ_log_api_usage_oncer    r&   ÚcopyÚdeepcopyr   r:   ÚanyÚmodulesÚwarningsÚwarnro   )ÚmodelÚinplaceÚ
allow_listÚobserver_non_leaf_module_listr3   rs   rq   s   &&&&&  r   Úpreparer’   W  sÔ   € ôD 
‡H�H× Ñ Ð!DÔEØ!Ò)Ü%CÓ%EÐ"Ø"<×"@Ñ"@Ø/°ó#Ð÷ Ü—’˜eÓ$ˆð  *ÐØÒÜ#GÓ#IÐ Ü�u¨4Õ0÷ ‹3ÑL¸E¿M¹M¼OÓL�3�3Š3ÑL¸E¿M¹M¼OÓL×LÒLÜ�ŠðKð õ		
ô ØØ Ø%Ø$?õ	ð €Lr   c                 ó®   a € \        S R 4      '       d(   \        S P                  4      '       d   \        S R 4       RV 3R llpV! RR7       V! RR7       R# )r=   Fc                 ó  <€ V '       d   SP                   MSP                  pV '       d   \        M\        p\	        4       pVP                  4        F  w  rEWRJ g   K  VP                  V4       K  	  V F  pVP                  V4       K  	  R # rN   )Ú_forward_pre_hooksÚ_forward_hooksrC   rA   ÚsetÚitemsÚaddÚpop)rJ   Úhook_mapÚobserver_hookÚhandle_ids_to_removeÚ	handle_idÚhook_fnr/   s   &     €r   Úremove_hooksÚ5_remove_activation_post_process.<locals>.remove_hooks¤  sp   ø€ ß08�6×,Ò,¸f×>SÑ>Sˆç*2Õ&Ô8Nð 	ô  #›uÐØ"*§.¡.Ö"2ÑˆIØÕ'Ø$×(Ñ(¨Ö3ñ #3ó .ˆIØ�L‰L˜Ö#ó .r   Tr\   N©F)rF   r   r=   Údelattr)r/   r    s   f r   Ú_remove_activation_post_processr¤   ›  sM   ø€ ô ˆvÐ0×1Ò1Ô6QØ×&Ñ&÷7ò 7ô 	�Ð1Ô2÷
$ñ ˜$ÕÙ˜%× r   c                óˆ   € V P                  4        F  p\        V4       K  	  \        V R4      '       d   V =\	        V 4       R# )zzClean up the qconfig left in the module so that new qconfig can be
propagated.

Args:
    module: module to be cleaned up
r"   N)ÚchildrenÚ_remove_qconfigrF   r"   r¤   )r/   r7   s   & r   r§   r§   µ  s9   € ð —‘Ö"ˆÜ˜Öñ #ô ˆv�y×!Ò!ØˆNä# FÖ+r   c                ó  € \         P                  P                  R4       Vf   \        4       pV'       g   \        P
                  ! V 4      p V P                  4        \        V RR7       V! V .VO5!   \        WRR7       V # )aS  Quantize the input float model with post training static quantization.

First it will prepare the model for calibration, then it calls
`run_fn` which will run the calibration step, after that we will
convert the model to a quantized model.

Args:
    model: input float model
    run_fn: a calibration function for calibrating the prepared model
    run_args: positional arguments for `run_fn`
    inplace: carry out model transformations in-place, the original module is mutated
    mapping: correspondence between original module types and quantized counterparts

Return:
    Quantized model.
z"quantization_api.quantize.quantizeT©r�   )	r(   r†   r‡   r   rˆ   r‰   Úevalr’   Úconvert)rŽ   Úrun_fnÚrun_argsÚmappingr�   s   &&&&&r   Úquantizer¯   Å  sd   € ô$ 
‡H�H× Ñ Ð!EÔFØ‚Ü:Ó<ˆßÜ—’˜eÓ$ˆØ	‡J�J„LÜˆE˜4Õ Ù
ˆ5Ð�8ÔÜˆE DÕ)Ø€Lr   c                ó°  € \         P                  P                  R4       VEfž   V\         P                  8X  d}   \        P
                  \        \        P                  \        \        P                  \        \        P                  \        \        P                  \        \        P                  \        /pEMÌV\         P                  8X  d}   \        P
                  \        \        P                  \        \        P                  \        \        P                  \        \        P                  \        \        P                  \        /pEM;V\         P                  8X  d,   \        P                  \         \        P"                  \         /pMûV\         P$                  8X  d   \        P                  \&        /pMÏ\)        RV R24      h\+        V\,        4      '       d«   V\         P                  J d   \        pMfV\         P                  J d   \        pMKV\         P                  J d   \         pM0V\         P$                  J d   \&        pM\/        R\1        V4      4      h\3        \5        V\6        P8                  ! V4      4      4      pVf   \;        4       pV'       g   \<        P>                  ! V 4      p V PA                  4        \C        W4       \E        WRR7       V # )a*  Converts a float model to dynamic (i.e. weights-only) quantized model.

Replaces specified modules with dynamic weight-only quantized versions and output the quantized model.

For simplest usage provide `dtype` argument that can be float16 or qint8. Weight-only quantization
by default is performed for layers with large weights size - i.e. Linear and RNN variants.

Fine grained control is possible with `qconfig` and `mapping` that act similarly to `quantize()`.
If `qconfig` is provided, the `dtype` argument is ignored.

Args:
    model: input model
    qconfig_spec: Either:

        - A dictionary that maps from name or type of submodule to quantization
          configuration, qconfig applies to all submodules of a given
          module unless qconfig for the submodules are specified (when the
          submodule already has qconfig attribute). Entries in the dictionary
          need to be QConfig instances.

        - A set of types and/or submodule names to apply dynamic quantization to,
          in which case the `dtype` argument is used to specify the bit-width

    inplace: carry out model transformations in-place, the original module is mutated
    mapping: maps type of a submodule to a type of corresponding dynamically quantized version
        with which the submodule needs to be replaced

z*quantization_api.quantize.quantize_dynamicz5Don't know how to quantize with default settings for z. Provide full qconfig pleasez.Unknown dtype specified for quantize_dynamic: Tr©   )#r(   r†   r‡   Úqint8rf   ÚLinearr   ÚLSTMÚGRUÚLSTMCellÚRNNCellÚGRUCellÚfloat16r   Úquint8ÚEmbeddingBagr	   Ú	EmbeddingÚquint4x2r
   Ú
ValueErrorr]   r—   ÚRuntimeErrorÚstrÚdictÚzipÚ	itertoolsÚrepeatr   rˆ   r‰   rª   r:   r«   )rŽ   Úqconfig_specÚdtyper®   r�   Údefault_qconfigs   &&&&& r   Úquantize_dynamicrÇ   ã  sç  € ô@ 
‡H�H× Ñ Ð!MÔNØÓØ”E—K‘KÔä—	‘	Ô2Ü—‘Ô0Ü—‘Ô/Ü—‘Ô4Ü—
‘
Ô3Ü—
‘
Ô3ðŠLð ”e—m‘mÔ#ä—	‘	Ô2Ü—‘Ô0Ü—‘Ô/Ü—‘Ô4Ü—
‘
Ô3Ü—
‘
Ô3ðŠLð ”e—l‘lÔ"ä—‘Ô!BÜ—‘Ô?ð‰Lð ”e—n‘nÔ$ä—‘Ô!Gð‰Lô ØGÈÀwÐNkÐlóð ô 
�L¤#×	&Ò	&Ø”E—K‘KÓÜ5‰OØ”e—m‘mÓ#Ü5‰OØ”e—l‘lÓ"Ü?‰OØ”e—n‘nÓ$ÜD‰OäØ@Ä#ÀeÃ*óð ô œC ¬i×.>Ò.>¸Ó.OÓPÓQˆà‚Ü;Ó=ˆçÜ—’˜eÓ$ˆØ	‡J�J„LÜ�uÔ+ÜˆE DÕ)Ø€Lr   c                óV  € \         P                  P                  R4       V P                  '       g   \	        R4      hVf   \        4       pV'       g   \        P                  ! V 4      p \        V RR7       \        WRRR7       \        V \        VP                  4       4      RR7       V # )	aé  
Prepares a copy of the model for quantization calibration or
quantization-aware training and converts it to quantized version.

Quantization configuration should be assigned preemptively
to individual submodules in `.qconfig` attribute.

Args:
    model: input model to be modified in-place
    mapping: dictionary that maps float modules to quantized modules to be
             replaced.
    inplace: carry out model transformations in-place, the original module
             is mutated
z%quantization_api.quantize.prepare_qatz1prepare_qat only works on models in training modeNr€   TF)r®   r�   Úremove_qconfig)r‘   r�   )r(   r†   r‡   ÚtrainingrG   r   rˆ   r‰   r:   r«   r’   r—   Úvalues)rŽ   r®   r�   s   &&&r   Úprepare_qatrÌ   >  s~   € ô  
‡H�H× Ñ Ð!HÔIØ�>�>ˆ>ÜÐPÓQÐQØ‚Ü1Ó3ˆçÜ—’˜eÓ$ˆä�u¨4Õ0ÜˆE¨DÀÕGÜˆE´°W·^±^Ó5EÓ1FÐPTÕUØ€Lr   c                óè   € \         P                  P                  R4       V'       g   \        P                  ! V 4      p V P                  4        \        V RR7       V! V .VO5!   \        V RR7       V # )aC  Do quantization aware training and output a quantized model

Args:
    model: input model
    run_fn: a function for evaluating the prepared model, can be a
            function that simply runs the prepared model or a training
            loop
    run_args: positional arguments for `run_fn`

Return:
    Quantized model.
z&quantization_api.quantize.quantize_qatTr©   )r(   r†   r‡   rˆ   r‰   ÚtrainrÌ   r«   )rŽ   r¬   r­   r�   s   &&&&r   Úquantize_qatrÏ   ]  sW   € ô 
‡H�H× Ñ Ð!IÔJßÜ—’˜eÓ$ˆØ	‡K�K„MÜ�˜tÕ$Ù
ˆ5Ð�8ÔÜˆE˜4Õ Ø€Lr   c           	     óÈ   € \         P                  P                  R4       V'       g   \        P                  ! V 4      p \        V VRVVVR7       V'       d   \        V 4       V # )ad  Converts submodules in input module to a different module according to `mapping`
by calling `from_float` method on the target module class. And remove qconfig at the
end if remove_qconfig is set to True.

Args:
    `module`: prepared and calibrated module
    `mapping`: a dictionary that maps from source module type to target
               module type, can be overwritten to allow swapping user defined
               Modules
    `inplace`: carry out model transformations in-place, the original module
               is mutated
    `convert_custom_config_dict`: custom configuration dictionary for convert function
    `use_precomputed_fake_quant`: a flag to enable use of precomputed fake quant

.. code-block:: python

   # Example of convert_custom_config_dict:
   convert_custom_config_dict = {
       # user will manually define the corresponding quantized
       # module class which has a from_observed class method that converts
       # observed custom module to quantized custom module
       "observed_to_quantized_custom_module_class": {
           ObservedCustomModule: QuantizedCustomModule
       }
   }

z!quantization_api.quantize.convertT)r�   Úis_referenceÚconvert_custom_config_dictÚuse_precomputed_fake_quant)r(   r†   r‡   rˆ   r‰   Ú_convertr§   )r/   r®   r�   rÉ   rÑ   rÒ   rÓ   s   &&&&&&&r   r«   r«   u  sU   € ôJ 
‡H�H× Ñ Ð!DÔEßÜ—’˜vÓ&ˆÜØØØØ!Ø#=Ø#=õ÷ Ü˜ÔØ€Mr   c           
     óÐ  € Vf   V'       d   \        4       M	\        4       pVf   \        4       pVP                  R/ 4      pV'       g   \        P
                  ! V 4      p / pV P                  4        FJ  w  r‰\        V	\        4      '       g"   \        V	4      V9  d   \        V	VRVVVR7       \        W‘We4      Wx&   KL  	  VP                  4        F  w  r«W°P                  V
&   K  	  V # )aC  Converts submodules in input module to a different module according to `mapping`
by calling `from_float` method on the target module class

Args:
    module: input module
    mapping: a dictionary that maps from source module type to target
             module type, can be overwritten to allow swapping user defined
             Modules
    inplace: carry out model transformations in-place, the original module
             is mutated
    is_reference: a flag to enable quantized reference module
    use_precomputed_fake_quant: a flag to enable use of precomputed fake quant

r   T©rÓ   )r   r   r    r&   rˆ   r‰   r,   r]   r   r   rÔ   Úswap_moduler˜   r~   )r/   r®   r�   rÑ   rÒ   rÓ   rs   Úreassignr6   ÚmodÚkeyÚvalues   &&&&&&      r   rÔ   rÔ   ª  sè   € ð, ‚÷ ô ?Ô@ä9Ó;ð 	ð
 "Ò)Ü%CÓ%EÐ"Ø"<×"@Ñ"@Ø3°Ró#Ð÷ Ü—’˜vÓ&ˆØ€HØ×*Ñ*Ö,‰	ˆô ˜3¤×-Ò-Ü,¨SÓ1Ð9TÔTäØØØØØ*Ø+Eõô %ØÐ5ó
ˆ‹ñ -ð& —n‘nÖ&‰
ˆØ$�‰˜Óñ 'ð €Mr   c                óÐ  € T p\        V R4      '       EdQ   V P                  EeB   Rp\        V 4      V9   d%   V\        V 4      ,          P                  V 4      pRpMÿ\        V 4      V9   dð   V\        V 4      ,          p\        VR4      '       du   VP                  '       dc   V P                  f   \        R4      hV P                  P                  4       pV! V P                  4       \        V4      pVP                  W4      pMU\        P                  ! VP                  4      p	RV	P                  9   d   VP                  WR7      pMVP                  V 4      pRpV'       Ed   V P                  P                  4        F  p
VP                  V
4       K  	  V P                  P                  4        F   pV\         Jg   K  VP#                  V4       K"  	  \%        V 4      p\'        V4      ^8:  g:   \'        V4      ^8X  d   \(        P*                  ! R	4      V9   g   \        R
V 24      h\'        V4      ^ 8”  d   \-        \/        V4      4      MRpV'       d   VP1                  V4       V# )zíSwaps the module if it has a quantized counterpart and it has an
`observer` attached.

Args:
    mod: input module
    mapping: a dictionary that maps from nn module to nnq module

Return:
    The corresponding quantized module of `mod`
r"   NFTÚ_IS_REFERENCEzAmodule qconfig must not be None when swapping to reference modulerÓ   rÖ   rx   zOswap_module only works with cpu or single-device CUDA modules, but got devices )rF   r"   r   Úfrom_observedrÝ   rG   Úweightr   rl   ÚinspectÚ	signaturery   r•   rË   rH   r–   rA   rI   rb   rc   r(   rQ   rd   re   rP   )rÙ   r®   rs   rÓ   Únew_modÚswappedÚqmodÚweight_post_processÚweight_qparamsÚsigÚpre_hook_fnrŸ   rt   rQ   s   &&&&          r   r×   r×   è  s  € ð €GÜˆs�I×Ó 3§;¡;Ó#:ØˆÜ'¨Ó,Ð0KÔKØ1Ü,¨SÓ1õç‰m˜CÓ ð ð ‰GÜ)¨#Ó.°'Ô9ØÔ7¸Ó<Õ=ˆDÜ�t˜_×-Ò-°$×2D×2DÐ2DØ—;‘;Ò&Ü(Ø[óð ð '*§k¡k×&8Ñ&8Ó&:Ð#Ù# C§J¡JÔ/Ü!0Ð1DÓ!E�ØŸ/™/¨#Ó>‘ä×'Ò'¨¯©Ó8�Ø/°3·>±>ÔAØ"Ÿo™oØð .ó ‘Gð #Ÿo™o¨cÓ2�GØˆGçˆ7à"×5Ñ5×<Ñ<Ö>�Ø×1Ñ1°+Ö>ñ  ?ð ×-Ñ-×4Ñ4Ö6�ØÔ"8Õ8Ø×1Ñ1°'Ö:ñ 7ô
 +¨3Ó/ˆGä�G“ Ô!Ü˜“L AÔ%¬%¯,ª,°vÓ*>À'Ô*Iä$ØeÐfmÐenÐoóð ô -0°«L¸1Ô,<”Tœ$˜w›-Ô(À$ˆFßØ—
‘
˜6Ô"Ø€Nr   c                óâ   € R p\        V R4      '       d   V P                  W! V4      R,           &   V P                  4        F*  w  rEV'       d   V! V4      V,           MTp\        WQV4       K,  	  R# )a  Traverse the modules and save all observers into dict.
This is mainly used for quantization accuracy debug
Args:
    mod: the top module we want to save all observers
    prefix: the prefix for the current module
    target_dict: the dictionary used to save all the observers
c                 ó&   € V R 8X  d   V # V R,           # )Ú r#   r   )r2   s   &r   Ú
get_prefixÚ&_get_observer_dict.<locals>.get_prefix4  s   € Ø 2œˆvÐ7¨6°C­<Ð7r   r=   N)rF   r=   r,   Ú_get_observer_dict)rÙ   Útarget_dictr2   rì   r6   r7   r8   s   &&&    r   rî   rî   +  si   € ò8ô ˆsÐ-×.Ò.à×'Ñ'ð 	�J˜vÓ&Ð)BÕBÑCð ×)Ñ)Ö+‰ˆß5;™
 6Ó*¨TÖ1ÀˆÜ˜5¨}Ö=ó ,r   )
r    r:   r}   r’   r¯   rÇ   rÌ   rÏ   r«   r×   )Nrë   N)NNr¢   )NNNN)FNNN)NF)NFTFNF)NFFNF)rë   )Erˆ   rà   rÂ   Útyping_extensionsrŒ   r(   Útorch.ao.nn.quantizedr)   rf   Ú	quantizedri   Útorch.nnÚtorch.ao.nn.intrinsicr   Útorch.ao.quantization.observerr   Útorch.ao.quantization.qconfigr   r   r   r   r	   r
   Ú+torch.ao.quantization.quantization_mappingsr   r   r   r   r   r   r   r   Útorch.ao.quantization.stubsr   r   Útorch.nn.utils.parametrizer   Úutilsr   r   r   Ú__all__Úis_activation_post_processr³   ÚquantizableÚMultiheadAttentionr   r    r.   r:   rA   rC   rK   ro   rb   r}   Ú
deprecatedr’   r¤   r§   r¯   r±   rÇ   rÌ   rÏ   r«   rÔ   r×   rî   r   r   r   Ú<module>r      sø  ðã Û Û Û Û ã ß #Ó #Ý Ý .Ý F÷÷ ÷	÷ 	ó 	÷ BÝ C÷ñ ò€ð 9Ð ð ,Ø
�‰�—‘×$Ñ$Ø
×Ñ˜rŸ~™~×@Ñ@ð.ð 0Ø
�‰×Ñ˜RŸ\™\×.Ñ.Ø
�‰×)Ñ)¨2¯<©<×+JÑ+Jð2ð	Ð ò'ô
.ôbò20ò
2ô
KôH/òVòð6 ×ÒÐ1Ó2ó@ó 3ð@òF!ò4,ð  ×ÒÐ1Ó2óó 3ðð: ×ÒÐ1Ó2à E§K¡K¸ÀuóWó 3ðWðt ×ÒÐ1Ó2óó 3ðð< ×ÒÐ1Ó2óó 3ðð. ×ÒÐ1Ó2ó1ó 3ð1ôh;ô|@öF>r   