§
    ú¸¸j‹  ã                  ó  — d dl mZ d dlmZmZ d dlZd dlmZm	Z	 d dl
mZmZ erd dlmZ  G d„ de¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )é    )Úannotations)ÚTYPE_CHECKINGÚAnyN)Úconvert_from_ml_dtypesÚconvert_to_ml_dtypes)ÚOpRunÚRuntimeTypeError)Ú	NodeProtoc                  ó   — e Zd ZdZd„ ZdS )Ú
OpRunUnaryzmAncestor to all unary operators in this subfolder.

    Checks that input and output types are the same.
    c                óâ  — |                       d| j        j        ¦  «         t          |¦  «        }	 |                      |¦  «        }nQ# t
          $ rD}t          dd                     d„ |fD ¦   «         ¦  «        › d| j        j        ›d�¦  «        |‚d}~ww xY wt          |d         ¦  «        f}|                       d	| j        j        t          |¦  «        ¦  «         |  	                    |¦  «        S )
z|Calls method ``_run``, catches exceptions, displays a longer error message.

        Supports only unary operators.
        z-- begin %s.run(1 input)úIssues with types ú, c              3  óN   K  — | ] }t          t          |¦  «        ¦  «        V — Œ!d S ©N©ÚstrÚtype©Ú.0Ú_s     úf/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/onnx/reference/ops/_op.pyú	<genexpr>z!OpRunUnary.run.<locals>.<genexpr>%   s.   è è € Ð.IÐ.IÀ­sµ4¸±7´7©|¬|Ð.IÐ.IÐ.IÐ.IÐ.IÐ.Ió    z (unary operator ú).Nr   ú-- done %s.run -> %d outputs)
Ú_logÚ	__class__Ú__name__r   Ú_runÚ	TypeErrorÚjoinr   ÚlenÚ_check_and_fix_outputs)ÚselfÚxÚresÚes       r   ÚrunzOpRunUnary.run   s  € ð
 	�	Š	Ð,¨d¬nÔ.EÑFÔFÐFÝ  Ñ#Ô#ˆð	Ø—)’)˜A‘,”,ˆCˆCøÝð 	ð 	ð 	ÝðA T§Y¢YÐ.IÐ.IÀaÀSÐ.IÑ.IÔ.IÑ%IÔ%Ið Að AØ#'¤>Ô#:ðAð Að Añô ð ðøøøøð	øøøõ
 & c¨!¤fÑ-Ô-Ð/ˆØ�	Š	Ð0°$´.Ô2IÍ3ÈsÉ8Ì8ÑTÔTÐTØ×*Ò*¨3Ñ/Ô/Ð/s   ±A Á
BÁ?BÂBN©r   Ú
__module__Ú__qualname__Ú__doc__r)   © r   r   r   r      s-   € € € € € ðð ð
0ð 0ð 0ð 0ð 0r   r   c                  ó   — e Zd ZdZd„ ZdS )ÚOpRunUnaryNumz{Ancestor to all unary and numerical operators in this subfolder.

    Checks that input and output types are the same.
    c           	     ód  — t                                | |¦  «        }t          |¦  «        dk    s|d         €|S t          |d         t          ¦  «        sI|d         j        |j        k    r3t          d|j        › d|d         j        › d| j        j        ›d�¦  «        ‚|  	                    |¦  «        S )z”Calls method ``OpRunUnary.run``.

        Catches exceptions, displays a longer error message.
        Checks that the result is not empty.
        r   NzOutput type mismatch: input 'z' != output 'z' (operator r   )
