+
    –°³j´~  ã                   ó8  € ^ RI t ^ RIt^ RIt^ RIHt ^ RIt^ RIHt ^ RIH	t	 ^RI
HtHt ^RIHt ^RIHtHtHt ^RIHt ^R	IHt ^R
IHt ^RIHtHtHt ^RIHtHt ^RI H!t! ^RI"H#t# R R lt$R R lt%R R lt&R R lt'R-R R llt(R.R R llt)R-R R llt*R-R R llt+]PX                  ! ]#4      R/R R  ll4       t-]PX                  ! ]#4      R-R! R" ll4       t.R0R# R$ llt/]PX                  ! ]#4      R1R% R& ll4       t0R2R' R( llt1R/R) R* llt2R3R+ R, llt3R# )4é    N)ÚAny©ÚGraphModule)Ú_USER_PRESERVED_ATTRIBUTES_KEY)ÚBackendConfigÚget_tensorrt_backend_config)Úconvert)ÚConvertCustomConfigÚFuseCustomConfigÚPrepareCustomConfig)Úfuse)ÚObservedGraphModule)Úprepare)ÚQuantizationTracerÚScopeÚScopeContextManager)Úget_custom_module_class_keysÚ#get_skipped_module_name_and_classes)ÚQConfigMapping)ÚDEPRECATION_WARNINGc                ó”   € V ^8„  d   QhR\         \        P                  P                  ,          R\        \
        \        3,          RR/# )é   ÚmodelÚpreserved_attrsÚreturnN)r   ÚtorchÚnnÚModuleÚdictÚstrr   )Úformats   "Úb/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torch/ao/quantization/quantize_fx.pyÚ__annotate__r#      s;   € ÷ 	(ñ 	(ÜœŸ™Ÿ™Õ(ð	(äœ#œs˜(•^ð	(ð 
ñ	(ó    c                óÈ   € \         P                   ! V4      V P                  \        &   V P                  \        ,          P                  4        F  w  r#\	        WV4       K  	  R# )zXStore preserved attributes to the model.meta so that it can be preserved during deepcopyN)ÚcopyÚmetar   ÚitemsÚsetattr)r   r   Ú	attr_nameÚattrs   &&  r"   Úattach_preserved_attrs_to_modelr,      sH   € ô
 26·²¸?Ó1K€E‡J�JÔ-Ñ.ð !Ÿ:™:Ô&DÕE×KÑKÖM‰ˆ	Ü� $Ö'ó Nr$   c                óP   € V ^8„  d   QhR\         P                  P                  RR/# ©r   r   r   N©r   r   r   )r!   s   "r"   r#   r#   %   s"   € ÷ 
ñ 
¤%§(¡(§/¡/ð 
°dñ 
r$   c                 ó–   € \        V \        4      '       g3   \        R\        \	        V 4      4      ,           R,           R,           4      hR# )z#input model must be a GraphModule, z Please make zsure to follow the tutorials.Nz,input model must be a GraphModule, Got type:)Ú
isinstancer   Ú
ValueErrorr    Útype)r   s   &r"   Ú_check_is_graph_moduler4   %   sK   € Ü�eœ[×)Ò)Üðä”$�u“+Óõð õð .õ	.ó
ð 	
ñ *r$   c                ó(   € V ^8„  d   QhR\         RR/# r.   r   )r!   s   "r"   r#   r#   0   s   € ÷ 
ñ 
¬[ð 
¸Tñ 
r$   c                óv   € V P                   P                   F  p\        VR4      '       d   K  / Vn        K   	  R# )a¦  Attach meta field to all nodes of the graph if it does not exist,
meta field is a field stores some meta information about the node, such
as dtype and shape information for output of the node, this only exists
if the program is captured by make_fx (used in quantize_pt2e flow), if
the program is captured by torch.fx symbolic tracing, this field may not exist,
so we add it here to avoid checking this all over the places
r'   N)ÚgraphÚnodesÚhasattrr'   )r   Únodes   & r"   Ú!_attach_meta_to_node_if_not_existr;   0   s,   € ð —‘×!Ô!ˆÜ�t˜V×$Ô$ØˆDŽIó "r$   c                óP   € V ^8„  d   QhR\         P                  P                  RR/# r.   r/   )r!   s   "r"   r#   r#   =   s&   € ÷ Iñ IœeŸh™hŸo™oð I°$ñ Ir$   c                óž  € . pV P                  4        Fa  w  r#\        V\        P                  P                  P
                  P                  4      '       d   VP                  V4       KV  \        V4       Kc  	  V FO  pV P                  V \        P                  P                  P
                  P                  4       V P                  V&   KQ  	  R# )z+Swap FloatFunctional with FXFloatFunctionalN)Únamed_childrenr1   r   Úaor   Ú	quantizedÚFloatFunctionalÚappendÚ_swap_ff_with_fxffÚ_modulesÚFXFloatFunctional)r   Úmodules_to_swapÚnameÚmodules   &   r"   rC   rC   =   s�   € à€OØ×,Ñ,Ö.‰ˆÜ�fœeŸh™hŸk™k×3Ñ3×CÑC×DÒDØ×"Ñ" 4Ö(ä˜vÖ&ñ	 /ó  ˆØ�N‰N˜4Ð Ü$Ÿx™xŸ{™{×4Ñ4×FÑFÓHˆ�‰�tÓó  r$   c                óà   € V ^8„  d   QhR\         R\        R\        \        \        \
        3,          ,          R,          R\        \        \        \
        3,          ,          R,          R\         /# )r   r   Úis_qatÚfuse_custom_configNÚbackend_configr   )r   Úboolr   r   r    r   r   )r!   s   "r"   r#   r#   K   se   € ÷ Cñ CÜðCäðCô )¬4´´S°­>Õ9¸DÕ@ðCô "¤D¬¬c¨¥NÕ2°TÕ9ð	Cô
 ñCr$   c                ó0   € \        V 4       \        WW#4      # )zžInternal helper function to fuse modules in preparation for quantization

Args:
    model: GraphModule object from symbolic tracing (torch.fx.symbolic_trace)
)r4   r   )r   rJ   rK   rL   s   &&&&r"   Ú_fuse_fxrO   K   s   € ô ˜5Ô!Ü�Ð1ÓBÐBr$   c                óÐ  € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        3,          ,          R\        R\        \        R3,          R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R	\        \        \
        \        3,          ,          R,          R
\        R\        /	# )r   r   Úqconfig_mappingrJ   Úexample_inputs.Úprepare_custom_configNÚ_equalization_configrL   Úis_standalone_moduler   ©r   r   r   r   r   r    r   rM   Útupler   r   r   )r!   s   "r"   r#   r#   Z   sÀ   € ÷ Eñ EÜ�8‰8�?‰?ðEä#¤d¬3´¨8¥nÕ4ðEô ðEô œ#˜s˜(•Oð	Eô
 /´´c¼3°hµÕ?À$ÕFðEô )¬4´´S°­>Õ9¸DÕ@ðEô "¤D¬¬c¨¥NÕ2°TÕ9ðEô ðEô ñEr$   c                ó�  € Vf   \        4       pVf   \        4       p\        V\        4      '       d4   \        P
                  ! R\        ^R7       \         P                  ! V4      p\        V 4       \        WG4      w  r‰VP                  p
