§
    ‚Štj»  ã                   ó4  — d dl 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
  e
j        e¦  «        Z G d„ d	e¦  «        Ze G d
„ d¦  «        ¦   «         Ze G d„ de¦  «        ¦   «         Ze G d„ de¦  «        ¦   «         Ze G d„ de¦  «        ¦   «         ZdS )é    N)Ú	dataclass)ÚEnum)ÚPathLike)ÚAnyé   )Úloggingc                   ó   — e Zd ZdZdZdZdZdS )ÚExportFormatz]Identifies the export backend. Stored in [`ExportConfigMixin`] for serialisation round-trips.Ú
executorchÚdynamoÚonnxN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
EXECUTORCHÚDYNAMOÚONNX© ó    ú\/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/exporters/configs.pyr
   r
      s#   € € € € € ØgÐgà€JØ€FØ€D€D€Dr   r
   c                   óV   — e Zd ZU dZeed<   ed„ ¦   «         Zdee	e
f         fd„Zd„ ZdS )ÚExportConfigMixina  
    Base class for all export configuration dataclasses.

    Provides `to_dict` / `from_dict` serialisation so configs can be saved and round-tripped
    without knowing the concrete subclass. The `export_format` field identifies the subclass
    during deserialisation.
    Úexport_formatc                 ó   —  | di |¤Ž}|S )aa  
        Instantiates a [`ExportConfigMixin`] from a Python dictionary of parameters.

        Args:
            config_dict (`dict[str, Any]`):
                Dictionary that will be used to instantiate the configuration object.

        Returns:
            [`ExportConfigMixin`]: The configuration object instantiated from those parameters.
        r   r   )ÚclsÚconfig_dictÚconfigs      r   Ú	from_dictzExportConfigMixin.from_dict/   s   € ð �Ð#Ð#�{Ð#Ð#ˆØˆr   Úreturnc                 ó4   — t          j        | j        ¦  «        S )z½
        Serializes this instance to a Python dictionary.

        Returns:
            `dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
        )ÚcopyÚdeepcopyÚ__dict__©Úselfs    r   Úto_dictzExportConfigMixin.to_dict>   s   € õ Œ}˜Tœ]Ñ+Ô+Ð+r   c              #   óH   K  — | j                              ¦   «         E d {V —† d S )N)r$   Úitemsr%   s    r   Ú__iter__zExportConfigMixin.__iter__G   s2   è è € Ø”=×&Ò&Ñ(Ô(Ð(Ð(Ð(Ð(Ð(Ð(Ð(Ð(Ð(r   N)r   r   r   r   r
   Ú__annotations__Úclassmethodr   ÚdictÚstrr   r'   r*   r   r   r   r   r   #   sy   € € € € € € ðð ð  ÐÐÑàðð ñ „[ðð,˜˜c 3˜hœð ,ð ,ð ,ð ,ð)ð )ð )ð )ð )r   r   c                   óz   — e Zd ZU dZej        Zeed<   dZe	ed<   dZ
e	ed<   dZeeef         dz  ed<   dZe	ed<   dS )	ÚDynamoConfigao  
    Configuration class for exporting models via `torch.export`.

    Args:
        dynamic (`bool`, *optional*, defaults to `False`):
            Whether to export with dynamic (symbolic) shapes. When `True` and
            `dynamic_shapes` is not set, all tensor dimensions are set to
            `Dim.AUTO` automatically.
        strict (`bool`, *optional*, defaults to `False`):
            Whether to enable strict mode in `torch.export`. Runs the full
            symbolic trace and catches more errors, but is slower and more
            likely to fail on complex models.
        dynamic_shapes (`dict[str, Any]`, *optional*):
            Explicit per-input dynamic shape specifications passed to
            `torch.export`. Takes precedence over `dynamic`.
        prefer_deferred_runtime_asserts_over_guards (`bool`, *optional*, defaults to `False`):
            When `True`, data-dependent shape guards are emitted as runtime asserts in the exported
            graph instead of failing the export at trace time when a guard wouldn't hold across the
            full symbolic shape range. Most transformer LLMs need this set to `True` when using
            fine-grained ``Dim(min=, max=)`` bounds. Not needed with ``dynamic=True`` / ``Dim.AUTO``,
            where ``torch.export`` infers shape relations instead of verifying them against the
            user-stated bounds.
    r   FÚdynamicÚstrictNÚdynamic_shapesÚ+prefer_deferred_runtime_asserts_over_guards)r   r   r   r   r
   r   r   r+   r1   Úboolr2   r3   r-   r.   r   r4   r   r   r   r0   r0   K   s   € € € € € € ðð ð0 #/Ô"5€M�<Ð5Ð5Ñ5Ø€GˆTÐÐÑà€FˆDÐÐÑØ,0€N�D˜˜c˜”N TÑ)Ð0Ð0Ñ0Ø8=Ð/°Ð=Ð=Ñ=Ð=Ð=r   r0   c                   ó¶   — e Zd ZU dZej        Zeed<   dZe	e
z  dz  ed<   dZee	ef         dz  ed<   dZedz  ed<   dZeed<   dZeed	<   dZeed
<   dZeed<   dS )Ú
OnnxConfigu>  
    Configuration class for exporting models to ONNX via `torch.onnx.export`.

    Inherits all fields from [`DynamoConfig`] (`dynamic`, `strict`,
    `dynamic_shapes`, `prefer_deferred_runtime_asserts_over_guards`).

    Args:
        output_path (`str` or `PathLike`, *optional*):
            Output path for the `.onnx` file. When `None` (default) the
            exported model is kept in memory as an `ONNXProgram` and not
            written to disk.
        opset_version (`int`, *optional*):
            ONNX opset version to target. Defaults to the latest opset
            supported by the installed `onnxscript` version.
        external_data (`bool`, *optional*, defaults to `True`):
            Store large weight tensors in a separate `.onnx_data` sidecar
            file instead of embedding them in the protobuf. Required for
            models whose weights exceed the 2 GB protobuf limit.
        optimize (`bool`, *optional*, defaults to `True`):
            Run `onnxscript` optimisation passes (constant folding, dead-code
            elimination, â€¦) on the exported graph. Disable for models that
            hit upstream `onnxscript` optimiser bugs.
        export_params (`bool`, *optional*, defaults to `True`):
            Embed model weights in the ONNX graph. Set to `False` to export
            a weight-free graph (weights must be supplied at runtime).
        keep_initializers_as_inputs (`bool`, *optional*, defaults to `False`):
            Expose weight initializers as explicit graph inputs. Required by
            some older ONNX runtimes (opset < 9).
    r   NÚoutput_pathr3   Úopset_versionTÚexternal_dataÚoptimizeÚexport_paramsFÚkeep_initializers_as_inputs)r   r   r   r   r
   r   r   r+   r8   r.   r   r3   r-   r   r9   Úintr:   r5   r;   r<   r=   r   r   r   r7   r7   m   s¼   € € € € € € ðð ð< #/Ô"3€M�<Ð3Ð3Ñ3à)-€K��x‘ $Ñ&Ð-Ð-Ñ-Ø,0€N�D˜˜c˜”N TÑ)Ð0Ð0Ñ0Ø $€M�3˜‘:Ð$Ð$Ñ$Ø€M�4ÐÐÑØ€HˆdÐÐÑØ€M�4ÐÐÑØ(-Ð Ð-Ð-Ñ-Ð-Ð-r   r7   c                   ó:   — e Zd ZU dZej        Zeed<   dZe	ed<   dS )ÚExecutorchConfiguþ  
    Configuration class for exporting models to ExecuTorch format.

    Inherits all fields from [`DynamoConfig`] (`dynamic`, `strict`,
    `dynamic_shapes`, `prefer_deferred_runtime_asserts_over_guards`).

    Args:
        backend (`str`, *optional*, defaults to `"xnnpack"`):
            Target ExecuTorch backend. Supported values:

            - `"xnnpack"` â€” CPU inference via the XNNPACK library (default; runs anywhere).
            - `"cuda"` â€” GPU inference via the ExecuTorch CUDA backend.
    r   ÚxnnpackÚbackendN)
r   r   r   r   r
   r   r   r+   rB   r.   r   r   r   r@   r@   ˜   sA   € € € € € € ðð ð #/Ô"9€M�<Ð9Ð9Ñ9à€GˆSÐÐÑÐÐr   r@   )r"   Údataclassesr   Úenumr   Úosr   Útypingr   Úutilsr   Ú
get_loggerr   Úloggerr
   r   r0   r7   r@   r   r   r   ú<module>rJ      sŒ  ðð €€€Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ð 
ˆÔ	˜HÑ	%Ô	%€ðð ð ð ð �4ñ ô ð ð ð$)ð $)ð $)ð $)ð $)ñ $)ô $)ñ „ð$)ðN ð>ð >ð >ð >ð >Ð$ñ >ô >ñ „ð>ðB ð'.ð '.ð '.ð '.ð '.�ñ '.ô '.ñ „ð'.ðT ðð ð ð ð �|ñ ô ñ „ðð ð r   