§
    ù¸¸jú  ã                  óX  — d dl mZ d dlZdgZd dlZd dlmZmZmZmZ d dl	Z
d dlZ
d dlZ
d dlZej        rd dlmZ  ede
j        j        j        ¬¦  «        ZdZ G d	„ d
e¦  «        Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z e¦   «         Ze                      e¦   «         ¦  «         e                      e¦   «         ¦  «         e                      e¦   «         ¦  «         e                      e¦   «         ¦  «         dS )é    )ÚannotationsNÚregistry)ÚAnyÚOptionalÚProtocolÚTypeVar)Ú
CollectionÚ_Proto)Úboundzutf-8c                  ó8   — e Zd ZU dZded<   ded<   dd
„Zdd„ZdS )ÚProtoSerializerzQA serializer-deserializer to and from in-memory Protocol Buffers representations.ÚstrÚsupported_formatzCollection[str]Úfile_extensionsÚprotor
   Úreturnr   c                ó   — dS )z6Serialize a in-memory proto to a serialized data type.N© )Úselfr   s     úb/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/onnx/serialization.pyÚserialize_protozProtoSerializer.serialize_proto,   ó   € € € ó    Ú
serializedc                ó   — dS )z4Parse a serialized data type into a in-memory proto.Nr   ©r   r   r   s      r   Údeserialize_protoz!ProtoSerializer.deserialize_proto/   r   r   N)r   r
   r   r   )r   r   r   r
   r   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   r   r      sj   € € € € € € Ø[Ð[ð ÐÐÑð %Ð$Ð$Ñ$ðEð Eð Eð EðCð Cð Cð Cð Cð Cr   r   c                  ó.   — e Zd Zdd„Zdd„Zdd	„Zdd„ZdS )Ú	_Registryr   ÚNonec                ó"   — i | _         i | _        d S ©N)Ú_serializersÚ_extension_to_format)r   s    r   Ú__init__z_Registry.__init__4   s   € Ø8:ˆÔà46ˆÔ!Ð!Ð!r   Ú
serializerr   c                ó|   ‡— ‰| j         ‰j        <   | j                             ˆfd„‰j        D ¦   «         ¦  «         d S )Nc                ó    •— i | ]
}|‰j         “ŒS r   )r   )Ú.0Úextr+   s     €r   ú
<dictcomp>z&_Registry.register.<locals>.<dictcomp><   s   ø€ ÐTÐTÐT°#ˆS�*Ô-ÐTÐTÐTr   )r(   r   r)   Úupdater   )r   r+   s    `r   Úregisterz_Registry.register9   sR   ø€ Ø9CˆÔ˜*Ô5Ñ6ØÔ!×(Ò(ØTÐTÐTÐT¸Ô9SÐTÑTÔTñ	
ô 	
ð 	
ð 	
ð 	
r   Úfmtr   c                ó”   — 	 | j         |         S # t          $ r. t          d|› d| j                              ¦   «         › �¦  «        d‚w xY w)a  Get a serializer for a format.

        Args:
            fmt: The format to get a serializer for.

        Returns:
            ProtoSerializer: The serializer for the format.

        Raises:
            ValueError: If the format is not supported.
        zUnsupported format: 'z'. Supported formats are: N)r(   ÚKeyErrorÚ
ValueErrorÚkeys)r   r3   s     r   Úgetz_Registry.get?   sg   € ð	ØÔ$ SÔ)Ð)øÝð 	ð 	ð 	ÝØa¨ÐaÐaÀtÔGX×G]ÒG]ÑG_ÔG_ÐaÐañô àðð	øøøs	   ‚ �8AÚfile_extensionú
str | Nonec                ó6   — | j                              |¦  «        S )zæGet the corresponding format from a file extension.

        Args:
            file_extension: The file extension to get a format for.

        Returns:
            The format for the file extension, or None if not found.
        )r)   r8   )r   r9   s     r   Úget_format_from_file_extensionz(_Registry.get_format_from_file_extensionR   s   € ð Ô(×,Ò,¨^Ñ<Ô<Ð<r   N)r   r%   )r+   r   r   r%   )r3   r   r   r   )r9   r   r   r:   )r   r   r    r*   r2   r8   r<   r   r   r   r$   r$   3   sd   € € € € € ð7ð 7ð 7ð 7ð

ð 
ð 
ð 
ðð ð ð ð&	=ð 	=ð 	=ð 	=ð 	=ð 	=r   r$   c                  ó@   — e Zd ZdZdZ eddh¦  «        Zdd	„Zdd„ZdS )Ú_ProtobufSerializerz+Serialize and deserialize protobuf message.Úprotobufz.onnxz.pbr   r
   r   Úbytesc                óL  — t          |d¦  «        rvt          |j        ¦  «        rb	 |                     ¦   «         }nJ# t          $ r=}|                     ¦   «         t
          j        j        k    rt          d¦  «        |‚‚ d }~ww xY w|S t          dt          |¦  «        › �¦  «        ‚)NÚSerializeToStringz~The proto size is larger than the 2 GB limit. Please use save_as_external_data to save tensors separately from the model file.z1No SerializeToString method is detected.