V
 Uu/ uF"  p\        W4      '       g   K  V\        W4      bK$  	  pp\        W‰4      p\        WP                  V 4      4      p\!        V4       \#        4       P%                  VP                  4      p\'        WâWö4      p\)        VVVVP*                  VVVVVR7	      p\-        VV4       V# u upi )a2  Internal helper function for prepare_fx
    Args:
      `model`, `qconfig_mapping`, `prepare_custom_config`, `_equalization_config`:
      see docs for :func:`~torch.ao.quantization.prepare_fx`
      `is_standalone_module`: a boolean flag indicates whether we are
      quantizing a standalone module or not, a standalone module
      is a submodule of the parent module that is not inlined in the
forward graph of the parent module,
      the way we quantize standalone module is described in:
      :func:`~torch.ao.quantization._prepare_standalone_module_fx`
zšPassing a prepare_custom_config_dict to prepare is deprecated and will not be supported in a future version. Please pass in a PrepareCustomConfig instead.©Ú
stacklevel)rR   rS   rT   rL   rU   )r   r   r1   r   ÚwarningsÚwarnÚFutureWarningÚ	from_dictrC   r   Úpreserved_attributesr9   Úgetattrr   r   Útracer;   r   Úset_preserved_attributesrO   r   Únode_name_to_scoper,   )r   rQ   rJ   rR   rS   rT   rL   rU   Úskipped_module_namesÚskipped_module_classesÚpreserved_attr_namesr+   r   ÚtracerÚgraph_modulerK   Úprepareds   &&&&&&&&         r"   Ú_prepare_fxrj   Z   sP  € ð* Ò$Ü 3Ó 5ÐØÒ#Ü-Ó/ÐäÐ'¬×.Ò.Ü�ŠðQäØõ		
ô !4× =Ò =Ð>SÓ TÐô �uÔä3VØó4Ñ0Ðð 1×EÑEÐñ )óá(ˆDÜ�5×ô 	#ˆŒg�eÓ"Ò"Ù(ð ð ô  Ð 4ÓM€FÜ˜u§l¡l°5Ó&9Ó:€LÜ% lÔ3ä)Ó+×DÑDØ×2Ñ2óÐô ˜LÐ2DÓU€LÜØØØØ×!Ñ!Ø%Ø3Ø1Ø%Ø1ô
€Hô $ H¨oÔ>Ø€Oùò7s   ÂEÂ&Ec                ór  € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        3,          ,          R\        R\        \        R3,          R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R	\        /# )
r   r   rQ   rJ   rR   .rS   NrL   r   rV   )r!   s   "r"   r#   r#   ¢   s�   € ÷ 'ñ 'Ü�8‰8�?‰?ð'ä#¤d¬3´¨8¥nÕ4ð'ô ð'ô œ#˜s˜(•Oð	'ô
 /´´c¼3°hµÕ?À$ÕFð'ô "¤D¬¬c¨¥NÕ2°TÕ9ð'ô ñ'r$   c           
     ó&   € \        V VVVVVRR7      # )aÏ  [Internal use only] Prepare a standalone module, so that it can be used when quantizing the