r   r)   r#   Ú
isinstanceÚlistÚdtyper	   r   r   r$   )r%   r&   r'   s      r   r)   zOpRunUnaryNum.run3   s¿   € õ �nŠn˜T 1Ñ%Ô%ˆÝˆs‰8Œ8�qŠ=ˆ=˜C œF˜NØˆJÝ˜#˜aœ&¥$Ñ'Ô'ð 	¨C°¬F¬L¸A¼GÒ,CÐ,CÝ"ð;°´ð ;ð ;ÀcÈ!ÄfÄlð ;ð ;Ø!œ^Ô4ð;ð ;ð ;ñô ð ð ×*Ò*¨3Ñ/Ô/Ð/r   Nr*   r.   r   r   r0   r0   -   s-   € € € € € ðð ð
0ð 0ð 0ð 0ð 0r   r0   c                  ó   — e Zd ZdZd„ ZdS )ÚOpRunBinaryznAncestor to all binary operators in this subfolder.

    Checks that input and output types are the same.
    c                ó4  — |                       d| j        j        ¦  «         |�|€@t          dt	          |¦  «        › dt	          |¦  «        › dt	          | ¦  «        › d�¦  «        ‚|j        |j        k    r=t          d|j        › d|j        › d| j        j        ›d	|j        › d
|j        › d�¦  «        ‚t          |¦  «        }t          |¦  «        }	 |  	                    ||¦  «        }nY# t          t          f$ rE}t          dd
                     d„ ||fD ¦   «         ¦  «        › d| j        j        ›d�¦  «        |‚d}~ww xY wt          |d         ¦  «        f}|                       d| j        j        t          |¦  «        ¦  «         |                      |¦  «        S )z}Calls method ``_run``, catches exceptions, displays a longer error message.

        Supports only binary operators.
        z-- begin %s.run(2 inputs)Nzx and y have different dtype: ú != z (ú)zInput type mismatch: z (operator 'z
', shapes r   r   r   c              3  óN   K  — | ] }t          t          |¦  «        ¦  «        V — Œ!d S r   r   r   s     r   r   z"OpRunBinary.run.<locals>.<genexpr>`   s.   è è € Ð.LÐ.LÀ­sµ4¸±7´7©|¬|Ð.LÐ.LÐ.LÐ.LÐ.LÐ.Lr   z (binary operator r   r   )r   r   r   ÚRuntimeErrorr   r4   r	   Úshaper   r    r!   Ú
ValueErrorr"   r   r#   r$   )r%   r&   Úyr'   r(   s        r   r)   zOpRunBinary.runJ   sê  € ð
 	�	Š	Ð-¨t¬~Ô/FÑGÔGÐGØˆ9˜˜	ÝØVµ°a±´ÐVÐV½dÀ1¹g¼gÐVÐVÍÈdÉÌÐVÐVÐVñô ð ð Œ7�a”gÒÐÝ"ð1¨¬ð 1ð 1°Q´Wð 1ð 1Ø"œnÔ5ð1ð 1àœ'ð1ð 1à%&¤Wð1ð 1ð 1ñô ð õ
 ! Ñ#Ô#ˆÝ  Ñ#Ô#ˆð	Ø—)’)˜A˜q‘/”/ˆCˆCøÝ�:Ð&ð 	ð 	ð 	ÝðB T§Y¢YÐ.LÐ.LÀaÈÀVÐ.LÑ.LÔ.LÑ%LÔ%Lð Bð BØ$(¤NÔ$;ðBð Bð Bñô ð ðøøøøð	øøøõ
 & c¨!¤fÑ-Ô-Ð/ˆØ�	Š	Ð0°$´.Ô2IÍ3ÈsÉ8Ì8ÑTÔTÐTØ×*Ò*¨3Ñ/Ô/Ð/s   ÃC( Ã(D>Ã9A D9Ä9D>Nr*   r.   r   r   r6   r6   D   s-   € € € € € ðð ð
0ð 0ð 0ð 0ð 0r   r6   c                  ó   — e Zd ZdZdS )ÚOpRunBinaryComparisonzEAncestor to all binary operators in this subfolder comparing tensors.N)r   r+   r,   r-   r.   r   r   r@   r@   h   s   € € € € € ØOÐOÐOÐOr   r@   c                  ó   — e Zd ZdZd„ ZdS )ÚOpRunBinaryNumznAncestor to all binary operators in this subfolder.

    Checks that input oud output types are the same.
    c                óD  — t                                | ||¦  «        }|d         j        |j        k    rZt          d|j        › d|d         j        › d|j        › d| j        j        ›dt          |¦  «        › dt          |¦  «        › �¦  «        ‚|                      |¦  «        S )zVCalls method ``OpRunBinary.run``, catches exceptions, displays a longer error message.r   zOutput type mismatch: r8   z or z (operator z
) type(x)=z	 type(y)=)r6   r)   r4   r	   r   r   r   r$   )r%   r&   r>   r'   s       r   r)   zOpRunBinaryNum.runr   s½   € å�oŠo˜d A qÑ)Ô)ˆØˆqŒ6Œ<˜1œ7Ò"Ð"Ý"ð8¨¬ð 8ð 8°c¸!´f´lð 8ð 8ÈÌð 8ð 8Ø!œ^Ô4ð8ð 8å  ™GœGð8ð 8å.2°1©g¬gð8ð 8ñô ð ð
 ×*Ò*¨3Ñ/Ô/Ð/r   Nr*   r.   r   r   rB   rB   l   s-   € € € € € ðð ð
	0ð 	0ð 	0ð 	0ð 	0r   rB   c                  ó    — e Zd ZdZdd„Zd	„ Zd
