+
    œ°³j  ã                  óþ   € R t ^ RIHt ^RIHt ^RIHt ^RIHtH	t	 ^RI
HtHt ^RIHtHt ^RIHtHt R]R	]R
]/tR]R	]R
]/t]P*                  ! ]4      t ! R R4      t ! R R4      tR R ltR R ltR R ltR# )z0Auto exporter factory for HuggingFace exporters.)Úannotations)Úlogging)Ú
HfExporter)ÚExportConfigMixinÚExportFormat)ÚDynamoConfigÚDynamoExporter)ÚExecutorchConfigÚExecutorchExporter)Ú
OnnxConfigÚOnnxExporterÚ
executorchÚdynamoÚonnxc                  ó0   € ] tR t^*tRt]R R l4       tRtR# )ÚAutoExportConfigzš
The Auto-HF export config class that takes care of automatically dispatching to the correct
export config given an export config stored in a dictionary.
c               ó   € V ^8„  d   QhRR/# )é   Úexport_config_dictÚdict© )Úformats   "Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/exporters/auto.pyÚ__annotate__ÚAutoExportConfig.__annotate__1   s   € ÷ 8ñ 8¨4ñ 8ó    c           	     	ó6  € VP                  R 4      pVf   \        R4      h\        V\        4      '       d   VP                  pMTpV\
        9  d-   \        RV R\        \
        P                  4       4       24      h\
        V,          pVP                  V4      # )Úexport_formatzHexport_config_dict must contain key 'export_format' set to exporter namezUnknown exporter type, got z - supported exporters are: )	ÚgetÚ
ValueErrorÚ
isinstancer   ÚvalueÚAUTO_EXPORT_CONFIG_MAPPINGÚlistÚkeysÚ	from_dict)Úclsr   r   ÚnameÚ
target_clss   &&   r   r%   ÚAutoExportConfig.from_dict0   s™   € à*×.Ñ.¨Ó?ˆàÒ ÜÐgÓhÐhô �m¤\×2Ò2Ø ×&Ñ&‰Dà ˆDàÔ1Ô1ÜØ-¨d¨VÐ3OÔPTÔUo×UtÑUtÓUvÓPwÐOxÐyóð ô 0°Õ5ˆ
Ø×#Ñ#Ð$6Ó7Ð7r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úclassmethodr%   Ú__static_attributes__r   r   r   r   r   *   s   † ñð
 ô8ó ô8r   r   c                  ó\   € ] tR t^FtRt]R R l4       t]R R l4       t]R R l4       t	Rt
