§
    1�Åj]  ã                  óx  — d Z ddlmZ g d¢ZddlZddlmZ ddlZddl	m
c mZ ddlmZ erddlmZ dZ ej        ¦   «         Zee_        d	ej                             ¦   «         ie_         ej        ¦   «         Zd3d„Zefd4d„Zefd5d„Zeefd6d„Zeefd7d „Zdefd8d$„Zeefd9d'„Z efd:d*„Z!	 	 	 d;d<d2„Z"ej#        Z#dS )=zDGraph utilities for checking whether an ONNX proto message is legal.é    )Úannotations)Úcheck_attributeÚcheck_functionÚcheck_graphÚcheck_modelÚ
check_nodeÚcheck_sparse_tensorÚcheck_tensorÚcheck_value_infoÚDEFAULT_CONTEXTÚLEXICAL_SCOPE_CONTEXTÚValidationErrorÚCÚMAXIMUM_PROTOBUFN)ÚTYPE_CHECKING)Ú
IR_VERSION)ÚMessageiÿÿÿÚ Úprotor   Ú
proto_typeútype[Message]ÚreturnÚNonec                óV   — t          | |¦  «        st          d|j        › d�¦  «        ‚d S )Nz'The proto message needs to be of type 'ú')Ú
isinstanceÚ	TypeErrorÚ__name__)r   r   s     ú=C:\Projects\Historical\venv\Lib\site-packages\onnx/checker.pyÚ_ensure_proto_typer    /   sA   € Ý�e˜ZÑ(Ô(ð 
ÝØL°jÔ6IÐLÐLÐLñ
ô 
ð 	
ð
ð 
ó    Ú
value_infoúonnx.ValueInfoProtoÚctxúC.CheckerContextc                ó„   — t          | t          j        ¦  «         t          j        |                      ¦   «         |¦  «        S ©N)r    ÚonnxÚValueInfoProtor   r   ÚSerializeToString)r"   r$   s     r   r   r   6   s6   € õ �z¥4Ô#6Ñ7Ô7Ð7ÝÔ˜j×:Ò:Ñ<Ô<¸cÑBÔBÐBr!   Útensorúonnx.TensorProtoc                ó„   — t          | t          j        ¦  «         t          j        |                      ¦   «         |¦  «        S r'   )r    r(   ÚTensorProtor   r
   r*   )r+   r$   s     r   r
   r
   =   s5   € õ �v�tÔ/Ñ0Ô0Ð0ÝŒ>˜&×2Ò2Ñ4Ô4°cÑ:Ô:Ð:r!   Úattrúonnx.AttributeProtoÚlexical_scope_ctxúC.LexicalScopeContextc                ó†   — t          | t          j        ¦  «         t          j        |                      ¦   «         ||¦  «        S r'   )r    r(   ÚAttributeProtor   r   r*   )r/   r$   r1   s      r   r   r   D   s9   € õ
 �t�TÔ0Ñ1Ô1Ð1ÝÔ˜T×3Ò3Ñ5Ô5°sÐ<MÑNÔNÐNr!   Únodeúonnx.NodeProtoc                ó†   — t          | t          j        ¦  «         t          j        |                      ¦   «         ||¦  «        S r'   )r    r(   Ú	NodeProtor   r   r*   )r5   r$   r1   s      r   r   r   M   s7   € õ
 �t�Tœ^Ñ,Ô,Ð,ÝŒ<˜×.Ò.Ñ0Ô0°#Ð7HÑIÔIÐIr!   Úfunctionúonnx.FunctionProtoúC.CheckerContext | Nonec                ó6  — t          | t          j        ¦  «         |€Tt          j        ¦   «         }t          j                             | j        d¬¦  «        |_        d„ | j        D ¦   «         |_	        t          j
        |                      ¦   «         ||¦  «         d S )NT)Úignore_unknownc                ó(   — i | ]}|j         |j        “ŒS © )ÚdomainÚversion)Ú.0Údomain_versions     r   ú
<dictcomp>z"check_function.<locals>.<dictcomp>a   s0   € ð 
ð 
ð 
àð Ô! >Ô#9ð
ð 
ð 
r!   )r    r(   ÚFunctionProtor   ÚCheckerContextÚhelperÚfind_min_ir_version_forÚopset_importÚ
ir_versionÚopset_importsr   r*   )r9   r$   r1   s      r   r   r   V   sž   € õ
 �x¥Ô!3Ñ4Ô4Ð4Ø