parent module.
standalone_module means it a submodule that is not inlined in parent module,
and will be quantized separately as one unit.

How the standalone module is observed is specified by `input_quantized_idxs` and
`output_quantized_idxs` in the prepare_custom_config for the standalone module

Returns:

    * model(GraphModule): prepared standalone module. It has these attributes in
      model.meta:

        * `standalone_module_input_quantized_idxs(List[Int])`: a list of
          indexes for the graph input that is expected to be quantized,
          same as input_quantized_idxs configuration provided
          for the standalone module
        * `standalone_module_output_quantized_idxs(List[Int])`: a list of
          indices for the graph output that is quantized
          same as input_quantized_idxs configuration provided
          for the standalone module

T)rL   rU   )rj   )r   rQ   rJ   rR   rS   rL   s   &&&&&&r"   Ú_prepare_standalone_module_fxrm   ¢   s&   € ô> ØØØØØØ%Ø!ôð r$   c          	      óü   € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R\        /# )r   r   rK   NrL   r   )	r   r   r   r   r   r    r   r   r   )r!   s   "r"   r#   r#   Ì   s\   € ÷ .ñ .Ü�8‰8�?‰?ð.ä(¬4´´S°­>Õ9¸DÕ@ð.ô "¤D¬¬c¨¥NÕ2°TÕ9ð.ô ñ	.r$   c                óô  € Vf   \        4       p\        V\        4      '       d4   \        P                  ! R\
        ^R7       \         P                  ! V4      p\        P                  P                  R4       VP                  pV Uu/ uF"  p\        W4      '       g   K  V\        W4      bK$  	  pp\        P                  P                  V 4      p\        V4       \!        VRW4      p\#        We4       V# u upi )aç  Fuse modules like conv+bn, conv+bn+relu etc, model must be in eval mode.
Fusion rules are defined in torch.ao.quantization.fx.fusion_pattern.py

Args:

    * `model` (torch.nn.Module): a torch.nn.Module model
    * `fuse_custom_config` (FuseCustomConfig): custom configurations for fuse_fx.
        See :class:`~torch.ao.quantization.fx.custom_config.FuseCustomConfig` for more details
Example::

    from torch.ao.quantization import fuse_fx

    m = Model().eval()
    m = fuse_fx(m)

