ó
    oM‡j "  ã                  óÊ  • S SK Jr  S SKrS SKrS SKJr  S SKrS SKJ	r	  S SK
Jr  SSKJrJrJrJr  \" 5       (       a  S SKr\R&                  " \5      r\R,                  \R.                  \R0                  \R2                  \R4                  \R6                  \R8                  \R:                  \R<                  \R>                  \R@                  \RB                  S.r" " S	 S
5      r#g)é    )ÚannotationsN)ÚPath)Úhf_hub_download)Úvalidate_hf_hub_argsé   )ÚONNX_EXTERNAL_WEIGHTS_NAMEÚONNX_WEIGHTS_NAMEÚis_onnx_availableÚlogging)ztensor(bool)ztensor(int8)ztensor(uint8)ztensor(int16)ztensor(uint16)ztensor(int32)ztensor(uint32)ztensor(int64)ztensor(uint64)ztensor(float16)ztensor(float)ztensor(double)c                  óÜ   • \ rS rSrSS jrS r\SSS jj5       rSSS jjr  SS jr	\
\       S               SS jj5       5       r\
\   S       SS	 jj5       5       rS
rg)ÚOnnxRuntimeModelé4   Nc                óž   • [         R                  S5        Xl        UR                  SS 5      U l        UR                  S[
        5      U l        g )NzL`diffusers.OnnxRuntimeModel` is experimental and might change in the future.Úmodel_save_dirÚlatest_model_name)ÚloggerÚinfoÚmodelÚgetr   r	   r   )Úselfr   Úkwargss      Ú¬C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\diffusers/pipelines/onnx_utils.pyÚ__init__ÚOnnxRuntimeModel.__init__5   s=   € Ü�‰ÐbÔcØŒ
Ø$Ÿj™jÐ)9¸4Ó@ˆÔØ!'§¡Ð,?ÔARÓ!SˆÕó    c                ó¸   • UR                  5        VVs0 s H  u  p#U[        R                  " U5      _M     nnnU R                  R	                  S U5      $ s  snnf ©N)ÚitemsÚnpÚarrayr   Úrun)r   r   ÚkÚvÚinputss        r   Ú__call__ÚOnnxRuntimeModel.__call__;   sD   € Ø-3¯\©\¬^Ô<ª^¡T Q�!”R—X’X˜a“[’.©^ˆÑ<Ø�z‰z�~‰~˜d FÓ+Ð+ùó =s   ”#Ac                óž   • Uc  [         R                  S5        SnUc  / nO[        U[        5      (       d  U/n[        R
                  " X/X#S9$ )a=  
Loads an ONNX Inference session with an ExecutionProvider. Default provider is `CPUExecutionProvider`

Arguments:
    path (`str` or `Path`):
        Directory from which to load
    provider(`str`, *optional*):
        Onnxruntime execution provider to use for loading the model, defaults to `CPUExecutionProvider`
