
    Sic                       S SK Jr  S SKrS SKJrJr  S SKrS SKr\(       a  S SK	J
r
   " S S\5      r " S S\5      r " S	 S
\5      r " S S5      r " S S5      rS S jr\" 5       r " S S5      r " S S5      rS!S jrS"S jr " S S5      r " S S\R2                  5      r " S S\5      r " S S\5      r " S S\5      rg)#    )annotationsN)TYPE_CHECKINGAny)Sequencec                      \ rS rSrSrSrg)RuntimeTypeError   z/Raised when a type of a variable is unexpected. N__name__
__module____qualname____firstlineno____doc____static_attributes__r
       T/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/reference/op_run.pyr   r      s    9r   r   c                      \ rS rSrSrSrg)RuntimeContextError   zfRaised when the context is missing but an context dependent implementation is defined for an operator.r
   Nr   r
   r   r   r   r      s    pr   r   c                      \ rS rSrSrSrg)RuntimeImplementationError   z8Raised when no implementation was found for an operator.r
   Nr   r
   r   r   r   r      s    Br   r   c                      \ rS rSrSrSrg)DefaultNone   zjDefault value for parameters when the parameter is not set but the operator has a default behavior for it.r
   Nr   r
   r   r   r   r      s    tr   r   c                  ,    \ rS rSrSrSS jrSS jrSrg)	RefAttrName!   zqImplements a link between a parameter of a function and an attribute in node.

Args:
    name: name of the input
c                    Xl         g Nname)selfr#   s     r   __init__RefAttrName.__init__(   s    	r   c                P    U R                   R                   SU R                  < S3$ )N())	__class__r   r#   r$   s    r   __repr__RefAttrName.__repr__+   s$    ..))*!DII=::r   r"   N)r#   strreturnr.   )r   r   r   r   r   r%   r,   r   r
   r   r   r   r   !   s    ;r   r   c            
     @   0 n [         R                  R                   R                  R                  5        H  nUR                  U ;   a  UR                  XR                     R                  :w  aB  [        SUR                  < SUR                  < SXR                     R                  < S35      eUR                  XR                     R                  :  a  XUR                  '   OXUR                  '   XUR                  S-   [        UR                  5      -   '   M     U $ )Nz7This function assumes every operator has a unique name z even across multiple domains z and ._)onnxdefsget_all_schemas_with_historyr#   domainNotImplementedErrorsince_versionr.   )resschemas     r   _build_schemasr<   /   s    )+C))..%%BBD;;#}}KK 0 7 77)Mfkk_ ]44:MM3DE#kkJZJaJaIddeg  ##c++&6&D&DD#)FKK %=CFKK#F$8$8 99: E Jr   c                  (    \ rS rSrSS jrSS jrSrg)OnnxTypeE   c                ~    [        U[        R                  5      (       d  [        S[	        U5       S35      eXl        g )Nztype_proto z  must be of type onnx.TypeProto.)
isinstancer4   	TypeProto	TypeErrortype
type_proto)r$   rE   s     r   r%   OnnxType.__init__F   s:    *dnn55d:.//OP  %r   c                $    SU R                   < S3$ )Nz	OnnxType(r)   rE   r+   s    r   r,   OnnxType.__repr__M   s    4??-Q//r   rH   N)rE   zonnx.TypeProtor/   )r   r   r   r   r%   r,   r   r
   r   r   r>   r>   E   s    %0r   r>   c                  F    \ rS rSrSr        SS jr\SS j5       rSrg)	SparseTensorQ   z[Simple representation of a sparse tensor.
It is based on numpy but does not require scipy.
c                (    Xl         X l        X0l        g r!   )valuesindicesshape)r$   rN   rO   rP   s       r   r%   SparseTensor.__init__V   s     
r   c                .    U R                   R                  $ r!   )rN   dtyper+   s    r   rS   SparseTensor.dtype]   s    {{   r   )rO   rP   rN   N)rN   
np.ndarrayrO   rU   rP   z
tuple[int]r0   None)r0   r   )	r   r   r   r   r   r%   propertyrS   r   r
   r   r   rK   rK   Q   s@     +5>H	 ! !r   rK   c                    [        S U R                   5       5      n[        [        R                  R                  U R                  5      [        R                  R                  U R                  5      U5      $ )zHosts a sparse tensor.c              3  $   #    U  H  ov   M     g 7fr!   r
   ).0ds     r   	<genexpr>#to_sparse_tensor.<locals>.<genexpr>d   s     &X!Xs   )tupledimsrK   r4   numpy_helperto_arrayrN   rO   )attrP   s     r   to_sparse_tensorrc   b   sV    &SXX&&E""3::.""3;;/ r   c                    [         R                  R                  S [         R                  R                  S [         R                  R                  S [         R                  R
                  S [         R                  R                  S [         R                  R                  S [         R                  R                  S [         R                  R                  S [         R                  R                  S	 [         R                  R                  S
 [         R                  R                  S [         R                  R                  S [         R                  R                  S [         R                  R                  S 0U    $ )Nc                B    [         R                  " U R                  5      $ r!   )npfloat32frb   s    r   <lambda>0_attribute_conversion_function.<locals>.<lambda>n   s    rzz#%%/@r   c                n    U R                    Vs/ s H  n[        R                  " U5      PM     sn$ s  snf r!   )floatsrf   rg   )rb   rh   s     r   rj   rk   o   s"    

0S
1A
0S0Ss    2c                ,    [        U R                  5      $ r!   )Graphgri   s    r   rj   rk   p   s    uSUU|r   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf r!   )graphsro   )rb   rp   s     r   rj   rk   q   s    3::0N:aq:0N0N   'c                ,    [        U R                  5      $ r!   )intiri   s    r   rj   rk   r   s    SZr   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf r!   )intsru   )rb   rv   s     r   rj   rk   s   s    sxx.Hx!s1vx.H.Hrs   c                ,    [        U R                  5      $ r!   )rc   sparse_tensorri   s    r   rj   rk   t   s    7G8
r   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf r!   )sparse_tensorsrc   rb   ts     r   rj   rk   w   s+    ),););9
);AQ);9
 9
rs   c                8    U R                   R                  S5      $ Nzutf-8)sdecoderi   s    r   rj   rk   z   s    W0Er   c                b    U R                    Vs/ s H  oR                  S5      PM     sn$ s  snf r   )stringsr   )rb   r   s     r   rj   rk   {   s)    '*{{2
'2!HHW{2
 2
