
    
Ng                     6    d dl Zd dlmZ  G d de          ZdS )    N)OpRunc                   0    e Zd Zd ZdefdZdddddZdS )Loopc                 l   t          j        | ||           d| j        vrt          d          d|vrt          d          d t	          | j        j                  D             | _        t          | j        j	                  dz
  | _
        t          | j        j                  | j
        z
  dz
  | _        d S )Nopsetsz&run_params must contains key 'opsets'.verbosez'run_params must contains key 'verbose'.c                     i | ]\  }}||	S  r
   ).0ins      V/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/reference/ops/op_loop.py
<dictcomp>z!Loop.__init__.<locals>.<dictcomp>   s    PPPdaQPPP          )r   __init__
run_paramsKeyError	enumeratebodyoutput_namesoutput_indexleninput_namesNK)self	onnx_noder   s      r   r   zLoop.__init__   s    tY
3334?**CDDDJ&&DEEEPPi	8N.O.OPPPTY*++a/TY+,,tv59r   returnc                     dS )zThe operator Loop needs to know all results produced
        so far as the loop may silently access one of them.
        Some information are not always referred in the list of inputs
        (kind of static variables).
        Tr
   )r   s    r   need_contextzLoop.need_context   s	     tr   N)contextr   
attributesc                   |r|d         }|dd          }nd }|0t          |d          s t          dt          |           d          | j        }|j        }d |D             |||d         <   |j        d         }	|rDt          |          t          |          z
  }
||
d          }t          ||          D ]
\  }}||<   ||D ]}||         |<   d t          | j	                  D             }d}|r|||k     r| 
                    d	|           t          |j                  dk    r:|j        d         -t          j        ||d n|j        
          |j        d         <   t          |j                  dk    r|j        d         ||j        d         <   |                     |          }| j	        dk    rAt          | j	                  D ],}||                             || j	         |z                       -| j        |	         }||         }|t#          d|	d          t          |j        dd          |j        dd                    D ]\  }}|| j        |                  |<   |dz  }| 
                    d           |r
|||k     |dk    rfd|j        dd          D             }n|dd| j        z            }|                    d |D                        t          |          t          | j        j                  k     rR|                    t          j        d                     t          |          t          | j        j                  k     Rt/          |          }|                     |          S )Nr   r   dtypez,M must be empty or an array but its type is .c                     i | ]}|d S )Nr
   )r   names     r   r   zLoop._run.<locals>.<dictcomp>(   s    555$555r   r   c                     g | ]}g S r
   r
   )r   r   s     r   
<listcomp>zLoop._run.<locals>.<listcomp>5   s    444"444r   z  -- loop> {%r})r&   )r$   z
Condition z) returned by the subgraph cannot be None.z
  -- loop<c                      g | ]
}|         S r
   r
   )r   r   inputss     r   r+   zLoop._run.<locals>.<listcomp>M   s    ???Qvay???r   c                 6    g | ]}t          j        |          S r
   )npvstack)r   xs     r   r+   zLoop._run.<locals>.<listcomp>P   s     ===	!===r   r
   )shape)hasattr	TypeErrortyper   r   r   r   zipranger   _logr/   arrayr&   	_run_bodyappendr   RuntimeErrorr   extendr   outputemptytuple_check_and_fix_outputs)r   Mcondr#   r   r$   args	v_initialloop_inputs	cond_namebegin
all_inputsr)   valak_carried_awayitoutputsk
index_condr   oresr-   s                          @r   _runz	Loop._run   s    	QI8DDI=G!4!4=U4PQ77UUUVVVy&55555 %.F;q>"%a(	 	#$$s4yy0E$UVV,J T22 # #	c"t ' '#AJq		44eDFmm444 	$	R!VVII'1114#$$q((T-=a-@-L.0hrXYX_.`.`.`t'*+4#$$q((T-=a-@-L.2t'*+nnV
nCCGvzztv C CA"1%,,WdfWq[-ABBBB*95J:&D|"WWWW   D,QRR0$2CABB2GHH : :1#D$5a$89q		!GBIIl###'  	$	R!VV* 77????$*:122*>???GGa!df*n-G==n===>>>'llS!67777NN28"---... 'llS!67777Gnn**3///r   )__name__
__module____qualname__r   boolr"   rS   r
   r   r   r   r      s`        : : :d     ,0dt 60 60 60 60 60 60 60r   r   )numpyr/   onnx.reference.op_runr   r   r
   r   r   <module>rZ      sc        ' ' ' ' ' 'I0 I0 I0 I0 I05 I0 I0 I0 I0 I0r   