S )ÚOpRunBinaryNumpyzI*numpy_fct* is a binary numpy function which
    takes two matrices.
    Ú	numpy_fctr   Ú	onnx_noder
   Ú
run_paramsúdict[str, Any]c                óL   — t                                | ||¦  «         || _        d S r   )rB   Ú__init__rF   )r%   rF   rG   rH   s       r   rK   zOpRunBinaryNumpy.__init__ƒ   s'   € õ 	×Ò  i°Ñ<Ô<Ð<Ø"ˆŒˆˆr   c                óÂ   — t          |¦  «        }t          |¦  «        }|                      ||¦  «        f}t          |d         ¦  «        f}|                      |¦  «        S )Nr   )r   rF   r   r$   )r%   ÚaÚbr'   s       r   r    zOpRunBinaryNumpy._run‰   sZ   € Ý  Ñ#Ô#ˆÝ  Ñ#Ô#ˆØ�~Š~˜a Ñ#Ô#Ð%ˆÝ% c¨!¤fÑ-Ô-Ð/ˆØ×*Ò*¨3Ñ/Ô/Ð/r   N)rF   r   rG   r
   rH   rI   )r   r+   r,   r-   rK   r    r.   r   r   rE   rE   ~   sA   € € € € € ðð ð#ð #ð #ð #ð0ð 0ð 0ð 0ð 0r   rE   c                  ó2   — e Zd ZdZdd„Zd„ Zd„ Zd	„ Zd
„ ZdS )ÚOpRunReduceNumpyzFImplements the reduce logic.
    It must have a parameter *axes*.
    rG   r
   rH   rI   c                óÔ  — t          j        | ||¦  «         t          | d¦  «        r¿t          | j        t
          j        ¦  «        rWt          | j        j        ¦  «        dk    s| j        j        d         dk    r	d | _        d S t          | j        ¦  «        | _        d S | j        g dfv r	d | _        d S t          | j        t          ¦  «        rt          | j        ¦  «        | _        d S d S d S )NÚaxesr   r.   )r   rK   Úhasattrr2   rR   ÚnpÚndarrayr#   r<   Útupler3   )r%   rG   rH   s      r   rK   zOpRunReduceNumpy.__init__–   sá   € ÝŒ�t˜Y¨