type is )
ÚhasattrÚcallablerB   r6   ÚByteSizeÚonnxÚcheckerÚMAXIMUM_PROTOBUFÚ	TypeErrorÚtype)r   r   ÚresultÚes       r   r   z#_ProtobufSerializer.serialize_protod   sÄ   € Ý�5Ð-Ñ.Ô.ð 
	µ8¸EÔ<SÑ3TÔ3Tð 
	ðØ×0Ò0Ñ2Ô2��øÝð ð ð Ø—>’>Ñ#Ô#¥t¤|Ô'DÒDÐDÝ$ðkñô ð ðð øøøøðøøøð ˆMÝØNÅÀeÁÄÐNÐNñ
ô 
ð 	
s   ¦; »
BÁ8A=Á=Br   c                óv  — t          |t          ¦  «        st          dt          |¦  «        › �¦  «        ‚t	          j        t          t                   |                     |¦  «        ¦  «        }|�J|t          |¦  «        k    r7t          j        j                             d|› dt          |¦  «        › �¦  «        ‚|S )Nz4Parameter 'serialized' must be bytes, but got type: z*Protobuf decoding consumed too few bytes: z out of )Ú
isinstancer@   rI   rJ   ÚtypingÚcastr   ÚintÚParseFromStringÚlenÚgoogler?   ÚmessageÚDecodeError)r   r   r   Údecodeds       r   r   z%_ProtobufSerializer.deserialize_protot   s²   € Ý˜*¥eÑ,Ô,ð 	ÝØYÅtÈJÑGWÔGWÐYÐYñô ð õ ”+�h¥sœm¨U×-BÒ-BÀ:Ñ-NÔ-NÑOÔOˆØÐ 7­c°*©o¬oÒ#=Ð#=Ý”/Ô)×5Ò5Ø_¸WÐ_Ð_ÍcÐR\ÉoÌoÐ_Ð_ñô ð ð ˆr   N©r   r
   r   r@   )r   r@   r   r
   r   r
   ©	r   r   r    r!   r   Ú	frozensetr   r   r   r   r   r   r>   r>   ^   s\   € € € € € Ø5Ð5à!ÐØ�i ¨%Ð 0Ñ1Ô1€Oð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
