§
    ù¸¸jÖ  ã                  óÀ   — d Z ddlm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mZmZmZ erddlmZ 	 	 	 d-d.d„Z	 	 	 	 d/d0d„Zdddej        fd1d%„Zd2d,„Ze
j        ZdS )3zIonnx shape inference. Shape inference is not guaranteed to be
complete.

é    )ÚannotationsN)ÚTYPE_CHECKING)ÚAttributeProtoÚFunctionProtoÚ
ModelProtoÚ	TypeProto)ÚSequenceFÚmodelúModelProto | bytesÚ
check_typeÚboolÚstrict_modeÚ	data_propÚreturnr   c                ól  — t          | t          t          f¦  «        rVt          | t          ¦  «        r| n|                      ¦   «         }t	          j        ||||¦  «        }t          j        |¦  «        S t          | t          ¦  «        rt          d¦  «        ‚t          dt          | ¦  «        › �¦  «        ‚)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)r
   r   r   r   Ú	model_strÚinferred_model_strs         úd/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/onnx/shape_inference.pyr   r      s½   € õ0 �%�*¥eÐ,Ñ-Ô-ð 9Ý'¨­uÑ5Ô5ÐT�E�E¸5×;RÒ;RÑ;TÔ;Tˆ	Ýœ^Ø�z ;°	ñ
ô 
Ðõ Ô$Ð%7Ñ8Ô8Ð8Ý�%�ÑÔð 
ÝðIñ
ô 
ð 	
õ
 ØWÍ$ÈuÉ+Ì+ÐWÐWñô ð ó    Ú Ú
model_pathústr | os.PathLikeÚoutput_pathÚNonec                ó®  — t          | t          ¦  «        rt          d¦  «        ‚	 t          j        | ¦  «        } n2# t          $ r%}t          dt          | ¦  «        › �¦  «        |‚d}~ww xY w	 t          j        |¦  «        }n2# t          $ r%}t          dt          |¦  «        › �¦  «        |‚d}~ww xY w|dk    r| }t          j        | ||||¦  «         dS )zñTake 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   r   ÚosÚfspathr   r   Úinfer_shapes_path)r!   r#   r   r   r   Úexps         r   r(   r(   @   s*  € õ �*�jÑ)Ô)ð 
Ýð;ñ
ô 
ð 	
ðÝ”Y˜zÑ*Ô*ˆ
ˆ
øÝð ð ð Ýð=Ý*.¨zÑ*:Ô*:ð=ð =ñ
ô 
ð ð	øøøøðøøøð
Ý”i Ñ,Ô,ˆˆøÝð ð ð Ýð?Ý+/°Ñ+<Ô+<ð?ð ?ñ
ô 
ð ð	øøøøðøøøð �bÒÐØ ˆÝÔ˜
 K°¸[È)ÑTÔTÐTÐTÐTs-   ¦; »
A*Á A%Á%A*Á.B Â
B2Â B-Â-B2Úschemaúonnx.defs.OpSchemaÚnodeúonnx.NodeProtoÚinput_typesúdict[str, onnx.TypeProto]Ú
input_dataú"dict[str, onnx.TensorProto] | NoneÚinput_sparse_dataú(dict[str, onnx.SparseTensorProto] | NoneÚopset_importsú$list[onnx.OperatorSetIdProto] | NoneÚ
ir_versionÚintc                ó¼  ‡‡‡— | j         si S ‰€i Š‰€i Š|€i }nd„ |D ¦   «         }ˆfd„|j        D ¦   «         }‰                     ¦   «         D ] \  }	}
|	|vr|
                     ¦   «         ||	<   Œ!ˆfd„|j        D ¦   «         }ˆfd„|j        D ¦   «         }|                      |                     ¦   «         |||||¦  «        }d„ |                     ¦   «         D ¦   «         S )Nc                ó(   — i | ]}|j         |j        “ŒS © )ÚdomainÚversion)Ú.0Úopsets     r   ú