z‘Passing a fuse_custom_config_dict to fuse is deprecated and will not be supported in a future version. Please pass in a FuseCustomConfig instead.rY   z$quantization_api.quantize_fx.fuse_fxF)r   r1   r   r[   r\   r]   r^   r   Ú_CÚ_log_api_usage_oncer_   r9   r`   ÚfxÚsymbolic_tracer;   rO   r,   )r   rK   rL   rf   r+   r   rh   s   &&&    r"   Úfuse_fxrt   Ì   sâ   € ð* Ò!Ü-Ó/ÐäÐ$¤d×+Ò+Ü�ŠðNäØõ		
ô .×7Ò7Ð8JÓKÐä	‡H�H× Ñ Ð!GÔHØ-×BÑBÐñ )óá(ˆDÜ�5×ô 	#ˆŒg�eÓ"Ò"Ù(ð ð ô —8‘8×*Ñ*¨5Ó1€LÜ% lÔ3Ü˜L¨%Ð1CÓT€Lä# LÔBØÐùòs   ÂC5ÂC5c                ó¸  € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        3,          ,          R\        \        R3,          R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R	\        /# )
r   r   rQ   rR   .rS   NrT   rL   r   ©r   r   r   r   r   r    r   rW   r   r   r   )r!   s   "r"   r#   r#   þ   sª   € ÷ Tñ TÜ�8‰8�?‰?ðTä#¤d¬3´¨8¥nÕ4ðTô œ#˜s˜(•OðTô /´´c¼3°hµÕ?À$ÕFð	Tô
 )¬4´´S°­>Õ9¸DÕ@ðTô "¤D¬¬c¨¥NÕ2°TÕ9ðTô ñTr$   c           	     ób   € \         P                  P                  R4       \        V VRVVVV4      # )a'  Prepare a model for post training quantization

Args:
  * `model` (torch.nn.Module): torch.nn.Module model

  * `qconfig_mapping` (QConfigMapping): QConfigMapping object to configure how a model is
     quantized, see :class:`~torch.ao.quantization.qconfig_mapping.QConfigMapping`
     for more details

  * `example_inputs` (Tuple[Any, ...]): Example inputs for forward function of the model,
     Tuple of positional args (keyword args can be passed as positional args as well)

  * `prepare_custom_config` (PrepareCustomConfig): customization configuration for quantization tool.
      See :class:`~torch.ao.quantization.fx.custom_config.PrepareCustomConfig` for more details

  * `_equalization_config`: config for specifying how to perform equalization on the model

  * `backend_config` (BackendConfig): config that specifies how operators are quantized
     in a backend, this includes how the operators are observed,
     supported fusion patterns, how quantize/dequantize ops are
     inserted, supported dtypes etc. See :class:`~torch.ao.quantization.backend_config.BackendConfig` for more details

Return:
  A GraphModule with observer (configured by qconfig_mapping), ready for calibration

Example::

    import torch
    from torch.ao.quantization import get_default_qconfig_mapping
    from torch.ao.quantization.quantize_fx import prepare_fx

    class Submodule(torch.nn.Module):
        def __init__(self) -> None:
            super().__init__()
            self.linear = torch.nn.Linear(5, 5)
        def forward(self, x):
            x = self.linear(x)
            return x

    class M(torch.nn.Module):
        def __init__(self) -> None:
            super().__init__()
            self.linear = torch.nn.Linear(5, 5)
            self.sub = Submodule()

        def forward(self, x):
            x = self.linear(x)
            x = self.sub(x) + x
            return x

    # initialize a floating point model
    float_model = M().eval()

    # define calibration function
    def calibrate(model, data_loader):
        model.eval()
        with torch.no_grad():
            for image, target in data_loader:
                model(image)

    # qconfig is the configuration for how we insert observers for a particular
    # operator
    # qconfig = get_default_qconfig("fbgemm")
    # Example of customizing qconfig:
    # qconfig = torch.ao.quantization.QConfig(
    #    activation=MinMaxObserver.with_args(dtype=torch.qint8),
    #    weight=MinMaxObserver.with_args(dtype=torch.qint8))
    # `activation` and `weight` are constructors of observer module

    # qconfig_mapping is a collection of quantization configurations, user can
    # set the qconfig for each operator (torch op calls, functional calls, module calls)
    # in the model through qconfig_mapping
    # the following call will get the qconfig_mapping that works best for models
    # that target "fbgemm" backend
    qconfig_mapping = get_default_qconfig_mapping("fbgemm")

    # We can customize qconfig_mapping in different ways.
    # e.g. set the global qconfig, which means we will use the same qconfig for
    # all operators in the model, this can be overwritten by other settings
    # qconfig_mapping = QConfigMapping().set_global(qconfig)
    # e.g. quantize the linear submodule with a specific qconfig
    # qconfig_mapping = QConfigMapping().set_module_name("linear", qconfig)
    # e.g. quantize all nn.Linear modules with a specific qconfig
    # qconfig_mapping = QConfigMapping().set_object_type(torch.nn.Linear, qconfig)
    # for a more complete list, please see the docstring for :class:`torch.ao.quantization.QConfigMapping`
    # argument

    # example_inputs is a tuple of inputs, that is used to infer the type of the
    # outputs in the model
    # currently it's not used, but please make sure model(*example_inputs) runs
    example_inputs = (torch.randn(1, 3, 224, 224),)

    # TODO: add backend_config after we split the backend_config for fbgemm and qnnpack
    # e.g. backend_config = get_default_backend_config("fbgemm")
    # `prepare_fx` inserts observers in the model based on qconfig_mapping and
    # backend_config. If the configuration for an operator in qconfig_mapping
    # is supported in the backend_config (meaning it's supported by the target
    # hardware), we'll insert observer modules according to the qconfig_mapping
    # otherwise the configuration in qconfig_mapping will be ignored
    #
    # Example:
    # in qconfig_mapping, user sets linear module to be quantized with quint8 for
    # activation and qint8 for weight:
    # qconfig = torch.ao.quantization.QConfig(
    #     observer=MinMaxObserver.with_args(dtype=torch.quint8),
    #     weight=MinMaxObserver.with-args(dtype=torch.qint8))
    # Note: current qconfig api does not support setting output observer, but
    # we may extend this to support these more fine grained control in the
    # future
    #
    # qconfig_mapping = QConfigMapping().set_object_type(torch.nn.Linear, qconfig)
    # in backend config, linear module also supports in this configuration:
    # weighted_int8_dtype_config = DTypeConfig(
    #   input_dtype=torch.quint8,
    #   output_dtype=torch.quint8,
    #   weight_dtype=torch.qint8,
    #   bias_type=torch.float)

    # linear_pattern_config = BackendPatternConfig(torch.nn.Linear) \
    #    .set_observation_type(ObservationType.OUTPUT_USE_DIFFERENT_OBSERVER_AS_INPUT) \
    #    .add_dtype_config(weighted_int8_dtype_config) \
    #    ...

    # backend_config = BackendConfig().set_backend_pattern_config(linear_pattern_config)
    # `prepare_fx` will check that the setting requested by user in qconfig_mapping
    # is supported by the backend_config and insert observers and fake quant modules
    # in the model
    prepared_model = prepare_fx(float_model, qconfig_mapping, example_inputs)
    # Run calibration
    calibrate(prepared_model, sample_inference_data)
z'quantization_api.quantize_fx.prepare_fxF©r   rp   rq   rj   )r   rQ   rR   rS   rT   rL   s   &&&&&&r"   Ú
prepare_fxry   ý   s:   € ôX 
‡H�H× Ñ Ð!JÔKÜØØØØØØØóð r$   c                óf  € V ^8„  d   QhR\         P                  P                  R\        \        \
        \        3,          ,          R\        \        R3,          R\        \        \
        \        3,          ,          R,          R\        \        \
        \        3,          ,          R,          R\        /# )	r   r   rQ   rR   .rS   NrL   r   rv   )r!   s   "r"   r#   r#   –  s�   € ÷ mñ mÜ�8‰8�?‰?ðmä#¤d¬3´¨8¥nÕ4ðmô œ#˜s˜(•Oðmô /´´c¼3°hµÕ?À$ÕFð	mô
 "¤D¬¬c¨¥NÕ2°TÕ9ðmô ñmr$   c           	     ób   € \         P                  P                  R4       \        V VRVVVR7      # )aÞ  Prepare a model for quantization aware training

Args:
  * `model` (torch.nn.Module): torch.nn.Module model
  * `qconfig_mapping` (QConfigMapping): see :func:`~torch.ao.quantization.prepare_fx`
  * `example_inputs` (Tuple[Any, ...]): see :func:`~torch.ao.quantization.prepare_fx`
  * `prepare_custom_config` (PrepareCustomConfig): see :func:`~torch.ao.quantization.prepare_fx`
  * `backend_config` (BackendConfig): see :func:`~torch.ao.quantization.prepare_fx`

Return:
  A GraphModule with fake quant modules (configured by qconfig_mapping and backend_config), ready for
  quantization aware training

Example::

    import torch
    from torch.ao.quantization import get_default_qat_qconfig_mapping
    from torch.ao.quantization.quantize_fx import prepare_qat_fx


    class Submodule(torch.nn.Module):
        def __init__(self) -> None:
            super().__init__()
            self.linear = torch.nn.Linear(5, 5)

        def forward(self, x):
            x = self.linear(x)
            return x


    class M(torch.nn.Module):
        def __init__(self) -> None:
            super().__init__()
            self.linear = torch.nn.Linear(5, 5)
            self.sub = Submodule()

        def forward(self, x):
            x = self.linear(x)
            x = self.sub(x) + x
            return x


    # initialize a floating point model
    float_model = M().train()
    # (optional, but preferred) load the weights from pretrained model
    # float_model.load_weights(...)


    # define the training loop for quantization aware training
    def train_loop(model, train_data):
        model.train()
        for image, target in data_loader:
            ...


    # qconfig is the configuration for how we insert observers for a particular
    # operator
    # qconfig = get_default_qconfig("fbgemm")
    # Example of customizing qconfig:
    # qconfig = torch.ao.quantization.QConfig(
    #    activation=FakeQuantize.with_args(observer=MinMaxObserver.with_args(dtype=torch.qint8)),
    #    weight=FakeQuantize.with_args(observer=MinMaxObserver.with_args(dtype=torch.qint8)))
    # `activation` and `weight` are constructors of observer module

    # qconfig_mapping is a collection of quantization configurations, user can
    # set the qconfig for each operator (torch op calls, functional calls, module calls)
    # in the model through qconfig_mapping
    # the following call will get the qconfig_mapping that works best for models
    # that target "fbgemm" backend
    qconfig_mapping = get_default_qat_qconfig_mapping("fbgemm")

    # We can customize qconfig_mapping in different ways, please take a look at
    # the docstring for :func:`~torch.ao.quantization.prepare_fx` for different ways
    # to configure this

    # example_inputs is a tuple of inputs, that is used to infer the type of the
    # outputs in the model
    # currently it's not used, but please make sure model(*example_inputs) runs
    example_inputs = (torch.randn(1, 3, 224, 224),)

    # TODO: add backend_config after we split the backend_config for fbgemm and qnnpack
    # e.g. backend_config = get_default_backend_config("fbgemm")
    # `prepare_qat_fx` inserts observers in the model based on qconfig_mapping and
    # backend_config, if the configuration for an operator in qconfig_mapping
    # is supported in the backend_config (meaning it's supported by the target
    # hardware), we'll insert fake_quantize modules according to the qconfig_mapping
    # otherwise the configuration in qconfig_mapping will be ignored
    # see :func:`~torch.ao.quantization.prepare_fx` for a detailed explanation of
    # how qconfig_mapping interacts with backend_config
    prepared_model = prepare_qat_fx(float_model, qconfig_mapping, example_inputs)
    # Run training
    train_loop(prepared_model, train_loop)

z+quantization_api.quantize_fx.prepare_qat_fxT)rL   rx   )r   rQ   rR   rS   rL   s   &&&&&r"   Úprepare_qat_fxr|   •  s7   € ôL 
‡H�H× Ñ Ð!NÔOÜØØØØØØ%ôð r$   c                ób  € V ^8„  d   QhR\         R\        R\        \        \        \
        3,          ,          R,          R\        R\        R\        \        \        \
        3,          ,          R,          R\        \        \        \
        3,          ,          R,          R	\        R
\        R\         /
# )r   rh   Úis_referenceÚconvert_custom_configNrU   Ú_remove_qconfigrQ   rL   Úis_decomposedÚkeep_original_weightsr   )r   rM   r
   r   r    r   r   r   )r!   s   "r"   r#   r#     s¢   € ÷ -ñ -Üð-äð-ô /´´c¼3°hµÕ?À$ÕFð-ô ð	-ô
 ð-ô $¤d¬3´¨8¥nÕ4°tÕ;ð-ô "¤D¬¬c¨¥NÕ2°TÕ9ð-ô ð-ô  ð-ô ñ-r$   c	                ó†  € Vf   \        4       p\        V\        4      '       d4   \        P                  ! R\
        ^R7       \         P                  ! V4      p\        V 4       VP                  p	V	 U
u/ uF"  p
\        W
4      '       g   K  V
\        W
4      bK$  	  pp
\        V VVVVVVVVR7	      p\        WË4       V# u up
i )z_`is_standalone_module`: see docs in :func:`~torch.ao.quantization.prepare_standalone_module_fx`zšPassing a convert_custom_config_dict to convert is deprecated and will not be supported in a future version. Please pass in a ConvertCustomConfig instead.rY   )Ú_remove_qconfig_flagrQ   rL   r�   r‚   )r
   r1   r   r[   r\   r]   r^   r4   r_   r9   r`   r	   r,   )rh   r~   r   rU   r€   rQ   rL   r�   r‚   rf   r+   r   r@   s   &&&&&&&&&    r"   Ú_convert_fxr…     sÓ   € ð Ò$Ü 3Ó 5ÐäÐ'¬×.Ò.Ü�ŠðQäØõ		