z=No onnxruntime provider specified, using CPUExecutionProviderÚCPUExecutionProvider)Ú	providersÚsess_optionsÚprovider_options)r   r   Ú
isinstanceÚlistÚortÚInferenceSession)ÚpathÚproviderr*   r+   s       r   Ú
load_modelÚOnnxRuntimeModel.load_model?   sY   € ð ÑÜ�K‰KÐWÔXØ-ˆHàÑ#Ø!ÑÜÐ,¬d×3Ñ3Ø 0Ð1Ðä×#Ò#Ø˜J°\ñ
ð 	
r   c                ó  • Ub  UO[         nU R                  R                  U R                  5      n[	        U5      R                  U5      n [
        R                  " XV5        U R                  R                  [        5      nUR                  5       (       a6  [	        U5      R                  [        5      n [
        R                  " XV5        gg! [
        R                   a     N�f = f! [
        R                   a     gf = f)aï  
Save a model and its configuration file to a directory, so that it can be re-loaded using the
[`~optimum.onnxruntime.modeling_ort.ORTModel.from_pretrained`] class method. It will always save the
latest_model_name.

Arguments:
    save_directory (`str` or `Path`):
        Directory where to save the model file.
    file_name(`str`, *optional*):
        Overwrites the default model file name from `"model.onnx"` to `file_name`. This allows you to save the
        model with a different name.
N)
r	   r   Újoinpathr   r   ÚshutilÚcopyfileÚSameFileErrorr   Úexists)r   Úsave_directoryÚ	file_namer   Úmodel_file_nameÚsrc_pathÚdst_paths          r   Ú_save_pretrainedÚ!OnnxRuntimeModel._save_pretrainedW   sØ   € ð (1Ñ'<™)ÔBSˆà×&Ñ&×/Ñ/°×0FÑ0FÓGˆÜ˜Ó'×0Ñ0°ÓAˆð	Ü�OŠO˜HÔ/ð
 ×&Ñ&×/Ñ/Ô0JÓKˆØ�?‰?×ÑÜ˜NÓ+×4Ñ4Ô5OÓPˆHðÜ—’ Õ3ð øô ×#Ñ#ó 	Ùð	ûô ×'Ñ'ó Ùðús$   ÁC Â5C' ÃC$Ã#C$Ã'C>Ã=C>c                óÐ   • [         R                  R                  U5      (       a  [        R	                  SU S35        g[         R
                  " USS9  U R                  " U40 UD6  g)zô
Save a model to a directory, so that it can be re-loaded using the [`~OnnxModel.from_pretrained`] class
method.:

Arguments:
    save_directory (`str` or `os.PathLike`):
        Directory to which to save. Will be created if it doesn't exist.
zProvided path (z#) should be a directory, not a fileNT)Úexist_ok)Úosr0   Úisfiler   ÚerrorÚmakedirsr?   )r   r:   r   s      r   Úsave_pretrainedÚ OnnxRuntimeModel.save_pretrainedv   sT   € ô �7‰7�>‰>˜.×)Ñ)Ü�L‰L˜?¨>Ð*:Ð:]Ð^Ô_Øä
�Š�N¨TÒ2ð 	×Ò˜nÑ7°Ó7r   c	           	     óÐ  • Ub  UO[         n
[        R                  R                  U5      (       aK  [        R                  [        X5      R                  5       UUU	R                  S5      S9n[        U5      U	S'   Oc[        UU
UUUUS9n[        U5      R                  U	S'   [        U5      R                  U	S'   [        R                  UUUU	R                  S5      S9nU " SSU0U	D6$ )a‹  
Load a model from a directory or the HF Hub.

Arguments:
    model_id (`str` or `Path`):
        Directory from which to load
    token (`str` or `bool`):
        Is needed to load models from a private or gated repository
    revision (`str`):
        Revision is the specific model version to use. It can be a branch name, a tag name, or a commit id
    cache_dir (`str | Path`, *optional*):
        Path to a directory in which a downloaded pretrained model configuration should be cached if the
        standard cache should not be used.
    force_download (`bool`, *optional*, defaults to `False`):
        Whether or not to force the (re-)download of the model weights and configuration files, overriding the
        cached versions if they exist.
    file_name(`str`):
        Overwrites the default model file name from `"model.onnx"` to `file_name`. This allows you to load
        different model files from the same repository or directory.
    provider(`str`):
        The ONNX runtime provider, e.g. `CPUExecutionProvider` or `CUDAExecutionProvider`.
    kwargs (`Dict`, *optional*):
        kwargs will be passed to the model during initialization
r+   )r1   r*   r+   r   )Úrepo_idÚfilenameÚtokenÚrevisionÚ	cache_dirÚforce_downloadr   r   © )r	   rC   r0   Úisdirr   r2   r   Úas_posixÚpopr   ÚparentÚname)ÚclsÚmodel_idrL   rM   rO   rN   r;   r1   r*   r   r<   r   Úmodel_cache_paths                r   Ú_from_pretrainedÚ!OnnxRuntimeModel._from_pretrainedŒ   sþ   € ðL (1Ñ'<™)ÔBSˆä�7‰7�=‰=˜×"Ñ"Ü$×/Ñ/Ü�XÓ/×8Ñ8Ó:Ø!Ø)Ø!'§¡Ð,>Ó!?ð	 0ð ˆEô (,¨H£~ˆFÐ#Ò$ô  /Ø Ø(ØØ!Ø#Ø-ñ Ðô (,Ð,<Ó'=×'DÑ'DˆFÐ#Ñ$Ü*.Ð/?Ó*@×*EÑ*EˆFÐ&Ñ'Ü$×/Ñ/Ø Ø!Ø)Ø!'§¡Ð,>Ó!?ð	 0ð ˆEñ Ñ)˜Ð) &Ñ)Ð)r   c           	     óª   • S n[        [        U5      R                  S5      5      S:X  a  UR                  S5      u  pU R                  " SUUUUUS.UD6$ )NÚ@r   )rW   rM   rN   rO   rL   rP   )ÚlenÚstrÚsplitrY   )rV   rW   rO   rL   rN   Úmodel_kwargsrM   s          r   Úfrom_pretrainedÚ OnnxRuntimeModel.from_pretrainedÑ   sg   € ð ˆÜŒs�8‹}×"Ñ" 3Ó'Ó(¨AÓ-Ø!)§¡°Ó!4ÑˆHà×#Ò#ð 
ØØØØ)Øñ
ð ñ
ð 	
r   )r   r   r   r   )NNN)r0   ú
str | Path)r:   rc   r;   ú
str | None)r:   zstr | os.PathLike)NNFNNNN)rW   rc   rL   zbool | str | None | NonerM   zstr | None | NonerO   ÚboolrN   rd   r;   rd   r1   rd   r*   z'ort.SessionOptions' | None)TNN)rW   rc   rO   re   rL   rd   rN   rd   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r%   Ústaticmethodr2   r?   rG   Úclassmethodr   rY   ra   Ú__static_attributes__rP   r   r   r   r   4   s  † ôTò,ð õ
ó ð
ö.ð>8à)ô8ð, Øð +/Ø&*Ø$Ø $Ø $Ø#Ø48ðA*àðA*ð (ðA*ð $ð	A*ð
 ðA*ð ðA*ð ðA*ð ðA*ð 2ôA*ó ó ðA*ðF Øð  $Ø Ø $ð
àð
ð ð
ð ð	
ð
 ô
ó ó ó
r   r   )$Ú
__future__r   rC   r6   Úpathlibr   Únumpyr   Úhuggingface_hubr   Úhuggingface_hub.utilsr   Úutilsr   r	   r
   r   Úonnxruntimer.   Ú
get_loggerrf   r   Úbool_Úint8Úuint8Úint16Úuint16Úint32Úuint32Úint64Úuint64Úfloat16Úfloat32Úfloat64ÚORT_TO_NP_TYPEr   rP   r   r   Ú<module>r‚      s«   ðõ" #ã 	Û Ý ã Ý +Ý 6ç ]Ó ]ñ ×ÑÛð 
×	Ò	˜HÓ	%€ð —H‘HØ—G‘GØ—X‘XØ—X‘XØ—i‘iØ—X‘XØ—i‘iØ—X‘XØ—i‘iØ—z‘zØ—Z‘ZØ—j‘jñ€÷ r
ò r
r   