Ë
    ÛÓ^j»  ã                   ó   — 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y)é    N)Ú	dataclass)ÚEnum)ÚPathLike)ÚAnyé   )Úloggingc                   ó   — e Zd ZdZdZdZdZy)ÚExportFormatz]Identifies the export backend. Stored in [`ExportConfigMixin`] for serialisation round-trips.Ú
executorchÚdynamoÚonnxN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
EXECUTORCHÚDYNAMOÚONNX© ó    úi/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/exporters/configs.pyr
   r
      s   „ Ùgà€JØ€FØ�Dr   r
   c                   óH   — e Zd ZU dZeed<   ed„ «       Zdee	e
f   fd„Zd„ Zy)Ú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                 ó@   — 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              #   óT   K  — | j                   j                  «       E d {  –—†  y 7 Œ­w)N)r$   Úitemsr%   s    r   Ú__iter__zExportConfigMixin.__iter__G   s   è ø€ Ø—=‘=×&Ñ&Ó(×(Ò(ús   ‚( &¡(N)r   r   r   r   r
   Ú__annotations__Úclassmethodr   ÚdictÚstrr   r'   r*   r   r   r   r   r   #   s:   … ñð  Óàñó ðð,˜˜c 3˜h™ó ,ó)r   r   c                   ó|   — 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<   y)	Ú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   sO   … ñð0 #/×"5Ñ"5€M�<Ó5Ø€GˆTÓà€FˆDÓØ,0€N�D˜˜c˜‘N TÑ)Ó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<   y)Ú
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   sz   … ñð< #/×"3Ñ"3€M�<Ó3à)-€K��x‘ $Ñ&Ó-Ø,0€N�D˜˜c˜‘N TÑ)Ó0Ø $€M�3˜‘:Ó$Ø€M�4ÓØ€HˆdÓØ€M�4ÓØ(-Ð Ô-r   r7   c                   óB   — e Zd ZU dZej
                  Zeed<   dZe	ed<   y)Ú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@   ˜   s#   … ñð #/×"9Ñ"9€M�<Ó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   