ô !4× =Ò =Ð>SÓ TÐä˜<Ô(Ø0×EÑEÐñ )óá(ˆDÜ�<×&ô 	*ˆŒg�lÓ)Ò)Ù(ð ð ô ØØØØØ,Ø'Ø%Ø#Ø3ô
€Iô $ IÔ?ØÐùò's   Á3B>ÂB>c                ó>  € V ^8„  d   QhR\         R\        \        \        \        3,          ,          R,          R\
        R\        \        \        \        3,          ,          R,          R\        \        \        \        3,          ,          R,          R\
        R\         /# )	r   rh   r   Nr€   rQ   rL   r‚   r   ©r   r
   r   r    r   rM   r   r   )r!   s   "r"   r#   r#   7  s�   € ÷ Bñ BÜðBä.´´c¼3°hµÕ?À$ÕFðBô ðBô $¤d¬3´¨8¥nÕ4°tÕ;ð	Bô
 "¤D¬¬c¨¥NÕ2°TÕ9ðBô  ðBô ñBr$   c           
     ód   € \         P                  P                  R4       \        V RVVVVVR7      # )a 
  Convert a calibrated or trained model to a quantized model

Args:
    * `graph_module` (torch.fx.GraphModule): A prepared and calibrated/trained model (GraphModule)

    * `convert_custom_config` (ConvertCustomConfig): custom configurations for convert function.
        See :class:`~torch.ao.quantization.fx.custom_config.ConvertCustomConfig` for more details

    * `_remove_qconfig` (bool): Option to remove the qconfig attributes in the model after convert.

    * `qconfig_mapping` (QConfigMapping): config for specifying how to convert a model for quantization.

       The keys must include the ones in the qconfig_mapping passed to `prepare_fx` or `prepare_qat_fx`,
       with the same values or `None`. Additional keys can be specified with values set to `None`.

      For each entry whose value is set to None, we skip quantizing that entry in the model::

        qconfig_mapping = QConfigMapping
            .set_global(qconfig_from_prepare)
            .set_object_type(torch.nn.functional.add, None)  # skip quantizing torch.nn.functional.add
            .set_object_type(torch.nn.functional.linear, qconfig_from_prepare)
            .set_module_name("foo.bar", None)  # skip quantizing module "foo.bar"

     * `backend_config` (BackendConfig): A configuration for the backend which describes how
        operators should be quantized in the backend, this includes quantization
        mode support (static/dynamic/weight_only), dtype support (quint8/qint8 etc.),
        observer placement for each operators and fused operators.
        See :class:`~torch.ao.quantization.backend_config.BackendConfig` for more details

