
    /;ji                       d Z ddlmZ g dZddl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)Messagel         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     F/root/voice-cloning/.venv/lib/python3.11/site-packages/onnx/checker.py_ensure_proto_typer    0   sA    eZ(( 
Lj6I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   7   s6     z4#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     vt/000>&2244c:::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   E   s9    
 tT0111T3355s<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   N   s7    
 tT^,,,<..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>b   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   W   s    
 x!3444
{  <<!$ = 
 

 
"*"7
 
 
 X//1138I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   i   s7    
 udo...=0022C9J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	   r   s<     vt5666&2244c:::::r!   Fmodel+onnx.ModelProto | str | bytes | os.PathLike
full_checkboolskip_opset_compatibility_checkcheck_custom_domainc                z   t          | t          t          j        f          r+t	          j        t          j        |           |||           dS t          | t                    r| n|                                 }t          j
        |          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*   sys	getsizeofr   
ValueErrorr   )rT   rV   rX   rY   protobuf_strings        r   r   r   y   s    4 %#r{+,, 
	Ie*		
 	
 	
 	
 	
  u--LEE53J3J3L3L 	
 =)),<<<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\   ra   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>rr      s9   K J " " " " " "    
			 



                 + + + + + + + + + # # # # # # 0//////   #!"$$' !#TY%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!   