R	# )
ÚAutoHfExporterz‚
The Auto-HF expoerter class that takes care of automatically instantiating to the correct
`HfExporter` given the `ExportConfig`.
c               ó    € V ^8„  d   QhRRRR/# )r   Úexport_configzExportConfigMixin | dictÚreturnr   r   )r   s   "r   r   ÚAutoHfExporter.__annotate__M   s   € ÷ 5ñ 5Ð(@ð 5Èzñ 5r   c                	ó@  € \        V\        4      '       d   VP                  4       MTpV P                  V4      '       g!   \	        R V: R\        \        4       R24      hVR,          p\        V\        4      '       d   VP                  MTp\        V,          ! R/ VB # )zUnsupported export config: z. Registered exporters: Ú.r   r   )	r    r   Úto_dictÚsupports_export_formatr   ÚsortedÚAUTO_EXPORTER_MAPPINGr   r!   )r&   r4   Úkwargsr   r   r'   s   &&,   r   Úfrom_configÚAutoHfExporter.from_configL   sŸ   € ô 9CÀ=ÔRc×8dÒ8d˜]×2Ñ2Ô4ÐjwÐØ×)Ñ)Ð*<×=Ò=ÜØ-Ð.@Ñ-Cð D)Ü)/Ô0EÓ)FÐ(GÀqðJóð ð
 +¨?Õ;ˆÜ&0°Ä×&MÒ&Mˆ}×"Ò"ÐS`ˆÜ$ TÖ*Ñ4¨VÑ4Ð4r   c               ó   € V ^8„  d   QhRR/# )r   r5   zHfExporter | Noner   )r   s   "r   r   r6   [   s   € ÷ 
ñ 
ÐIZñ 
r   c                ó   € \        R4      h)u«  
Load an exporter instance from a pretrained model/checkpoint that ships an export config.

**Not implemented yet** â€” placeholder for a first-class "export recipe" workflow.

The idea: model owners publish an ``export_config.json`` (or an ``export_config`` field in
``config.json``) alongside their weights on the Hub. That file captures the settings the
owner has already validated for their architecture â€” the target format (``dynamo`` /
``onnx`` / ``executorch``), exact dynamic-shape specs (e.g. ``text_ids`` dynamic to 4096,
image tiles fixed at 448, ``batch=1`` for edge deployment), ``strict`` flag, ONNX opset,
prefill vs. decode layout, ExecuTorch backend choice, and any other knob that today lives
as tribal knowledge in a README or a private notebook.

Consumers then get the owner-validated export in one call::

    exporter = AutoHfExporter.from_pretrained("org/model-name")
    program = exporter.export(model, inputs)

Composes with the [`register_export_input_preparer`] registry: the owner supplies the
shape spec via ``export_config.json``, transformers supplies the data-dependent
precomputations (``cu_seqlens``, vision position ids, window indices, â€¦) for that
architecture. Together they cover the two hard parts of exporting new models â€” knowing
the right shape contract and preparing the right inputs â€” so downstream users don't
re-derive either from scratch (and don't break in production when they get it wrong).
z‡AutoHfExporter.from_pretrained is not implemented yet. Load/export configs explicitly and call AutoHfExporter.from_config(...) instead.)ÚNotImplementedError)r&   Úpretrained_model_name_or_pathr=   s   &&,r   Úfrom_pretrainedÚAutoHfExporter.from_pretrainedZ   s   € ô6 "ð_ó
ð 	
r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r5   Úboolr   )r   s   "r   r   r6   {   s   € ÷ "ñ "°4ð "¸Dñ "r   c                ó>  € V P                  R4      pVf)   \        P                  R\        \        4       R24       R# \        V\        4      '       d   VP                  MTpV\        9   pV\        9   pV'       gR   V'       gJ   \        P                  RV: R\        \        \        4      \        \        4      ,          4       R24       R# V'       g!   \        P                  RV: RV: R	24       R# V'       g!   \        P                  RV: R
V: R	24       R# R# )zðReturn True if the provided dict describes an ``export_format`` that has both a
registered config class and a registered exporter class. Warns with an actionable message
when the format is missing entirely, unknown, or only half-registered.r   uB   No 'export_format' key in export config â€” supported values are: z. Skipping.FzUnknown export format u    â€” supported values are: zExport format z[ has a registered exporter but no config class. Register one via ``@register_export_config(z)``. Skipping.zV has a registered config class but no exporter. Register one via ``@register_exporter(T)
r   ÚloggerÚwarningr;   r<   r    r   r!   r"   Úset)r   Ú
export_fmtr'   Ú
has_configÚhas_exporters   &    r   r:   Ú%AutoHfExporter.supports_export_formatz   s  € ð
 (×+Ñ+¨OÓ<ˆ
ØÒÜ�N‰NØTÜÔ/Ó0Ð1°ð>ôñ ä#-¨j¼,×#GÒ#Gˆz×ÒÈZˆØÔ7Ñ7ˆ
ØÔ4Ñ4ˆç§,Ü�N‰NØ(¨©Ð6QÜœ#Ô3Ó4´sÔ;UÓ7VÕVÓWÐXÐXcðeôñ ßÜ�N‰NØ  ¡ð )>Ø>B¹XÀ^ðUôñ ßÜ�N‰NØ  ¡ð )9Ø9=¹ÀðPôñ Ùr   r   N)r*   r+   r,   r-   r.   r/   r>   rD   Ústaticmethodr:   r0   r   r   r   r2   r2   F   sC   † ñð
 ô5ó ð5ð ô
ó ð
ð> ô"ó ô"r   r2   c               ó   € V ^8„  d   QhRR/# ©r   r'   Ústrr   )r   s   "r   r   r       s   € ÷ 	 ñ 	 ˜Cñ 	 r   c                ó   a € V 3R  lpV# )c                ó¤   <€ S\         9   d   \        P                  R S R24       \        V \        4      '       g   \        R4      hV \         S&   V # )z
Exporter 'ú0' is already registered and will be overwritten.zExporter must extend HfExporter)r<   rI   rJ   Ú
issubclassr   Ú	TypeError©r&   r'   s   &€r   Úregister_exporter_fnÚ/register_exporter.<locals>.register_exporter_fn¡   sK   ø€ ØÔ(Ô(Ü�N‰N˜Z¨ vÐ-]Ð^Ô_Ü˜#œz×*Ò*ÜÐ=Ó>Ð>Ø&)Ô˜dÑ#Øˆ
r   r   )r'   rZ   s   f r   Úregister_exporterr\       s   ø€ õð  Ðr   c               ó   € V ^8„  d   QhRR/# rR   r   )r   s   "r   r   r   ¬   s   € ÷ 	%ñ 	% ñ 	%r   c                ó   a € V 3R  lpV# )c                ó¤   <€ S\         9   d   \        P                  R S R24       \        V \        4      '       g   \        R4      hV \         S&   V # )zExport config 'rV   z+Export config must extend ExportConfigMixin)r"   rI   rJ   rW   r   rX   rY   s   &€r   Úregister_export_config_fnÚ9register_export_config.<locals>.register_export_config_fn­   sL   ø€ ØÔ-Ô-Ü�N‰N˜_¨T¨FÐ2bÐcÔdÜ˜#Ô0×1Ò1ÜÐIÓJÐJØ+.Ô" 4Ñ(Øˆ
r   r   )r'   r`   s   f r   Úregister_export_configrb   ¬   s   ø€ õð %Ð$r   c               ó   € V ^8„  d   QhRR/# )r   r5   r   r   )r   s   "r   r   r   ¸   s   € ÷ 5ñ 5 jñ 5r   c                ó,   € \         P                  V 4      # )N)r2   r>   )r4   s   &r   Úget_hf_exporterre   ¸   s   € Ü×%Ñ% mÓ4Ð4r   N)r.   Ú
__future__r   Úutilsr   Úbaser   Úconfigsr   r   Úexporter_dynamor   r   Úexporter_executorchr	   r
   Úexporter_onnxr   r   r<   r"   Ú
get_loggerr*   rI   r   r2   r\   rb   re   r   r   r   Ú<module>rn      s‹   ðñ 7å "å Ý ß 4ß 9ß Eß 3ð Ð$ØˆnØ
ˆLðÐ ð Ð"ØˆlØ
ˆJðÐ ð 
×	Ò	˜HÓ	%€÷8ñ 8÷8Wñ Wõt	 õ	%÷5r   