
    Si                    `   S r SSKJ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JrJrJrJr  \(       a  SSKJr  \
R&                  r\
R(                  r   S         SS jjr    S           SS jjrSSS\4               SS	 jjr        SS
 jr\
R2                  rg)zIonnx shape inference. Shape inference is not guaranteed to be
complete.

    )annotationsN)TYPE_CHECKING)
IR_VERSIONAttributeProtoFunctionProto
ModelProto	TypeProto)Sequencec                N   [        U [        [        45      (       aT  [        U [        5      (       a  U OU R                  5       n[        R
                  " XAX#5      n[        R                  " U5      $ [        U [        5      (       a  [        S5      e[        S[        U 5       35      e)a  Apply shape inference to the provided ModelProto.

Inferred shapes are added to the value_info field of the graph.

If the inferred values conflict with values already provided in the
graph, that means that the provided values are invalid (or there is a
bug in shape inference), and the result is unspecified.

Arguments:
    model: ModelProto.
    check_type: Checks the type-equality for input and output.
    strict_mode: Stricter shape inference, it will throw errors if any;
        Otherwise, simply stop if any error.
    data_prop: Enables data propagation for limited operators to perform shape computation.

Returns:
    (ModelProto) model with inferred shape information
zhinfer_shapes only accepts ModelProto or bytes,you can use infer_shapes_path for the model path (String).z?infer_shapes only accepts ModelProto or bytes, incorrect type: )
isinstancer   bytesSerializeToStringCinfer_shapesonnxload_from_stringstr	TypeErrortype)model
check_typestrict_mode	data_prop	model_strinferred_model_strs         S/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/shape_inference.pyr   r       s    0 %*e,--'u55E5;R;R;T	^^;
 $$%788%I
 	

 
I$u+W     c                   [        U [        5      (       a  [        S5      e [        R                  " U 5      n  [        R                  " U5      nUS:X  a  U n[        R                  " XX#U5        g! [         a  n[        S[        U 5       35      UeSnAff = f! [         a  n[        S[        U5       35      UeSnAff = f)zTake model path for shape_inference.

This function is the same as :func:`infer_shape` but supports >2GB models.
The function outputs the inferred model to the `output_path`. The original model path
is used if not specified.
z_infer_shapes_path only accepts model Path (String),you can use infer_shapes for the ModelProto.z^infer_shapes_path only accepts model path as a string or PathLike, incorrect model path type: Nz`infer_shapes_path only accepts output path as a string or PathLike, incorrect output path type:  )r   r   r   osfspathr   r   infer_shapes_path)
model_pathoutput_pathr   r   r   exps         r   r"   r"   I   s     *j));
 	
YYz*
ii, b 
)T  **.z*:);=
 	  ++/+<*=?
 	s.   A0 B 0
B:BB
C$B<<Cc                   Uc  0 nUc  0 nUc  0 nO&U Vs0 s H  oR                   UR                  _M     nnUR                   V	s0 s H  oS:w  d  M
  XU	   R                  5       _M     n
n	UR	                  5        H  u  pX;  d  M  UR                  5       X'   M      UR                   V	s0 s H  n	X;   d  M
  XU	   R                  5       _M     nn	UR                   V	s0 s H  n	X;   d  M
  XU	   R                  5       _M     nn	U R                  UR                  5       U
UUUU5      nUR	                  5        V	Vs0 s H%  u  pU	[        R                  R                  U5      _M'     snn	$ s  snf s  sn	f s  sn	f s  sn	f s  snn	f )Nr   )	domainversioninputr   items_infer_node_outputsr   r	   
FromString)schemanodeinput_types
input_datainput_sparse_dataopset_imports
ir_versionpassed_opset_importsopsetkeypassed_input_typesvaluepassed_input_datapassed_sparse_input_dataoutputsouts                   r   infer_node_outputsr=   o   s    
 !IVWemm ;W >BZZ=GcRT91//11Z   "'')
(&+&=&=&?# *
 ::C 	1_..00   :: C# 	8s#5577    ((  G AHPHCC**3//PP;  X
  Qs/    E,	E1E1+	E68E6	E;,E;<,F c           	        [         R                  " U R                  5       U Vs/ s H  o3R                  5       PM     snU Vs/ s H  o3R                  5       PM     sn5      nSS jnU Vs/ s H
  o5" U5      PM     sn$ s  snf s  snf s  snf )zpApply type-and-shape-inference to given function body, with given input types
and given input attribute values.
c                R    [         R                  " 5       nUR                  U 5        U$ )N)r   r	   ParseFromString)x
type_protos     r   to_type_proto2infer_function_output_types.<locals>.to_type_proto   s"    ^^%
""1%r   )returnr	   )r   infer_function_output_typesr   )functionr/   
attributesrA   resultrC   s         r   rF   rF      s     **""$(341			4(23
1			
3F
 '--fM!f-- 	53 .s   B 
B,B
)FFF)
r   zModelProto | bytesr   boolr   rJ   r   rJ   rE   r   )r   FFF)r#   str | os.PathLiker$   rK   r   rJ   r   rJ   r   rJ   rE   None)r-   zonnx.defs.OpSchemar.   zonnx.NodeProtor/   dict[str, onnx.TypeProto]r0   z"dict[str, onnx.TensorProto] | Noner1   z(dict[str, onnx.SparseTensorProto] | Noner2   z$list[onnx.OperatorSetIdProto] | Noner3   intrE   rM   )rG   r   r/   zSequence[TypeProto]rH   zSequence[AttributeProto]rE   zlist[TypeProto])__doc__
__future__r   r    typingr   r   'onnx.onnx_cpp2py_export.shape_inferenceonnx_cpp2py_exportshape_inferencer   onnx.onnx_pbr   r   r   r   r	   collections.abcr
   GraphInferencerInferenceContextr   r"   r=   rF   InferenceError r   r   <module>r[      sy  

 # 	    3 3  (##%% 
 	&&& & 	&
 &V &(#U!#U"#U #U 	#U
 #U 
#UT 6:BF:> -Q-Q
-Q +-Q 3	-Q
 @-Q 8-Q -Q -Q`..$. ). 	., !!r   