s   ,c                T    [         R                  R                  U R                  5      $ r!   )r4   r`   ra   r~   ri   s    r   rj   rk   ~   s    0A0A0J0J3550Qr   c                    U R                    Vs/ s H"  n[        R                  R                  U5      PM$     sn$ s  snf r!   )tensorsr4   r`   ra   r}   s     r   rj   rk      s3    36;;2
3>aD&&q);2
 2
s   );c                ,    [        U R                  5      $ r!   )r>   tpri   s    r   rj   rk      s    HSVV4Dr   c                X    U R                    Vs/ s H  n[        U5      PM     sn$ s  snf r!   )type_protosr>   r}   s     r   rj   rk      s&    !$6
!0AHQK6
 6
rs   )r4   AttributeProtoFLOATFLOATSGRAPHGRAPHSINTINTSSPARSE_TENSORSPARSE_TENSORSSTRINGSTRINGSTENSORTENSORS
TYPE_PROTOTYPE_PROTOS)	attr_types    r   _attribute_conversion_functionr   l   s$   !!#@""$S!!#;""$N!7  "H)) ,
 	** -
 	""$E## &
 	""$Q## &
 	&&(D'' *
-2 3 r   c                  "    \ rS rSrSrSS jrSrg)ro      rp   c                    Xl         g r!   r   )r$   rp   s     r   r%   Graph.__init__   s    r   N)rp   onnx.GraphProtor0   rV   )r   r   r   r   	__slots__r%   r   r
   r   r   ro   ro      s    Ir   ro   c                     \ rS rSrSrSr S     SS jjrS r S     SS jjr\	S 5       r
SS	 jr\	S S
 j5       r\S!S j5       r\S!S j5       r\S"S j5       r\S"S j5       rS#S jrS"S jr\R*                  S 5       rS$S jrSSS.S jr\S 5       r\  S%       S&S jj5       r\   S'         S(S jj5       r\SSS.         S)S jj5       rSrg)*OpRun   a  Ancestor to all operators in this subfolder.

Args:
    onnx_node: `onnx` node
    run_params: additional parameters such as `verbose`, `opsets`
        (it can be more than one if the operator has a subgraph),
        `log` for a logging function
    schema: operator schema
 Nc           	        [        U[        5      (       d  [        S[        U5       S35      eS H$  nXB;  d  M
  [	        SU< S[        U5       S35      e   SU;  a  [        S5      eXl        X l        Uc  [        U R                  S	5      (       a  U R                  R                  U l        O|U R                  R                  [        ;   a#  [        U R                  R                     U l        O;UR                  [        ;   a  [        UR                     U l        OS U l        OX0l        S
U l        U R#                  5         g )Nz$run_params must be a dictionary not r2   )opsetsnew_ops
Attribute z must be in run_params, only z was found.logz#run_params must contains key 'log'.	op_schemaF)rA   dictrC   rD   RuntimeErrorsortedKeyError	onnx_node
run_paramshasattrr*   r   _schemar   _schemasop_typehas_subgraph_load_attributes)r$   r   r   r;   rb   s        r   r%   OpRun.__init__   s    *d++B4
CSBTTUVWW(C$" 'Dj)*+7  ) 
"@AA"$>t~~{33#~~77((H4'(?(?@""h.'	(9(9:#!L!r   c                0    U R                   S   " U/UQ76   g )Nr   )r   )r$   patternargss      r   _log
OpRun._log   s    w..r   c                   UR                   [        R                  R                  :X  a  U R                  R                  SS5      nSU R                  ;   a'  [        U R                  S   R                  5       5      nOSnU R                  R                  SS5      nUc
   SU 35       eU" UR                  U R                  S   [        SU R                  R                  SS5      S	-
  5      Uc  SUS
9$ [        UR                  5       5      US
9$ [        UR                   5      nUb  U" U5      $ Uc[  [        SUR                  < SUR                   < SU R                  R                  < SU R                  R                  < SU S35      e[        SUR                  < SUR                   < SU R                  R                  < SU R                  R                  < SU SU S35      e)z0Converts an attribute value into a python value.r   Nexisting_functionsevaluator_clsz0evaluator_cls must be specified to evaluate att=r   r   verbose   )r   r   r   	functionszUnable to convert attribute z type z from node type z	, domain 
r2   z$Unable to convert default value for )rD   r4   r   r   r   getlistrN   rp   maxr   AttributeErrorr#   r   r   r7   )r$   rb   ref_attr   r   r   conversion_functions          r   _extract_attribute_valueOpRun._extract_attribute_value   s    88t**000oo)))T:G#t6 1E!F!M!M!OP	 	 OO//FM , B3%H, !x0At229a@1DE '#  6:'..:J5K#  =SXXF*&s++? .sxxl& M""&.."8"8!; <..//2"SE<  27<<2B& U"nn447 8nn++.bRyC
 	
r   c                6    UR                  S U =(       d    0 US9$ )N
attributes)runcontextvaluer   s      r   _evaluate_subgraphOpRun._evaluate_subgraph   s    yyw}"yDDr   c                   SU l         / nU R                  R                   H  nUR                  nUR                  (       a  [        UR                  5      nSU l         OU R                  U5      n[        XU5        UR                  U5        UR                  [        R                  R                  :X  d  M  SU l        U =R                   UR                   -  sl         [        U SUR                   3US4S j5        M     U R                  (       Ga;  U R                  R                  S;  Ga   U R                  R                   R#                  5        H  u  pV[%        X5      (       a  M  ['        USS5      (       a(  [)        SU< S	U R                  R                  < S
35      e[%        US5      (       d  Md  UR*                  R                  S:X  d>  UR*                  R                  S:X  a'  UR*                  R,                  R.                  S:X  a  SnOU R                  UR*                  U5      n[        XU5        UR                  U5        M     [1        U5      U l        g)zChecks and loads attributes.FT_run_Nc                .    [         R                  XU5      $ r!   )r   r   r   s      r   rj   (OpRun._load_attributes.<locals>.<lambda>   s    %*%=%=
&r   >   Constantrequiredr   z3 is expected based on ONNX specifications for node r2   default_valuer      )has_linked_attributer   	attributer#   ref_attr_namer   r   setattrappendrD   r4   r   r   r   r   r   r   itemsr   getattrr   r   r~   	data_typesetattributes_names_)r$   added_attributesrb   r#   r   kvs          r   r   OpRun._load_attributes   s   $)!>>++C88D  #C$5$56,0)55c:D&##D)xx4..444$(!))U-G-GG)CHH:&# ,, <<<DNN22,F//557t''q*d33*( .((,(>(>'AD  q/22??//14OO00A5 ! 1 1 ; ;q @ %)E$($A$A!//ST$UE/(//2# 8$ "%%5!6r   c                   [        U [        R                  5      (       d  [        S[	        U 5      < S35      e[        5       n[        5       nU R                   H  nUR                  UR                  5        M      U R                   H  nUR                  UR                  5        M      U R                   H  nUR                  UR                  5        M      U R                   HR  nUR                   H  nUR                  U5        M     UR                   H  nX;  d  M
  UR                  U5        M     MT     [        U5      $ )zReturns all variables not registered as inputs and not produced by
an node inside the graph. This inputs are part of the context
existing in the graph calling this one.
zUnexpected type r2   )rA   r4   
GraphProtorC   rD   r   initializeraddr#   sparse_initializerinputnodeoutputr   )	graphlocalknowninitsparse_initinpr   orv   s	            r   implicit_inputsOpRun.implicit_inputs  s     %11.tE{oQ?@@%%DIIdii  & 33KIIk&&' 4;;CIIchh JJD[[		! !ZZ>IIaL    E{r   c                .    U R                   R                  $ )zReturns node attribute `input`.)r   r   r+   s    r   r   OpRun.input/  s     ~~###r   c                .    U R                   R                  $ )z Returns node attribute `output`.)r   r   r+   s    r   r   OpRun.output4       ~~$$$r   c                .    U R                   R                  $ )z!Returns node attribute `op_type`.)r   r   r+   s    r   r   OpRun.op_type9  s     ~~%%%r   c                .    U R                   R                  $ )z Returns node attribute `domain`.)r   r7   r+   s    r   r7   OpRun.domain>  r  r   c                    g)zTells the runtime if this node needs the context
(all the results produced so far) as it may silently access
one of them (operator Scan, If, Loop).
The default answer is `False`.
Fr
   r+   s    r   need_contextOpRun.need_contextC  s     r   c                   U R                   R                  S-   SU R                  R                   3/n[	        U R
                  R                  5       5       HF  u  p#US;   a  M  SUS   s=::  a  S::  d  M  O  M#  US   S:w  d  M.  UR                  S	U S
U S35        MH     UR                  S5        SR                  U5      $ )Nr(   z    op_type=>   descr   ar   zr3   z    =,r)   r   )	r*   r   r   r   r   __dict__r   r   join)r$   attsr   r   s       r   __str__OpRun.__str__K  s    ''#-dnn>T>T=U/VW4==..01DA))ad!c!!aesld1#QqcO,	 2
 	Cyyr   c                J    [        SU R                  R                  < S35      e)a@  Should be overwritten.

Args:
    *args: operator inputs
    **kwargs: optional inputs and overridden attributes, an
        attribute may be overridden if it belongs to a function,
        in this case, the same instance of OpRun can be called
        with different values of the same attribute.

Returns:
    outputs
z/Method '_run' must be overwritten for operator r2   )r8   r*   r   r$   r   kwargss      r   _run
OpRun._runU  s)     "=dnn>U>U=XXYZ
 	
r   c                   [        U[        5      (       d0  [        SU R                  R                  < S[        U5       S35      eU(       d$  [        SU R                  R                  < S35      e[        S U 5       5      (       aC  U Vs/ s H  n[        U5      PM     nn[        SU R                  R                  < SU< S35      e[        S	 U 5       5      n[        S
 U 5       5      (       aC  U Vs/ s H  n[        U5      PM     nn[        SU R                  R                  < SU< S35      eU$ s  snf s  snf )z-Checks the output are from the expected type.zMethod '_run' of class z does not return a tuple but 'z'.z does not return any result.c              3  B   #    U  H  n[        U[        5      v   M     g 7fr!   )rA   r^   rZ   r~   s     r   r\   /OpRun._check_and_fix_outputs.<locals>.<genexpr>q  s     1Sz!U##Ss   z6One of the results returned by method '_run' of class zg is a tuple, this is no ONNX corresponding type (Map, List, Tensor, SparseTensor). All returned types: r2   c              3     #    U  H8  n[         R                  " U5      (       a  [         R                  " U5      OUv   M:     g 7fr!   )rf   isscalararray)rZ   xs     r   r\   r  x  s,      
<?qBKKNNRXXa[1Cs   A Ac              3     #    U  HB  n[        U[        R                  [        [        45      =(       d    [        US 5      (       + v   MD     g7f)todenseN)rA   rf   ndarrayr   r   r   r  s     r   r\   r  {  s;      
 A

D$78QGAy<QRRs   A
Azs has an unexpected type, this is no ONNX corresponding type (Map, List, Tensor, SparseTensor). All returned types: )rA   r^   rC   r*   r   rD   
ValueErrorany)r$   r:   r~   dtypess       r   _check_and_fix_outputsOpRun._check_and_fix_outputsg  sZ   #u%%)$..*A*A)DDbcghkclbmmop  )$..*A*A)DD`a  1S111'*+s!d1gsF+HI`I`Hc d''-j3 
  
<?
 
  

 
 
 (++s!d1gsF+HI`I`Hc d''-j3 
 
' , ,s   D98D>)linked_attributesr   c               >   U R                  5       (       a  Uc  [        S[        U 5       S35      eOUb  [        S[        U 5       S35      eU R                  (       a  Uc  [	        S[        U 5       S35      eU R                  (       d'  Ub$  [	        S[        U 5       S[        U5       S35      e0 nU R                  (       a  Uc  [        S	[        U 5       S35      eU R                   He  n[        X5      n[        U[        5      (       d  M%  UR                  U;  a   [	        S
U< SU< S[        U 5       S35      eXR                     XE'   Mg     U R                  SU R                  R                  [        U5      5        0 nU R                   HO  nXT;   a  M
  [!        X5      (       d(  [#        SU< SU R                  R                  < S35      e[        X5      Xu'   MQ     U R$                  (       a4  U R                  (       a  U(       d  [        S[        U 5       S35      eXS'   Ub  X'S'    U(       a  U R&                  " U0 UDUD6nOU R&                  " U0 UD6n U R                  SU R                  R                  Ub  [        U5      OS5        U R-                  U5      $ ! [(        [        4 ae  n	[)        SU V
s/ s H  n
[        U
5      PM     Os  sn
f sn
 S[+        U5       S[+        U5       SU R                  R                  < S3	5      U	eSn	A	ff = f)an  Calls method ``_run``, catches exceptions,
displays a longer error message.

Args:
    *args: inputs
    linked_attributes: used if this has an attribute linked to
        the attribute of the function it belongs to
    context: if this node is part of the subgraph, `context` is
        a dictionary with the values this node may use

Returns:
    tuple of results
NzThis node if type z needs context to be filled.z+ does not need any contextbut one is given.z
This node zK has linked attributes but None are given in parameter 'linked_attributes'.zM has no linked attribute but some are given in parameter 'linked_attributes' r2   zBOne attribute is linked but no linked value is provided, in class z,Unable to find a value for linked attribute z in z	 in node z-- begin %s.run(%d inputs)r   z is missing in operator z6A subgraph has linked attribute but none was given to r   r   zIssues with types z and attributes z and linked attributes=z (operator ).z-- done %s.run -> %d outputsr   )r	  r   rD   r   r'  r   r   r   r   rA   r   r#   r   r*   r   lenr   	NameErrorr   r  rC   r   r*  )r$   r,  r   r   overridden_attributesrb   r   r  r:   er3   s              r   r   	OpRun.run  sG    "(d4PQ    $T$ZL0[\  $$):)BT$ZL(st  ((->-JT$ZL )''*+<'=&>aA  !#$$ ($  $T
|1.  --D&a--vv%66(J3'QUVgUj k''+Dzl!5  2C661J). . 			.0G0GTS))C+4%% '?@W@W?ZZ[\  "$,FK * ((1B"LTRVZLXYZ  $5<  '9
	$iiI)>I&Iii00 			*NN##CHQ	

 **3// >* 	$t%<t!d1gt%<$==M&>""9&AV:W9X Y!^^447r; 		s+   2J' J' 'L7
LKALLc                    U R                   nSU;  a   U[        R                  R                  5       4$ UR	                  SS5      u  p [        U5      nX4$ ! [         a-    U R                   [        R                  R                  5       4s $ f = f)Nr3      )r   r4   r5   onnx_opset_versionrsplitru   r'  )clsr#   versi_verss       r   
infer_nameOpRun.infer_name  s    ||d?55777[[a(
	@YF |  	@<<!=!=!???	@s   A 4BBc                   U R                  5       u  pEU R                  nSnUc/  Uc   [        R                  R	                  XEU5      nUR
                  nUc/  Uc   [        R                  R	                  XEU5      nUR                  n[        U5       Vs/ s H  nSU 3PM
     n	n[        U5       Vs/ s H  nSU 3PM
     n
n[        R                  R                  " XIU
40 UD6$ s  snf s  snf )at  Creates an ONNX node for this class based on the given information.

Args:
    n_inputs: number of inputs (default is defined by the
        operator schema)
    n_outputs: number of outputs (default is defined by the
        operator schema)
    verbose: verbosity
    **kwargs: node attributes

Returns:
    NodeProto

Method :meth:`eval <onnx.reference.op_run.OpRun.eval>` creates an onnx node
returned by method :meth:`make_node <onnx.reference.op_run.OpRun.make_node>`.

.. exec_code::

    import numpy as np
    from onnx.reference.ops._op_list import Celu

    onnx_node = Celu.make_node(alpha=0.5)
    print(onnx_node)
Nr#  y)
r;  	op_domainr4   r5   
get_schema	min_input
min_outputrangehelper	make_node)r8  n_inputs	n_outputsr  r   opsetr7   r;   rv   names_in	names_outs              r   rE  OpRun.make_node  s    > )~--gfE''H~--gfE))I%*8_5_asG_5&+I&67&6qW&6	7{{$$W	LVLL 67s   C#0C(r   c                   ^ SU4S jjnU R                   " X40 UD6nTUSS[        R                  R                  5       0S.nU " Xg5      $ )a4  Instantiates this class based on the given information.

Args:
    n_inputs: number of inputs (default is defined by the
        operator schema)
    n_outputs: number of outputs (default is defined by the
        operator schema)
    verbose: verbosity
    **kwargs: node attributes

Returns:
    NodeProto
c                B   > TS:  a  [        U [        U5      -  5        g g )Nr5  )printr^   )r   r   r   s     r   log_function"OpRun.create.<locals>.log_function-  s     {gd+, r   Nr   )r   r   r   r   )r   r.   r   r   r0   rV   )rE  r4   r5   r6  )r8  rF  rG  r   r  rO  r   r   s      `    r   createOpRun.create  sO    ,	- }}X;F;499779:	

 4$$r   rG  r   c                   U R                   " [        U5      4XS.UD6nUR                  " U6 n[        U5      S:X  a  US   $ U$ )zEvaluates this operator.

Args:
    *args: inputs
    n_outputs: number of outputs (default is defined by the
        operator schema)
    verbose: verbosity
    **kwargs: node attributes

Returns:
    NodeProto
rS  r5  r   )rQ  r/  r   )r8  rG  r   r   r  instr:   s          r   eval
OpRun.eval:  sF    ( zz#d)TyTVThhos8q=q6M
r   )r   r   r   r   r   r   r!   )r   onnx.NodeProtor   zdict[str, Any]r;   r   )rb   onnx.AttributeProtor   zonnx.AttributeProto | Noner0   r   )r0   rV   )r   r   r0   z	list[str])r0   zSequence[str]r/   )r0   bool)r:   tuple[Any, ...]r0   r[  NN)rF  
int | NonerG  r]  r  r   r0   rX  )NNr   )
rF  r]  rG  r]  r   ru   r  r   r0   r   )
r   z	list[Any]rG  r]  r   ru   r  r   r0   r   )r   r   r   r   r   r?  r%   r   r   staticmethodr   r   r   rW   r   r   r   r7   r	  r  abcabstractmethodr  r*  r   classmethodr;  rE  rQ  rV  r   r
   r   r   r   r      s    I TX ' 5C MP :/ OS%
&%
1K%
	%
N E E-7^  . $ $ % % & & % % 	
 
"@ ,0 S0j 	 	   $ $,M,M ,M 	,M
 
,M ,M\   $ $	 % %  % 	 %
  % 
 %  %D  !%	  	
  
 r   r   c                  $    \ rS rSrSrS rS rSrg)OpRunExpandiU  z.Class any operator to avoid must inherit from.c                2    [        S[        U 5       S35      eNz5The reference implementation must not use this node (r.  r   rD   r  s      r   r%   OpRunExpand.__init__X      CDJ<rR
 	
r   c                2    [        S[        U 5       S35      ere  rf  r$   inputsr  s      r   r  OpRunExpand._run]  rh  r   r
   Nr   r   r   r   r   r%   r  r   r
   r   r   rc  rc  U  s    8


r   rc  c                  H    \ rS rSrSr  S         S	S jjrS rS rSrg)

OpFunctionic  zRuns a custom function.Nc                
   Uc(  [        SUR                  < SUR                  < S35      e[        R	                  XU5        X0l        [        U R
                  SU5       Vs0 s H  nU[        X5      _M     snU l        g s  snf )Nz"impl cannot be None for node type  from domain r2   attributes_)r   r   r7   r   r%   impl_r   rr  )r$   r   r   implr   r#   s         r   r%   OpFunction.__init__f  s     <4Y5F5F4I J(//2!5  	t
3

  

M:F
F '$%%F
 
s   !B c                B    U R                   " U R                  /UQ70 UD6$ r!   )	_run_implrs  rj  s      r   r  OpFunction._run{  s    ~~djj<6<V<<r   c                z   [        UR                  5      [        U5      :w  aJ  [        S[        U5       S[        UR                  5       SU R                  < SU R                  < S3	5      e[        [        UR                  USS95      nU R                  R                  5       nUR                  U5        UR                  S XES9n[        UR                  5      [        U5      :w  aJ  [        S	[        U5       S
[        UR                  5       SU R                  < SU R                  < S3	5      e[        U5      $ )Nz.Mismatch lengths between the number of inputs z# and the expected number of inputs z
 for node rq  r2   F)strictr   z/Mismatch lengths between the number of outputs z$ and the expected number of outputs )r/  input_namesr   r   r7   r   ziprr  copyupdater   output_namesr^   )r$   rt  rk  r  feedsr   resultss          r   rw  OpFunction._run_impl~  s-   t CK/@V N5589I9I5J4K L LL+=qJ 
 S))6%@A%%**,
&!((4(>t  !S\1A#g, P669$:K:K6L5M N LL+=qJ 
 W~r   )rr  rs  r\  )
r   rX  r   dict[str, Any] | Nonert  r   r   r  r0   rV   )	r   r   r   r   r   r%   r  rw  r   r
   r   r   ro  ro  c  sL    ! ,0
!
 *
 	

 *
 

*=r   ro  c                  8    \ rS rSrSr S     SS jjrS rSrg)	OpFunctionContextDependanti  zThe function can be instantiated but only at execution time.
An instance of OpFunction is created everytime to node is executed.
This is needed when the schema of an operator defines a context dependent function.
Nc                    [         R                  XX 0 S9  X0l        UR                  UR                     n[
        R                  R                  UR                  XAR                  5      U l	        g )N)rt  r   )
ro  r%   parentr   r7   r4   r5   r@  r   schema_)r$   r   r   r  versions        r   r%   #OpFunctionContextDependant.__init__  sY     	DZrR--	 0 01yy++w(8(8
r   c                   / nU Hd  n[         R                  R                  UR                  5      nUR	                  [         R                  R                  XTR                  5      5        Mf     U R                  R                  U R                  U5      nU" U R                  U R                  5      nU R                  " UR                  /UQ70 UD6$ r!   )r4   rD  np_dtype_to_tensor_dtyperS   r   make_tensor_type_protorP   r  
_load_implr   r   rw  rs  )r$   rk  r  typesr~   rS   clrU  s           r   r  OpFunctionContextDependant._run  s     AKK88AELL;;E77KL  [[##DNNE:$..$//2~~djj<6<V<<r   )r  r  r!   )r   rX  r   r  r  r   rm  r
   r   r   r  r    s2     	
!
 *
 	
	=r   r  )r0   zdict[str, onnx.defs.OpSchema])rb   rY  r0   rK   )r   z!onnx.AttributeProto.AttributeType)
__future__r   r_  typingr   r   numpyrf   r4   collections.abcr   r   r   r   r8   r   r   r   r<   r   r>   rK   rc   r   ro   ABCr   rc  ro  r  r
   r   r   <module>r     s    # 
 %  (:| :q, qC!4 Cu u; ;& 	0 	0! !": BCGG BJ
% 
, ,^= =r   