
    h;-                    r   S SK Jr  / SQrS SKrS SKrS SKJrJrJr  S SKJ	r	  S SK
Jr  S SKJrJrJr  S SKJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+  S S	K,J-r-J.r.  S S
K/J0r0J1r1J2r2  S SK3J4r5  S SKJ6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrB  \\S   \C4   rDSrESS jrFSS jrGSS jrH S      S!S jjrI  S"       S#S jjrJ S      S$S jjrK\E4     S%S jjrL\E4     S&S jjrM S SSSSSS.                 S'S jjjrN S        S(S jjrO\JrP\LrQ\NrRg))    )annotations)7ONNX_ML
IR_VERSIONIR_VERSION_2017_10_10IR_VERSION_2017_10_30IR_VERSION_2017_11_3IR_VERSION_2019_1_22IR_VERSION_2019_3_18IR_VERSION_2019_9_19IR_VERSION_2020_5_8IR_VERSION_2021_7_30EXPERIMENTALSTABLEcheckercomposedefs	gen_protohelperhubmappingnumpy_helperparserprintershape_inferenceutilsversion_converterAttributeProtoFunctionProto
GraphProtoMapProto
ModelProto	NodeProtoOperatorProtoOperatorSetIdProtoOperatorSetProtoOperatorStatusOptionalProtoSequenceProtoSparseTensorProtoStringStringEntryProtoTensorAnnotationTensorProtoTensorShapeProtoTrainingInfoProto	TypeProtoValueInfoProtoVersionconvert_model_to_external_dataload_external_data_for_modelload_model_from_string
load_modelload_tensor_from_stringload_tensor
save_modelsave_tensorwrite_external_data_tensorsN)IOLiteralUnion)serialization)r   )r3   r:   r2   )r   r   r   r   r   r   r   r   r	   r
   r   r   r   r!   r"   r$   r&   r   r)   r*   r+   r,   r-   r.   r/   r0   r1   )r#   r%   )r    r'   r(   )version)r   r   r   r   r   r   r   r   r   r   r   r   r   )protobuf	textprotor@   c                   [        U S5      (       al  [        [        R                  " [        [
           U 5      R                  5      (       a2  [        R                  " [        [
           U 5      R                  5       nU$ [        R                  " [        [        [        R                  4   U 5      n [        U S5       nUR                  5       nS S S 5        U$ ! , (       d  f       W$ = f)Nreadrb)hasattrcallabletypingcastr;   bytesrC   r=   strosPathLikeopen)fcontentreadables      G/var/www/fran/franai/venv/lib/python3.13/site-packages/onnx/__init__.py_load_bytesrR      s    q&hv{{2e9a'@'E'EFF++bi+002
 N KKc2;;./3!T]hmmoG N ]Ns   <C
C&c                   [        US5      (       al  [        [        R                  " [        [
           U5      R                  5      (       a2  [        R                  " [        [
           U5      R                  U 5        g [        R                  " [        [        [        R                  4   U5      n[        US5       nUR                  U 5        S S S 5        g ! , (       d  f       g = f)Nwritewb)rE   rF   rG   rH   r;   rI   rT   r=   rJ   rK   rL   rM   )rO   rN   writables      rQ   _save_bytesrW      s    q'xBuIq(A(G(GHHBuIq!''0KKc2;;./3!T]hNN7# ]]s   <C
C%c                
   [        U [        [        R                  45      (       a  [        R                  R                  U 5      $ [        U S5      (       a.  U c   e[        R                  R                  U R                  5      $ g )Nname)
isinstancerJ   rK   rL   pathabspathrE   rY   )rN   s    rQ   _get_file_pathr]      s\    !c2;;'((wwq!!q&}}wwqvv&&    c                H   U b  [         R                  R                  U 5      $ [        U5      =nb@  [        R
                  R                  U5      u  p4[         R                  R                  U5      n U =(       d    [        n U c   e[         R                  R                  U 5      $ )zQGet the serializer for the given path and format from the serialization registry.)	r>   registrygetr]   rK   r[   splitextget_format_from_file_extension_DEFAULT_FORMAT)fmtrN   	file_path_exts        rQ   _get_serializerri      s    
 %%))#..#A&&	3!!),$$CCCH 
 C??!!%%c**r^   Tc                    [        X5      R                  [        U 5      [        5       5      nU(       a<  [	        U 5      nU(       a*  [
        R                  R                  U5      n[        X55        U$ )a  Loads a serialized ModelProto into memory.

Args:
    f: can be a file-like object (has "read" function) or a string/PathLike containing a file name
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.
    load_external_data: Whether to load the external data.
        Set to True if the data is under the same directory of the model.
        If not, users need to call :func:`load_external_data_for_model`
        with directory to load external data from.

Returns:
    Loaded in-memory ModelProto.
)	ri   deserialize_protorR   r!   r]   rK   r[   dirnamer3   )rN   formatload_external_datamodelmodel_filepathbase_dirs         rQ   r5   r5      sP    * F&88QVE'*ww~6H(9Lr^   c                Z    [        X5      R                  [        U 5      [        5       5      $ )a  Loads a serialized TensorProto into memory.

Args:
    f: can be a file-like object (has "read" function) or a string/PathLike containing a file name
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.

Returns:
    Loaded in-memory TensorProto.
)ri   rk   rR   r,   )rN   rm   s     rQ   r7   r7      s"      6%77AVVr^   c                H    [        U5      R                  U [        5       5      $ )a  Loads a binary string (bytes) that contains serialized ModelProto.

Args:
    s: a string, which contains serialized ModelProto
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.

Returns:
    Loaded in-memory ModelProto.
)ri   rk   r!   srm   s     rQ   r4   r4      s      6"44Q
EEr^   c                H    [        U5      R                  U [        5       5      $ )a  Loads a binary string (bytes) that contains serialized TensorProto.

Args:
    s: a string, which contains serialized TensorProto
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.

Returns:
    Loaded in-memory TensorProto.
)ri   rk   r,   rt   s     rQ   r6   r6     s      6"44QFFr^   Fi   )save_as_external_dataall_tensors_to_one_filelocationsize_thresholdconvert_attributec               ^   [        U [        5      (       a'  [        [        5      R	                  U [        5       5      n U(       a  [        XXVU5        [        U5      nUb*  [        R                  R                  U5      n	[        X	5      n [        X(5      R                  U 5      n
[        X5        g)a"  
Saves the ModelProto to the specified path and optionally, serialize tensors with raw data as external data before saving.

Args:
    proto: should be a in-memory ModelProto
    f: can be a file-like object (has "write" function) or a string containing
    a file name or a pathlike object
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.
    save_as_external_data: If true, save tensors to external file(s).
    all_tensors_to_one_file: Effective only if save_as_external_data is True.
        If true, save all tensors to one external file specified by location.
        If false, save each tensor to a file named with the tensor name.
    location: Effective only if save_as_external_data is true.
        Specify the external file that all tensors to save to.
        Path is relative to the model path.
        If not specified, will use the model name.
    size_threshold: Effective only if save_as_external_data is True.
        Threshold for size of data. Only when tensor's data is >= the size_threshold it will be converted
        to external data. To convert every tensor with raw data to external data set size_threshold=0.
    convert_attribute: Effective only if save_as_external_data is True.
        If true, convert all tensors to external data
        If false, convert only non-attribute tensors to external data
N)rZ   rI   ri   rd   rk   r!   r2   r]   rK   r[   rl   r:   serialize_protorW   )protorN   rm   rw   rx   ry   rz   r{   rp   basepath
serializeds              rQ   r8   r8     s    J %0BB5*,W&HFW	
 $A&N!77??>2+E< 8HHOJ
r^   c                N    [        X!5      R                  U 5      n[        X15        g)a  
Saves the TensorProto to the specified path.

Args:
    proto: should be a in-memory TensorProto
    f: can be a file-like object (has "write" function) or a string
    containing a file name or a pathlike object.
    format: The serialization format. When it is not specified, it is inferred
        from the file extension when ``f`` is a path. If not specified _and_
        ``f`` is not a path, 'protobuf' is used. The encoding is assumed to
        be "utf-8" when the format is a text format.
N)ri   r}   rW   )r~   rN   rm   r   s       rQ   r9   r9   J  s!    " !+;;EBJ
r^   )rN   IO[bytes] | str | os.PathLikereturnrI   )rO   rI   rN   r   r   None)rN   z$IO[bytes] | str | os.PathLike | Noner   
str | None)N)re   _SupportedFormat | NonerN   z$str | os.PathLike | IO[bytes] | Noner   zserialization.ProtoSerializer)NT)rN   r   rm   r   rn   boolr   r!   )rN   r   rm   r   r   r,   )ru   zbytes | strrm   _SupportedFormatr   r!   )ru   rI   rm   r   r   r,   )r~   zModelProto | bytesrN   r   rm   r   rw   r   rx   r   ry   r   rz   intr{   r   r   r   )r~   r,   rN   r   rm   r   r   r   )S
__future__r   __all__rK   rG   r;   r<   r=   onnxr>   onnx.onnx_cpp2py_exportr   onnx.external_data_helperr3   r:   r2   onnx.onnx_pbr   r   r   r   r   r   r   r   r	   r
   r   r   r   r!   r"   r$   r&   r   r)   r*   r+   r,   r-   r.   r/   r0   r1   onnx.onnx_operators_pbr#   r%   onnx.onnx_data_pbr    r'   r(   onnx.versionr?   __version__r   r   r   r   r   r   r   r   r   r   r   r   r   rJ   r   rd   rR   rW   r]   ri   r5   r7   r4   r6   r8   r9   loadload_from_stringsave r^   rQ   <module>r      s.  
 #<~ 
  % %  + 
       : C D D /   & !893>? $ MQ+	 +%I+"+* '+#$#  	D '+W$W#W W*  /FFF F*  /GGG G, '+3
 #($(#33$3 $3
  3 "3 3 3 3 
3r '+$ $ 
	, ) r^   