§
    3�Åj  ã                  ó  — d dl mZ d dlmZmZ d dl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)Ú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        ¦  «         	 |                      |¦  «        }nQ# t          $ rD}t	          dd                     d„ |fD ¦   «         ¦  «        › d| j        j        ›d�¦  «        |‚d}~ww xY w|                       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     úGC:\Projects\Historical\venv\Lib\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 ú).Nú-- done %s.run -> %d outputs)Ú_logÚ	__class__Ú__name__Ú_runÚ	TypeErrorÚjoinÚ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ñô ð ðøøøøð	øøøð
 	�	Š	Ð0°$´.Ô2IÍ3ÈsÉ8Ì8ÑTÔTÐTØ×*Ò*¨3Ñ/Ô/Ð/s   ¢8 ¸
BÁ?BÂBN©r   Ú
__module__Ú__qualname__Ú__doc__r'   © r   r   r
   r
      ó-   € € € € € ðð ð
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.run-   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   r/   r/   '   r-   r   r/   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                óÌ  — |                       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�¦  «        ‚	 |                      ||¦  «        }nY# t          t          f$ rE}t          dd
                     d„ ||fD ¦   «         ¦  «        › d| j        j        ›d�¦  «        |‚d}~ww xY w|                       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>X   s.   è è € Ð.LÐ.LÀ­sµ4¸±7´7©|¬|Ð.LÐ.LÐ.LÐ.LÐ.LÐ.Lr   z (binary operator r   )r   r   r   ÚRuntimeErrorr   r3   r   Úshaper   r   Ú
ValueErrorr    r!   r"   )r#   r$   Úyr%   r&   s        r   r'   zOpRunBinary.runD   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ñô ð ðøøøøð	øøøð
 	�	Š	Ð0°$´.Ô2IÍ3ÈsÉ8Ì8ÑTÔTÐTØ×*Ò*¨3Ñ/Ô/Ð/s   Â3C
 Ã
D ÃA DÄD Nr(   r,   r   r   r5   r5   >   s-   € € € € € ðð ð
0ð 0ð 0ð 0ð 0r   r5   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?   _   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: r7   z or z (operator z
) type(x)=z	 type(y)=)r5   r'   r3   r   r   r   r   r"   )r#   r$   r=   r%   s       r   r'   zOpRunBinaryNum.runi   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   rA   rA   c   s-   € € € € € ðð ð
	0ð 	0ð 	0ð 	0ð 	0r   rA   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   )rA   Ú__init__rE   )r#   rE   rF   rG   s       r   rJ   zOpRunBinaryNumpy.__init__z   s'   € õ 	×Ò  i°Ñ<Ô<Ð<Ø"ˆŒˆˆr   c                óZ   — |                       ||¦  «        f}|                      |¦  «        S r   )rE   r"   )r#   ÚaÚbr%   s       r   r   zOpRunBinaryNumpy._run€   s,   € Ø�~Š~˜a Ñ#Ô#Ð%ˆØ×*Ò*¨3Ñ/Ô/Ð/r   N)rE   r   rF   r   rG   rH   )r   r)   r*   r+   rJ   r   r,   r   r   rD   rD   u   sA   € € € € € ðð ð#ð #ð #ð #ð0ð 0ð 0ð 0ð 0r   rD   c                  ó4   — e Zd ZdZdd„Zd„ Zdd	„Zd
„ Zd„ ZdS )ÚOpRunReduceNumpyzFImplements the reduce logic.
    It must have a parameter *axes*.
    rF   r   rG   rH   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   rJ   Úhasattrr1   rQ   ÚnpÚndarrayr!   r;   Útupler2   )r#   rF   rG   s      r   rJ   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 p
|j         dk    S )N)r   )r;   )r#   rQ   s     r   Úis_axes_emptyzOpRunReduceNumpy.is_axes_empty—   s   € Ø�tˆ|Ð1˜tœz¨TÒ1Ð1r   Fc                óð  — t          |t          ¦  «        rt          |¦  «        dk    r|sd S |S |€|rd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|rdS d S t          | 	                    ¦   «          
                    ¦   «         ¦  «        S )Nr   r,   zaxes must be an array, not ú.)r1   rU   r!   ÚintrS   rT   r   r   r;   ÚravelÚtolist)r#   rQ   Únoop_with_empty_axess      r   Úhandle_axeszOpRunReduceNumpy.handle_axesš   s÷   € Ý�d�EÑ"Ô"ð 	Ý�4‰yŒy˜AŠ~ˆ~Ð&:ˆ~Ø�tØˆKØˆ<Ø#ð Ø�rØ�4Ý�d�S¥%˜LÑ)Ô)ð 	ØˆKÝ˜$¥¤
Ñ+Ô+ð 	IÝÐG½$¸t¹*¼*ÐGÐGÐGÑHÔHÐHÝˆtŒz‰?Œ?˜aÒÐÝ�t‘9”9Ðà�”
ˆ?ˆ?Ø#ð Ø�rØ�4Ý�T—Z’Z‘\”\×(Ò(Ñ*Ô*Ñ+Ô+Ð+r   c                ó:   — t          j        |||¬¦  «        j        S )N)ÚaxisÚkeepdims)rS   Úsumr;   )r#   ÚdatarQ   ra   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.)r3   )rd   rS   Úfullr3   )r#   rc   Ú	const_valrQ   ra   rd   s         r   Úreduce_constantz OpRunReduceNumpy.reduce_constant³   s5   € à×(Ò(¨¨t°XÑ>Ô>ˆÝ”˜ i°t´zÐBÑBÔBÐDÐDr   N)rF   r   rG   rH   )F)	r   r)   r*   r+   rJ   rW   r^   rd   rh   r,   r   r   rO   rO   …   s{   € € € € € ðð ð-ð -ð -ð -ð2ð 2ð 2ð,ð ,ð ,ð ,ð,@ð @ð @ðEð Eð Eð Eð Er   rO   )Ú
__future__r   Útypingr   r   ÚnumpyrS   Úonnx.reference.op_runr   r   Úonnx.onnx_pbr   r
   r/   r5   r?   rA   rD   rO   r,   r   r   ú<module>rn      s²  ðð #Ð "Ð "Ð "Ð "Ð "à %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð à 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9àð 'Ø&Ð&Ð&Ð&Ð&Ð&ð0ð 0ð 0ð 0ð 0�ñ 0ô 0ð 0ð.0ð 0ð 0ð 0ð 0�Jñ 0ô 0ð 0ð.0ð 0ð 0ð 0ð 0�%ñ 0ô 0ð 0ðB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ð 1Eð 1Eð 1Eð 1Eð 1E�uñ 1Eô 1Eð 1Eð 1Eð 1Er   