<dictcomp>z&infer_node_outputs.<locals>.<dictcomp>x   s   € ÐWÐWÐWÀ ¤¨e¬mÐWÐWÐWr   c                óR   •— i | ]#}|d k    ¯|‰|                               ¦   «         “Œ$S )r    ©r   )r=   Úkeyr.   s     €r   r?   z&infer_node_outputs.<locals>.<dictcomp>{   s9   ø€ ð ð ð Ø69È3ÐRTÊ9È9ˆˆ[˜Ô×/Ò/Ñ1Ô1È9È9È9r   c                óN   •— i | ]!}|‰v ¯|‰|                               ¦   «         “Œ"S r:   rA   )r=   rB   r0   s     €r   r?   z&infer_node_outputs.<locals>.<dictcomp>‚   s@   ø€ ð ð ð àØ�*ÐÐð 	ˆZ˜Œ_×.Ò.Ñ0Ô0àÐÐr   c                óN   •— i | ]!}|‰v ¯|‰|                               ¦   «         “Œ"S r:   rA   )r=   rB   r2   s     €r   r?   z&infer_node_outputs.<locals>.<dictcomp>‡   sC   ø€ ð  ð  ð  àØÐ#Ð#Ð#ð 	Ð˜sÔ#×5Ò5Ñ7Ô7à#Ð#Ð#r   c                óT   — i | ]%\  }}|t           j                             |¦  «        “Œ&S r:   )r   r   Ú
FromString)r=   rB   Úouts      r   r?   z&infer_node_outputs.<locals>.<dictcomp>•   s.   € ÐPÐPÐP±H°C¸ˆC•”×*Ò*¨3Ñ/Ô/ÐPÐPÐPr   )Ú%has_type_and_shape_inference_functionÚinputÚitemsr   Ú_infer_node_outputs)r*   r,   r.   r0   r2   r4   r6   Úpassed_opset_importsÚpassed_input_typesrB   ÚvalueÚpassed_input_dataÚpassed_sparse_input_dataÚoutputss     ```         r   Úinfer_node_outputsrR   f   sm  øøø€ ð Ô7ð Øˆ	ØÐØˆ
ØÐ ØÐØÐØ!ÐÐàWÐWÈÐWÑWÔWÐðð ð ð Ø=A¼Zðñ ô Ðð "×'Ò'Ñ)Ô)ð @ð @‰
ˆˆUØÐ(Ð(Ð(Ø&+×&=Ò&=Ñ&?Ô&?Ð˜sÑ#øðð ð ð à”:ðñ ô Ðð
 ð  ð  ð  à”:ð ñ  ô  Ðð ×(Ò(Ø×ÒÑ Ô ØØØ ØØñô €Gð QÐPÀÇÂÁÄÐPÑPÔPÐPr   Úfunctionr   úSequence[TypeProto]Ú
attributesúSequence[AttributeProto]úlist[TypeProto]c                ó    ‡— t          j        |                      ¦   «         d„ |D ¦   «         d„ |D ¦   «         ¦  «        }dd„Šˆfd„|D ¦   «         S )zxApply type-and-shape-inference to given function body, with given input types
    and given input attribute values.
    c                ó6   — g | ]}|                      ¦   «         ‘ŒS r:   rA   ©r=   Úxs     r   ú
<listcomp>z/infer_function_output_types.<locals>.<listcomp>¢   s$   € Ð4Ð4Ð4 1ˆ×	Ò	Ñ	Ô	Ð4Ð4Ð4r   c                ó6   — g | ]}|                      ¦   «         ‘ŒS r:   rA   rZ   s     r   r\   z/infer_function_output_types.<locals>.<listcomp>£   s$   € Ð3Ð3Ð3 1ˆ×	Ò	Ñ	Ô	Ð3Ð3Ð3r   r   r   c                óV   — t          j        ¦   «         }|                     | ¦  «         |S )N)r   r   ÚParseFromString)r[   Ú
type_protos     r   Úto_type_protoz2infer_function_output_types.<locals>.to_type_proto¦   s)   € Ý”^Ñ%Ô%ˆ
Ø×"Ò" 1Ñ%Ô%Ð%ØÐr   c                ó&   •— g | ]} ‰|¦  «        ‘ŒS r:   r:   )r=   r[   ra   s     €r   r\   z/infer_function_output_types.<locals>.<listcomp>«   s#   ø€ Ð-Ð-Ð- ˆMˆM˜!ÑÔÐ-Ð-Ð-r   )r   r   )r   Úinfer_function_output_typesr   )rS   r.   rU   Úresultra   s       @r   rc   rc   ˜   sx   ø€ õ Ô*Ø×"Ò"Ñ$Ô$Ø4Ð4¨Ð4Ñ4Ô4Ø3Ð3¨
Ð3Ñ3Ô3ñô €Fðð ð ð ð
 .Ð-Ð-Ð- fÐ-Ñ-Ô-Ð-r   )FFF)
r
   r   r   r   r   r   r   r   r   r   )r    FFF)r!   r"   r#   r"   r   r   r   r   r   r   r   r$   )r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r   r/   )rS   r   r.   rT   rU   rV   r   rW   )Ú__doc__Ú
__future__r   r&   Útypingr   r   Ú'onnx.onnx_cpp2py_export.shape_inferenceÚonnx_cpp2py_exportÚshape_inferencer   r   r   r   r   Úcollections.abcr	   r   r(   Ú
IR_VERSIONrR   rc   ÚInferenceErrorr:   r   r   ú<module>rn      sC  ðð
ð ð
 #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø  Ð  Ð  Ð  Ð  Ð  à €€€Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ Eàð )Ø(Ð(Ð(Ð(Ð(Ð(ð
 ØØð	&ð &ð &ð &ð &ðV &(ØØØð#Uð #Uð #Uð #Uð #UðT 6:ØBFØ:>Ø”oð/Qð /Qð /Qð /Qð /Qðd.ð .ð .ð .ð, Ô!€€€r   