r   r>   c                  ó@   — e Zd ZdZdZ eh d£¦  «        Zdd„Zdd„ZdS )Ú_TextProtoSerializerz%Serialize and deserialize text proto.Ú	textproto>   ú.pbtxtú	.prototxtú
.textprotor   r
   r   r@   c                ó~   — t           j        j                             |¦  «        }|                     t
          ¦  «        S r'   )rT   r?   Útext_formatÚMessageToStringÚencodeÚ	_ENCODING)r   r   r]   s      r   r   z$_TextProtoSerializer.serialize_proto‡   s.   € Ý”OÔ/×?Ò?ÀÑFÔFˆ	Ø×Ò¥	Ñ*Ô*Ð*r   r   úbytes | strc                óN  — t          |t          t          f¦  «        st          dt	          |¦  «        › �¦  «        ‚t          |t          ¦  «        r|                     t          ¦  «        }t          |t          ¦  «        sJ ‚t          j        j	         
                    ||¦  «        S ©Nú;Parameter 'serialized' must be bytes or str, but got type: )rN   r@   r   rI   rJ   Údecodere   rT   r?   rb   ÚParser   s      r   r   z&_TextProtoSerializer.deserialize_proto‹   ó–   € Ý˜*¥u­c lÑ3Ô3ð 	ÝØ`ÍdÐS]ÑN^ÔN^Ð`Ð`ñô ð õ �j¥%Ñ(Ô(ð 	6Ø#×*Ò*­9Ñ5Ô5ˆJÝ˜*¥cÑ*Ô*Ð*Ð*Ð*ÝŒÔ*×0Ò0°¸UÑCÔCÐCr   NrX   ©r   rf   r   r
   r   r
   rY   r   r   r   r\   r\   �   sd   € € € € € Ø/Ð/à"ÐØ�iÐ EÐ EÐ EÑFÔF€Oð+ð +ð +ð +ðDð Dð Dð Dð Dð Dr   r\   c                  ó@   — e Zd ZdZdZ eddh¦  «        Zdd	„Zdd„ZdS )Ú_JsonSerializerzSerialize and deserialize JSON.Újsonz.jsonz	.onnxjsonr   r
   r   r@   c                ó‚   — t           j        j                             |d¬¦  «        }|                     t
          ¦  «        S )NT)Úpreserving_proto_field_name)rT   r?   Újson_formatÚMessageToJsonrd   re   )r   r   Újson_messages      r   r   z_JsonSerializer.serialize_protoœ   s=   € Ý”Ô2×@Ò@Ø¨tð Añ 
ô 
ˆð ×"Ò"¥9Ñ-Ô-Ð-r   r   rf   c                óN  — t          |t          t          f¦  «        st          dt	          |¦  «        › �¦  «        ‚t          |t          ¦  «        r|                     t          ¦  «        }t          |t          ¦  «        sJ ‚t          j        j	         
                    ||¦  «        S rh   )rN   r@   r   rI   rJ   rj   re   rT   r?   rs   rk   r   s      r   r   z!_JsonSerializer.deserialize_proto¢   rl   r   NrX   rm   rY   r   r   r   ro   ro   –   sb   € € € € € Ø)Ð)àÐØ�i ¨+Ð 6Ñ7Ô7€Oð.ð .ð .ð .ðDð Dð Dð Dð Dð Dr   ro   c                  ó@   — e Zd ZdZdZ eddh¦  «        Zdd	„Zdd„ZdS )Ú_TextualSerializerz:Serialize and deserialize the ONNX textual representation.Úonnxtxtz.onnxtxtz	.onnxtextr   r
   r   r@   c                ót   — t           j                             |¦  «        }|                     t          ¦  «        S r'   )rF   ÚprinterÚto_textrd   re   )r   r   Útexts      r   r   z"_TextualSerializer.serialize_proto³   s)   € ÝŒ|×#Ò# EÑ*Ô*ˆØ�{Š{�9Ñ%Ô%Ð%r   r   rf   c                ó  — t          j        dd¬¦  «         t          |t          t          f¦  «        st          dt          |¦  «        › �¦  «        ‚t          |t          ¦  «        r|                     t          ¦  «        }n|}t          |t          j
        ¦  «        rt          j                             |¦  «        S t          |t          j        ¦  «        rt          j                             |¦  «        S t          |t          j        ¦  «        rt          j                             |¦  «        S t          |t          j        ¦  «        rt          j                             |¦  «        S t'          dt          |¦  «        › �¦  «        ‚)Nz[The onnxtxt format is experimental. Please report any errors to the ONNX GitHub repository.é   )Ú
stacklevelri   zUnsupported proto type: )ÚwarningsÚwarnrN   r@   r   rI   rJ   rj   re   rF   Ú
ModelProtoÚparserÚparse_modelÚ
GraphProtoÚparse_graphÚFunctionProtoÚparse_functionÚ	NodeProtoÚ
parse_noder6   )r   r   r   r}   s       r   r   z$_TextualSerializer.deserialize_proto·   sS  € ÝŒØiØð	
ñ 	
ô 	
ð 	
õ ˜*¥u­c lÑ3Ô3ð 	ÝØ`ÍdÐS]ÑN^ÔN^Ð`Ð`ñô ð õ �j¥%Ñ(Ô(ð 	Ø×$Ò$¥YÑ/Ô/ˆDˆDàˆDÝ�e�Tœ_Ñ-Ô-ð 	1Ý”;×*Ò*¨4Ñ0Ô0Ð0Ý�e�Tœ_Ñ-Ô-ð 	1Ý”;×*Ò*¨4Ñ0Ô0Ð0Ý�e�TÔ/Ñ0Ô0ð 	4Ý”;×-Ò-¨dÑ3Ô3Ð3Ý�e�Tœ^Ñ,Ô,ð 	0Ý”;×)Ò)¨$Ñ/Ô/Ð/ÝÐAµD¸±K´KÐAÐAÑBÔBÐBr   NrX   rm   rY   r   r   r   rx   rx   ­   sb   € € € € € ØDÐDà ÐØ�i ¨[Ð 9Ñ:Ô:€Oð&ð &ð &ð &ðCð Cð Cð Cð Cð Cr   rx   )Ú
__future__r   r�   Ú__all__rO   r   r   r   r   Úgoogle.protobuf.json_formatrT   Úgoogle.protobuf.messageÚgoogle.protobuf.text_formatrF   ÚTYPE_CHECKINGÚcollections.abcr	   r?   rU   ÚMessager
   re   r   r$   r>   r\   ro   rx   r   r2   r   r   r   ú<module>r”      sn  ðð
 #Ð "Ð "Ð "Ð "Ð "à €€€ð ð€ð €€€Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à "Ð "Ð "Ð "Ø Ð Ð Ð Ø "Ð "Ð "Ð "à €€€à	Ôð +Ø*Ð*Ð*Ð*Ð*Ð*à	ˆ� ¤Ô!8Ô!@Ð	AÑ	AÔ	A€à€	ðCð Cð Cð Cð C�hñ Cô Cð Cð*(=ð (=ð (=ð (=ð (=ñ (=ô (=ð (=ðV ð  ð  ð  ð  ˜/ñ  ô  ð  ðFDð Dð Dð Dð D˜?ñ Dô Dð Dð*Dð Dð Dð Dð D�oñ Dô Dð Dð.Cð Cð Cð Cð C˜ñ Cô Cð CðF ˆ9‰;Œ;€Ø × Ò Ð%Ð%Ñ'Ô'Ñ (Ô (Ð (Ø × Ò Ð&Ð&Ñ(Ô(Ñ )Ô )Ð )Ø × Ò �/�/Ñ#Ô#Ñ $Ô $Ð $Ø × Ò Ð$Ð$Ñ&Ô&Ñ 'Ô 'Ð 'Ð 'Ð 'r   