
    Si                    &   S r SSKJr  / SQrSSKrSSKrSSKJr  SSKr	SSK
Js  Jr  SSKJr  \(       a  SSKJr  Sr\R&                  " 5       r\\l        S	\	R,                  R/                  5       0\l        \R2                  " 5       rSS
 jr\4     SS jjr\4     SS jjr\\4       SS jjr\\4       SS jjrS\4       SS jjr \\4       SS jjr!\4     SS jjr"   S         SS jjr#\RH                  r$g)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         c                V    [        X5      (       d  [        SUR                   S35      eg )Nz'The proto message needs to be of type '')
isinstance	TypeError__name__)proto
proto_types     K/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/checker.py_ensure_proto_typer   0   s2    e((5j6I6I5J!L
 	
 )    c                    [        U [        R                  5        [        R                  " U R                  5       U5      $ N)r   onnxValueInfoProtor   r   SerializeToString)
value_infoctxs     r   r   r   7   s0     z4#6#67j::<cBBr   c                    [        U [        R                  5        [        R                  " U R                  5       U5      $ r    )r   r!   TensorProtor   r
   r#   )tensorr%   s     r   r
   r
   >   s.     vt//0>>&224c::r   c                    [        U [        R                  5        [        R                  " U R                  5       X5      $ r    )r   r!   AttributeProtor   r   r#   )attrr%   lexical_scope_ctxs      r   r   r   E   s0    
 tT001T335sNNr   c                    [        U [        R                  5        [        R                  " U R                  5       X5      $ r    )r   r!   	NodeProtor   r   r#   )noder%   r,   s      r   r   r   N   s,    
 tT^^,<<..0#IIr   c                   [        U [        R                  5        Ucy  [        R                  " 5       n[        R
                  R                  U R                  SS9Ul        U R                   Vs0 s H  nUR                  UR                  _M     snUl        [        R                  " U R                  5       X5        g s  snf )NT)ignore_unknown)r   r!   FunctionProtor   CheckerContexthelperfind_min_ir_version_foropset_import
ir_versiondomainversionopset_importsr   r#   )functionr%   r,   domain_versions       r   r   r   W   s    
 x!3!34
{ <<!!$ = 

 #+"7"7
"7 !!>#9#99"7
 X//13J	
s   .!B=c                    [        U [        R                  5        [        R                  " U R                  5       X5      $ r    )r   r!   
GraphProtor   r   r#   )graphr%   r,   s      r   r   r   i   s,    
 udoo.==002CKKr   c                    [        U [        R                  5        [        R                  " U R                  5       U5        g r    )r   r!   SparseTensorProtor   r	   r#   )sparser%   s     r   r	   r	   r   s-     vt556&224c:r   c                |   [        U [        [        R                  45      (       a.  [        R
                  " [        R                  " U 5      UUU5        g[        U [        5      (       a  U OU R                  5       n[        R                  " U5      [        :  a  [        S5      e[        R                  " UUUU5        g)a6  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   )model
full_checkskip_opset_compatibility_checkcheck_custom_domainprotobuf_strings        r   r   r   y   s    4 %#r{{+,,	IIe*		
  u--E53J3J3L 	
 ==),<<m  	
*		
r   )r   r   r   ztype[Message]returnNone)r$   zonnx.ValueInfoProtor%   C.CheckerContextrR   rS   )r(   zonnx.TensorProtor%   rT   rR   rS   )r+   zonnx.AttributeProtor%   rT   r,   C.LexicalScopeContextrR   rS   )r/   zonnx.NodeProtor%   rT   r,   rU   rR   rS   )r;   zonnx.FunctionProtor%   zC.CheckerContext | Noner,   rU   rR   rS   )r?   zonnx.GraphProtor%   rT   r,   rU   rR   rS   )rB   zonnx.SparseTensorProtor%   rT   rR   rS   )FFF)
rM   z+onnx.ModelProto | str | bytes | os.PathLikerN   boolrO   rV   rP   rV   rR   rS   )%__doc__
__future__r   __all__rE   rJ   typingr   	onnx.defsr!   onnx.onnx_cpp2py_export.checkeronnx_cpp2py_exportcheckerr   onnx.onnx_pbr   google.protobuf.messager   r   r3   r   r7   defsonnx_opset_versionr:   LexicalScopeContextr   r   r   r
   r   r   r   r   r	   r   r    r   r   <module>re      s   K "  
 
    + + #/   ""$' !#TYY%A%A%C D --/ 
 >MC#C*:C	C 7F;;#3;	; ,/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;";)9;	; +0 %	0
60
0
 %)0
 	0

 
0
f ##r   