Ñ3Ô3Ð3Ý�4˜Ñ Ô ð 		-Ý˜$œ)¥R¤ZÑ0Ô0ð -Ý�t”y”Ñ'Ô'¨1Ò,Ð,°´	´ÀÔ0BÀaÒ0GÐ0GØ $�D”I�I�Iå % d¤iÑ 0Ô 0�D”I�I�IØ”˜r 2˜hÐ&Ð&Ø �”	�	�	Ý˜DœI¥tÑ,Ô,ð -Ý! $¤)Ñ,Ô,�”	�	�	ð		-ð 		-ð-ð -r   c                ó
   — |d u S r   r.   ©r%   rR   s     r   Úis_axes_emptyzOpRunReduceNumpy.is_axes_empty£   s   € Ø�tˆ|Ðr   c                óÜ  — t          |t          ¦  «        rt          |¦  «        dk    rd S |S |€d S t          |t          t          f¦  «        r|S t          |t          j        ¦  «        s t          dt          |¦  «        › d�¦  «        ‚t          |j        ¦  «        dk    rt          |¦  «        S d|j        v rd S t          | 	                    ¦   «          
                    ¦   «         ¦  «        S )Nr   zaxes must be an array, not ú.)r2   rV   r#   ÚintrT   rU   r!   r   r<   ÚravelÚtolistrX   s     r   Úhandle_axeszOpRunReduceNumpy.handle_axes¦   sØ   € Ý�d�EÑ"Ô"ð 	Ý�4‰yŒy˜AŠ~ˆ~Ø�tØˆKØˆ<Ø�4Ý�d�S¥%˜LÑ)Ô)ð 	ØˆKÝ˜$¥¤
Ñ+Ô+ð 	IÝÐG½$¸t¹*¼*ÐGÐGÐGÑHÔHÐHÝˆtŒz‰?Œ?˜aÒÐÝ�t‘9”9ÐØ�”
ˆ?ˆ?Ø�4Ý�T—Z’Z‘\”\×(Ò(Ñ*Ô*Ñ+Ô+Ð+r   c                ó:   — t          j        |||¬¦  «        j        S )N)ÚaxisÚkeepdims)rT   Úsumr<   )r%   ÚdatarR   rb   s       r   Úoutput_shapezOpRunReduceNumpy.output_shape·   s   € ÝŒv�d °Ð9Ñ9Ô9Ô?Ð?r   c                ój   — |                       |||¦  «        }t          j        |||j        ¬¦  «        fS )z<Special case reduction where the output value is a constant.)r4   )re   rT   Úfullr4   )r%   rd   Ú	const_valrR   rb   re   s         r   Úreduce_constantz OpRunReduceNumpy.reduce_constantº   s5   € à×(Ò(¨¨t°XÑ>Ô>ˆÝ”˜ i°t´zÐBÑBÔBÐDÐDr   N)rG   r
   rH   rI   )	r   r+   r,   r-   rK   rY   r_   re   ri   r.   r   r   rP   rP   ‘   sv   € € € € € ðð ð-ð -ð -ð -ðð ð ð,ð ,ð ,ð"@ð @ð @ðEð Eð Eð Eð Er   rP   )Ú
__future__r   Útypingr   r   ÚnumpyrT   Ú#onnx.reference.custom_element_typesr   r   Úonnx.reference.op_runr   r	   Úonnx.onnx_pbr
   r   r0   r6   r@   rB   rE   rP   r.   r   r   ú<module>rp      sÜ  ðð #Ð "Ð "Ð "Ð "Ð "à %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð ðð ð ð ð ð ð ð ð :Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9àð 'Ø&Ð&Ð&Ð&Ð&Ð&ð0ð 0ð 0ð 0ð 0�ñ 0ô 0ð 0ð20ð 0ð 0ð 0ð 0�Jñ 0ô 0ð 0ð.!0ð !0ð !0ð !0ð !0�%ñ !0ô !0ð !0ðHPð Pð Pð Pð P˜Kñ Pô Pð Pð0ð 0ð 0ð 0ð 0�[ñ 0ô 0ð 0ð$0ð 0ð 0ð 0ð 0�~ñ 0ô 0ð 0ð&,Eð ,Eð ,Eð ,Eð ,E�uñ ,Eô ,Eð ,Eð ,Eð ,Er   