€{ÝÔÑ Ô ˆÝœ×<Ò<ØÔ!°$ð =ñ 
ô 
ˆŒð
ð 
à"*Ô"7ð
ñ 
ô 
ˆÔõ Ô�X×/Ò/Ñ1Ô1°3Ð8IÑJÔJÐJÐJÐJr!   Úgraphúonnx.GraphProtoc                ó†   — t          | t          j        ¦  «         t          j        |                      ¦   «         ||¦  «        S r'   )r    r(   Ú
GraphProtor   r   r*   )rL   r$   r1   s      r   r   r   h   s7   € õ
 �u�dœoÑ.Ô.Ð.ÝŒ=˜×0Ò0Ñ2Ô2°CÐ9JÑKÔKÐKr!   Úsparseúonnx.SparseTensorProtoc                óˆ   — t          | t          j        ¦  «         t          j        |                      ¦   «         |¦  «         d S r'   )r    r(   ÚSparseTensorProtor   r	   r*   )rP   r$   s     r   r	   r	   q   s<   € õ �v�tÔ5Ñ6Ô6Ð6ÝÔ˜&×2Ò2Ñ4Ô4°cÑ:Ô:Ð:Ð:Ð:r!   FÚmodelú+onnx.ModelProto | str | bytes | os.PathLikeÚ
full_checkÚboolÚskip_opset_compatibility_checkÚcheck_custom_domainc                óp  — t          | t          t          j        f¦  «        r+t	          j        t          j        | ¦  «        |||¦  «         dS t          | t          ¦  «        r| n|                      ¦   «         }t          |¦  «        t          k    rt          d¦  «        ‚t	          j        ||||¦  «         dS )ar  Check the consistency of a model.

    An exception will be raised if the model's ir_version is not set
    properly or is higher than checker's ir_version, or if the model
    has duplicate keys in metadata_props.

    If IR version >= 3, the model must specify opset_import.
    If IR version < 3, the model cannot have any opset_import specified.

    Args:
        model: Model to check. If model is a path, the function checks model
            path first. If the model bytes size is larger than 2GB, function
            should be called using model path.
        full_check: If True, the function also runs shape inference check.
        skip_opset_compatibility_check: If True, the function skips the check for
            opset compatibility.
        check_custom_domain: If True, the function will check all domains. Otherwise
            only check built-in domains.
    z[This protobuf of onnx model is too large (>2GiB). Call check_model with model path instead.N)r   ÚstrÚosÚPathLiker   Úcheck_model_pathÚfspathÚbytesr*   Úlenr   Ú
ValueErrorr   )rT   rV   rX   rY   Úprotobuf_strings        r   r   r   x   sÒ   € õ4 �%�#�rœ{Ð+Ñ,Ô,ð 
Ý	ÔÝŒI�eÑÔØØ*Øñ		
ô 	
ð 	
ð 	
ð 	
õ   ¥uÑ-Ô-ÐLˆEˆE°5×3JÒ3JÑ3LÔ3Lð 	õ
 ˆÑÔÕ"2Ò2Ð2ÝØmñô ð õ 	
ŒØØØ*Øñ		
ô 	
ð 	
ð 	
ð 	
r!   )r   r   r   r   r   r   )r"   r#   r$   r%   r   r   )r+   r,   r$   r%   r   r   )r/   r0   r$   r%   r1   r2   r   r   )r5   r6   r$   r%   r1   r2   r   r   )r9   r:   r$   r;   r1   r2   r   r   )rL   rM   r$   r%   r1   r2   r   r   )rP   rQ   r$   r%   r   r   )FFF)
rT   rU   rV   rW   rX   rW   rY   rW   r   r   )$Ú__doc__Ú
__future__r   Ú__all__r\   Útypingr   Ú	onnx.defsr(   Úonnx.onnx_cpp2py_export.checkerÚonnx_cpp2py_exportÚcheckerr   Úonnx.onnx_pbr   Úgoogle.protobuf.messager   r   rF   r   rJ   ÚdefsÚonnx_opset_versionrK   ÚLexicalScopeContextr   r    r   r
   r   r   r   r   r	   r   r   r?   r!   r   ú<module>rq      s0  ðð KÐ Jà "Ð "Ð "Ð "Ð "Ð "ðð ð €ð  
€	€	€	Ø  Ð  Ð  Ð  Ð  Ð  à Ð Ð Ð Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø #Ð #Ð #Ð #Ð #Ð #àð 0Ø/Ð/Ð/Ð/Ð/Ð/ð Ð ð #�!Ô"Ñ$Ô$€Ø'€Ô à!# T¤Y×%AÒ%AÑ%CÔ%CÐ D€Ô à-˜Ô-Ñ/Ô/Ð ð
ð 
ð 
ð 
ð >MðCð Cð Cð Cð Cð 7Fð;ð ;ð ;ð ;ð ;ð ,Ø/DðOð Oð Oð Oð Oð ,Ø/DðJð Jð Jð Jð Jð $(Ø/DðKð Kð Kð Kð Kð( ,Ø/DðLð Lð Lð Lð Lð =Lð;ð ;ð ;ð ;ð ;ð Ø+0Ø %ð	0
ð 0
ð 0
ð 0
ð 0
ðf Ô#€€€r!   