Return:
    A quantized model (torch.nn.Module)

Example::

    # prepared_model: the model after prepare_fx/prepare_qat_fx and calibration/training
    # convert_fx converts a calibrated/trained model to a quantized model for the
    # target hardware, this includes converting the model first to a reference
    # quantized model, and then lower the reference quantized model to a backend
    # Currently, the supported backends are fbgemm (onednn), qnnpack (xnnpack) and
    # they share the same set of quantized operators, so we are using the same
    # lowering procedure
    #
    # backend_config defines the corresponding reference quantized module for
    # the weighted modules in the model, e.g. nn.Linear
    # TODO: add backend_config after we split the backend_config for fbgemm and qnnpack
    # e.g. backend_config = get_default_backend_config("fbgemm")
    quantized_model = convert_fx(prepared_model)

z'quantization_api.quantize_fx.convert_fxF)r~   r   r€   rQ   rL   r‚   ©r   rp   rq   r…   )rh   r   r€   rQ   rL   r‚   s   &&&&&&r"   Ú
convert_fxrŠ   6  s:   € ôt 
‡H�H× Ñ Ð!JÔKÜØØØ3Ø'Ø'Ø%Ø3ôð r$   c                ó2  € V ^8„  d   QhR\         R\        \        \        \        3,          ,          R,          R\
        R\        \        \        \        3,          ,          R,          R\        \        \        \        3,          ,          R,          R\         /# )r   rh   r   Nr€   rQ   rL   r   r‡   )r!   s   "r"   r#   r#   |  sz   € ÷ /ñ /Üð/ä.´´c¼3°hµÕ?À$ÕFð/ô ð/ô $¤d¬3´¨8¥nÕ4°tÕ;ð	/ô
 "¤D¬¬c¨¥NÕ2°TÕ9ð/ô ñ/r$   c           	     ób   € \         P                  P                  R4       \        V RVVVVR7      # )a%  Convert a calibrated or trained model to a reference quantized model,
