
    h                         S SK JrJr  S SKrS SKJr  S SKJrJ	r	   " S S\5      r
 " S S\
5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)    )AnyDictN)	NodeProto)OpRunRuntimeTypeErrorc                   :    \ rS rSrSrS\S\\\4   4S jr	S r
Srg)	
OpRunUnary   ze
Ancestor to all unary operators in this subfolder.
Checks that input and output types are the same.
	onnx_node
run_paramsc                 2    [         R                  " XU5        g Nr   __init__selfr   r   s      P/var/www/fran/franai/venv/lib/python3.13/site-packages/onnx/reference/ops/_op.pyr   OpRunUnary.__init__       t
3    c                 x   U R                  SU R                  R                  5         U R                  U5      nU R                  SU R                  R                  [        U5      5        U$ ! [         aD  n[	        SSR                  S U4 5       5       SU R                  R                  < S35      UeSnAff = f)	zl
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   J   #    U  H  n[        [        U5      5      v   M     g 7fr   strtype.0_s     r   	<genexpr>!OpRunUnary.run.<locals>.<genexpr>!   s     .ISs47||S   !#z (unary operator ).N-- done %s.run -> %d outputs)_log	__class____name___run	TypeErrorjoinlen)r   xreses       r   runOpRunUnary.run   s     			,dnn.E.EF	))A,C 			0$..2I2I3s8T
  	$TYY.IaS.I%I$J K##'>>#:#:"=RA 	s   A+ +
B95?B44B9 Nr(   
__module____qualname____firstlineno____doc__r   r   r   r   r   r0   __static_attributes__r2   r   r   r	   r	      s'    
4) 4c3h 4r   r	   c                   :    \ rS rSrSrS\S\\\4   4S jr	S r
Srg)	OpRunUnaryNum(   zs
Ancestor to all unary and numerical operators
in this subfolder. Checks that input and output types
are the same.
r   r   c                 0    [         R                  XU5        g r   )r	   r   r   s      r   r   OpRunUnaryNum.__init__/   s    DZ8r   c           	      J   [         R                  X5      n[        U5      S:X  d  US   c  U$ [        US   [        5      (       d^  US   R
                  UR
                  :w  aA  [        SUR
                   SUS   R
                   SU R                  R                  < S35      eU$ )z|
Calls method ``OpRunUnary.run``, catches exceptions,
displays a longer error message.
Checks that the result is not empty.
r   zOutput type mismatch: input 'z' != output 'z' (operator r$   )	r	   r0   r,   
isinstancelistdtyper   r'   r(   )r   r-   r.   s      r   r0   OpRunUnaryNum.run2   s     nnT%s8q=CFNJ#a&$''CFLLAGG,C"/yc!fll^ T!^^447r;  
r   r2   Nr3   r2   r   r   r:   r:   (   s'    9) 9c3h 9r   r:   c                   :    \ rS rSrSrS\S\\\4   4S jr	S r
Srg)	OpRunBinaryC   zf
Ancestor to all binary operators in this subfolder.
Checks that input and output types are the same.
r   r   c                 2    [         R                  " XU5        g r   r   r   s      r   r   OpRunBinary.__init__I   r   r   c                    U R                  SU R                  R                  5        Ub  Uc0  [        S[	        U5       S[	        U5       S[	        U 5       S35      eUR
                  UR
                  :w  aX  [        SUR
                   SUR
                   SU R                  R                  < S	UR                   S
UR                   S35      e U R                  X5      nU R                  SU R                  R                  [        U5      5        U$ ! [        [        4 aD  n[        SS
R                  S X4 5       5       SU R                  R                  < S35      UeSnAff = f)zm
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   J   #    U  H  n[        [        U5      5      v   M     g 7fr   r   r   s     r   r!   "OpRunBinary.run.<locals>.<genexpr>a   s     .LVs47||Vr#   z (binary operator r%   )r&   r'   r(   RuntimeErrorr   rA   r   shaper)   r*   
ValueErrorr+   r,   )r   r-   yr.   r/   s        r   r0   OpRunBinary.runL   sX    			-t~~/F/FG9	0a	d1gYbdTUV  77agg"'yQWWI >"nn558 9''"QWWIR1 
	))A/C 			0$..2I2I3s8T
 :& 	$TYY.LaV.L%L$M N$$(NN$;$;#>bB 	s   D E'#?E""E'r2   Nr3   r2   r   r   rD   rD   C   s'    
4) 4c3h 4r   rD   c                   4    \ rS rSrSrS\S\\\4   4S jr	Sr
g)OpRunBinaryComparisonh   zG
Ancestor to all binary operators in this subfolder
comparing tensors.
r   r   c                 0    [         R                  XU5        g r   rD   r   r   s      r   r   OpRunBinaryComparison.__init__n       Tj9r   r2   N)r(   r4   r5   r6   r7   r   r   r   r   r   r8   r2   r   r   rS   rS   h   s"    
:) :c3h :r   rS   c                   :    \ rS rSrSrS\S\\\4   4S jr	S r
Srg)	OpRunBinaryNumr   zf
Ancestor to all binary operators in this subfolder.
Checks that input oud output types are the same.
r   r   c                 0    [         R                  XU5        g r   rV   r   s      r   r   OpRunBinaryNum.__init__x   rX   r   c                 6   [         R                  XU5      nUS   R                  UR                  :w  ae  [        SUR                   SUS   R                   SUR                   SU R                  R
                  < S[        U5       S[        U5       35      eU$ )zX
Calls method ``OpRunBinary.run``, catches exceptions,
displays a longer error message.
r   zOutput type mismatch: rI   z or z (operator z
) type(x)=z	 type(y)=)rD   r0   rA   r   r'   r(   r   )r   r-   rP   r.   s       r   r0   OpRunBinaryNum.run{   s    
 oodq)q6<<177""(	c!fll^4y Q!^^447 8 G9Id1gY8 
 
r   r2   Nr3   r2   r   r   rZ   rZ   r   s'    
:) :c3h :r   rZ   c                   >    \ rS rSrSrS\S\S\\\4   4S jr	S r
Srg	)
OpRunBinaryNumpy   zB
*numpy_fct* is a binary numpy function which
takes two matrices.
	numpy_fctr   r   c                 <    [         R                  XU5        Xl        g r   )rZ   r   rc   )r   rc   r   r   s       r   r   OpRunBinaryNumpy.__init__   s     	<"r   c                 &    U R                  X5      4$ r   rc   )r   abs      r   r)   OpRunBinaryNumpy._run   s    q$&&r   rg   N)r(   r4   r5   r6   r7   r   r   r   r   r   r)   r8   r2   r   r   ra   ra      s1    
##)2#@DS#X#'r   ra   c                   L    \ rS rSrSrS\S\\\4   4S jr	S r
S rS rS	 rS
rg)OpRunReduceNumpy   z?
Implements the reduce logic.
It must have a parameter *axes*.
r   r   c                    [         R                  " XU5        [        U S5      (       a  [        U R                  [
        R                  5      (       ac  [        U R                  R                  5      S:X  d  U R                  R                  S   S:X  a  S U l        g [        U R                  5      U l        g U R                  / S4;   a  S U l        g [        U R                  [        5      (       a  [        U R                  5      U l        g g g )Naxesr   r2   )r   r   hasattrr?   ro   npndarrayr,   rN   tupler@   r   s      r   r   OpRunReduceNumpy.__init__   s    t
34  $))RZZ00tyy'1,		0Ba0G $DI %dii 0DIr2h& 	DIIt,,!$)),	 - !r   c                 
    US L $ r   r2   r   ro   s     r   is_axes_emptyOpRunReduceNumpy.is_axes_empty   s    t|r   c                    [        U[        5      (       a  [        U5      S:X  a  g U$ Uc  g [        U[        [        45      (       a  U$ [        U[        R
                  5      (       d  [        S[        U5       S35      e[        UR                  5      S:X  a  [        U5      $ SUR                  ;   a  g [        UR                  5       R                  5       5      $ )Nr   zaxes must be an array, not .)r?   rs   r,   intrq   rr   r*   r   rN   raveltolistrv   s     r   handle_axesOpRunReduceNumpy.handle_axes   s    dE""4yA~K<dS%L))K$

++9$t*QGHHtzz?at9

?TZZ\((*++r   c                 @    [         R                  " XUS9R                  $ )N)axiskeepdims)rq   sumrN   )r   dataro   r   s       r   output_shapeOpRunReduceNumpy.output_shape   s    vvd9???r   c                 f    U R                  XU5      n[        R                  " XRUR                  S94$ )z<Special case reduction where the output value is a constant.)rA   )r   rq   fullrA   )r   r   	const_valro   r   r   s         r   reduce_constant OpRunReduceNumpy.reduce_constant   s,    ((X>tzzBDDr   )ro   N)r(   r4   r5   r6   r7   r   r   r   r   r   rw   r~   r   r   r8   r2   r   r   rl   rl      s8    
-) -c3h -,"@Er   rl   )typingr   r   numpyrq   onnx.onnx_pbr   onnx.reference.op_runr   r   r	   r:   rD   rS   rZ   ra   rl   r2   r   r   <module>r      sj   
   " 9 6J 6"% "J:K :[ 0'~ ' -Eu -Er   