
    
Ng                       d Z ddlmZ g dZddlZddlZddlmZmZm	Z	 ddl
mZ ddlZddlmc mZ ddlZddlmZmZmZmZmZmZmZmZmZ dZ ej                    Zee_        d	ej         !                                ie_"         ej#                    Z$ e	d
edef                   Z%d6dZ&efd7dZ'efd8dZ(ee$fd9d Z)ee$fd:d#Z*de$fd;d'Z+ee$fd<d*Z,efd=d-Z-	 	 	 d>d?d5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)AnyCallableTypeVar)Message)	
IR_VERSIONAttributeProtoFunctionProto
GraphProto
ModelProto	NodeProtoSparseTensorProtoTensorProtoValueInfoProtoi 5w FuncType.)bound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     H/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/checker.py_ensure_proto_typer,   A   sA    eZ(( 
Lj6ILLL
 
 	

 
    
value_infor   ctxC.CheckerContextc                z    t          | t                     t          j        |                                 |          S N)r,   r   r   r   SerializeToString)r.   r/   s     r+   r   r   H   s3     z>222j::<<cBBBr-   tensorr   c                z    t          | t                     t          j        |                                 |          S r2   )r,   r   r   r
   r3   )r4   r/   s     r+   r
   r
   O   s0    v{+++>&2244c:::r-   attrr   lexical_scope_ctxC.LexicalScopeContextc                |    t          | t                     t          j        |                                 ||          S r2   )r,   r   r   r   r3   )r6   r/   r7   s      r+   r   r   T   s6    
 t^,,,T3355s<MNNNr-   noder   c                |    t          | t                     t          j        |                                 ||          S r2   )r,   r   r   r   r3   )r:   r/   r7   s      r+   r   r   ]   s5    
 tY'''<..00#7HIIIr-   functionr   C.CheckerContext | Nonec                ,   t          | t                     |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>q   s0     
 
 
 !>#9
 
 
r-   )r,   r   r   CheckerContextonnxhelperfind_min_ir_version_foropset_import
ir_versionopset_importsr   r3   )r<   r/   r7   s      r+   r   r   f   s    
 x///
{  <<!$ = 
 

 
"*"7
 
 
 X//1138IJJJJJr-   graphr   c                |    t          | t                     t          j        |                                 ||          S r2   )r,   r   r   r   r3   )rN   r/   r7   s      r+   r   r   x   s5    
 uj)))=0022C9JKKKr-   sparser   c                ~    t          | t                     t          j        |                                 |           d S r2   )r,   r   r   r	   r3   )rP   r/   s     r+   r	   r	      s:     v0111&2244c:::::r-   Fmodel&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.
    zZThis protobuf of onnx model is too large (>2GB). Call check_model with model path instead.N)r(   strosPathLiker   check_model_pathfspathbytesr3   sys	getsizeofr   
ValueErrorr   )rR   rT   rV   rW   protobuf_strings        r+   r   r      s    4 %#r{+,, 
	Ie*		
 	
 	
 	
 	
  u--LEE53J3J3L3L 	
 =)),<<<l   	
*		
 	
 	
 	
 	
r-   )r!   r   r"   r#   r$   r%   )r.   r   r/   r0   r$   r%   )r4   r   r/   r0   r$   r%   )r6   r   r/   r0   r7   r8   r$   r%   )r:   r   r/   r0   r7   r8   r$   r%   )r<   r   r/   r=   r7   r8   r$   r%   )rN   r   r/   r0   r7   r8   r$   r%   )rP   r   r/   r0   r$   r%   )FFF)
rR   rS   rT   rU   rV   rU   rW   rU   r$   r%   )0__doc__
__future__r   __all__rZ   r_   typingr   r   r   google.protobuf.messager   	onnx.defsrH   onnx.onnx_cpp2py_export.checkeronnx_cpp2py_exportcheckerr   onnx.shape_inferencer   r   r   r   r   r   r   r   r   r   rG   r   rL   defsonnx_opset_versionrM   LexicalScopeContextr   r   r,   r   r
   r   r   r   r   r	   r   r   rA   r-   r+   <module>rp      s   K J " " " " " "    
			 



 ) ) ) ) ) ) ) ) ) ) + + + + + +     + + + + + + + + +    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   #!"$$' !#TY%A%A%C%C D --//  7:Xc3h%7888
 
 
 
 9HC C C C C ?N ; ; ; ; ; ,/DO O O O O ,/DJ J J J J $(/DK K K K K( ,/DL L L L L 8G; ; ; ; ; +0 %	0
 0
 0
 0
 0
f #r-   