see https://github.com/pytorch/rfcs/blob/master/RFC-0019-Extending-PyTorch-Quantization-to-Custom-Backends.md for more details,
reference quantized model is a standard representation of a quantized model provided
by FX Graph Mode Quantization, it can be further lowered to run on the target
hardware, like accelerators

Args:
    * `graph_module` (GraphModule): A prepared and calibrated/trained model (GraphModule)

    * `convert_custom_config` (ConvertCustomConfig): custom configurations for convert function.
        See :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

    * `_remove_qconfig` (bool): Option to remove the qconfig attributes in the model after convert.

    * `qconfig_mapping` (QConfigMapping): config for specifying how to convert a model for quantization.
        See :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

     * `backend_config` (BackendConfig): A configuration for the backend which describes how
        operators should be quantized in the backend. See
        :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

Return:
    A reference quantized model (GraphModule)

Example::

    # prepared_model: the model after prepare_fx/prepare_qat_fx and calibration/training
    # TODO: add backend_config after we split the backend_config for fbgemm and qnnpack
    # e.g. backend_config = get_default_backend_config("fbgemm")
    reference_quantized_model = convert_to_reference_fx(prepared_model)

z4quantization_api.quantize_fx.convert_to_reference_fxT)r~   r   r€   rQ   rL   r‰   )rh   r   r€   rQ   rL   s   &&&&&r"   Úconvert_to_reference_fxr�   |  s7   € ôN 
‡H�H× Ñ Ð!WÔXÜØØØ3Ø'Ø'Ø%ôð r$   c                ó&  € V ^8„  d   QhR\         R\        \        \        \        3,          ,          R,          R\
        \        \        \        3,          ,          R,          R\        \        \        \        3,          ,          R,          R\         /# )r   rh   r   NrQ   rL   r   )r   r
   r   r    r   r   r   )r!   s   "r"   r#   r#   ®  sp   € ÷ 4ñ 4Üð4ä.´´c¼3°hµÕ?À$ÕFð4ô $¤d¬3´¨8¥nÕ4°tÕ;ð4ô "¤D¬¬c¨¥NÕ2°TÕ9ð	4ô
 ñ4r$   c           
     ód   € \         P                  P                  R4       \        V RVRVVRR7      # )a»  Convert a calibrated or trained model to a reference quantized model, with
decomposed representation for quantized Tensor
see https://github.com/pytorch/rfcs/blob/master/RFC-0019-Extending-PyTorch-Quantization-to-Custom-Backends.md for more details,
reference quantized model is a standard representation of a quantized model provided
by FX Graph Mode Quantization, it can be further lowered to run on the target
hardware, like accelerators

Note: this is not public API

Args:
    * `graph_module` (GraphModule): A prepared and calibrated/trained model (GraphModule)

    * `convert_custom_config` (ConvertCustomConfig): custom configurations for convert function.
        See :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

    * `_remove_qconfig` (bool): Option to remove the qconfig attributes in the model after convert.

    * `qconfig_mapping` (QConfigMapping): config for specifying how to convert a model for quantization.
        See :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

     * `backend_config` (BackendConfig): A configuration for the backend which describes how
        operators should be quantized in the backend. See
        :func:`~torch.ao.quantization.quantize_fx.convert_fx` for more details.

Return:
    A reference quantized model (GraphModule) with operators working with decomposed quantized Tensor

Example::

    # prepared_model: the model after prepare_fx/prepare_qat_fx and calibration/training
    # TODO: add backend_config after we split the backend_config for fbgemm and qnnpack
    # e.g. backend_config = get_default_backend_config("fbgemm")
    reference_quantized_model = _convert_to_reference_decomposed_fx(prepared_model)

z@quantization_api.quantize_fx._convert_to_reference_decomposed_fxTF)r~   r   r€   rQ   rL   r�   r‰   )rh   r   rQ   rL   s   &&&&r"   Ú#_convert_to_reference_decomposed_fxr�   ®  s>   € ôR 
‡H�H× Ñ ØJôô ØØØ3ØØ'Ø%Øôð r$   c          	      óŽ   € V ^8„  d   QhR\         R\        R\        \        \        \
        3,          ,          R,          R\         /# )r   rh   r~   r   Nr   )r   rM   r
   r   r    r   )r!   s   "r"   r#   r#   å  sB   € ÷ ñ Üðäðô /´´c¼3°hµÕ?À$ÕFðô ñ	r$   c                ó    € \        V VVRR7      # )a^  [Internal use only] Convert a model produced by :func:`~torch.ao.quantization.prepare_standalone_module_fx`
and convert it to a quantized model

Returns a quantized standalone module, whether input/output is quantized is
specified by prepare_custom_config, with
input_quantized_idxs, output_quantized_idxs, please
see docs for prepare_fx for details
T)rU   )r…   )rh   r~   r   s   &&&r"   Ú_convert_standalone_module_fxr“   å  s   € ô ØØØØ!ô	ð r$   )NN)NNNF)NNN)NFTNNFF)NTNNF)NTNN)FN)4r&   Útyping_extensionsr[   Útypingr   r   Útorch.fxr   Útorch.fx.graph_moduler   rL   r   r   Ú
fx.convertr	   Úfx.custom_configr
   r   r   Úfx.fuser   Úfx.graph_moduler   Ú
fx.preparer   Ú	fx.tracerr   r   r   Úfx.utilsr   r   rQ   r   Úutilsr   r,   r4   r;   rC   rO   rj   rm   rt   Ú
deprecatedry   r|   r…   rŠ   r�   r�   r“   © r$   r"   Ú<module>r¢      sõ   ðÛ Û Û Ý ã Ý  Ý @ç FÝ ß XÑ XÝ Ý 0Ý ß EÑ E÷õ ,Ý &õ	(õ
õ
õI÷C÷E÷P'÷T.ðb ×ÒÐ1Ó2öTó 3ðTðn ×ÒÐ1Ó2ömó 3ðm÷`-ð` ×ÒÐ1Ó2öBó 3ðB÷J/÷d4÷nñ r$   