
    
Ng                     6    d dl Zd dlmZ  G d de          ZdS )    N)OpRunc                   2    e Zd Zd Zd ZdddddddddZdS )Scanc                 $    t          j         ||           t           j        d          s%t	          dt           j                   d           fdt           j                  D              _        t           j                  }|dk    rt	          d           fdt           j                  D              _
        t           j
                  }|dk    rt	          d           j        j         _         j        j         _        d S )	Nrunz0Parameter 'body' must have a method 'run', type .c                 l    g | ]0}j         |t          j                   k    rdnj         |         1S Nr   )scan_input_directionslen.0iselfs     V/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/reference/ops/op_scan.py
<listcomp>z!Scan.__init__.<locals>.<listcomp>   s[     "
 "
 "
 	 -5D67777  /2"
 "
 "
    r   z@Scan is not implemented for other output input_direction than 0.c                 l    g | ]0}j         |t          j                   k    rdnj         |         1S r
   )scan_input_axesr   r   s     r   r   z!Scan.__init__.<locals>.<listcomp>    sX     
 
 
  '/1D<P8Q8Q3Q3Q )!,	
 
 
r   z4Scan is not implemented for other input axes than 0.)r   __init__hasattrbodyRuntimeErrortyperangenum_scan_inputsinput_directions_maxinput_axes_input_namesoutput_names)r   	onnx_node
run_params
max_dir_in
max_axe_ins   `    r   r   zScan.__init__   s=   tY
333ty%(( 	U4	??UUU  "
 "
 "
 "
 4/00"
 "
 "
 /00
??R  
 
 
 
 4/00
 
 
 )**
??UVVV90 I2r   c                 2    t          |           j        z
  }t          |          |z
  } fdt          |          D             }t          |          }|dk    rt	          d           fdt          |          D             }t          |          }|dk    rt	          d           j        d  j                 } j        d t          |                   }	 j        |d          }
 j        |d          }||d          }|d |         }||||||||	|
|||fS )Nc                 l    g | ]0}j         |t          j                   k    rdnj         |         1S r
   )scan_output_directionsr   r   s     r   r   z*Scan._common_run_shape.<locals>.<listcomp>2   s[     
 
 
 	 .6D78888  03
 
 
r   r   zAScan is not implemented for other output output_direction than 0.c                 l    g | ]0}j         |t          j                   k    rdnj         |         1S r
   )scan_output_axesr   r   s     r   r   z*Scan._common_run_shape.<locals>.<listcomp>@   sX     
 
 
  (0AT=R9S9S4S4S *1-	
 
 
r   z5Scan is not implemented for other output axes than 0.)r   r   r   r   r   r    r!   )r   argsnum_loop_state_varsnum_scan_outputsoutput_directionsmax_dir_outoutput_axesmax_axe_outstate_names_instate_names_outscan_names_inscan_names_outscan_valuesstatess   `             r   _common_run_shapezScan._common_run_shape.   s   !$ii$*>>t99'::
 
 
 
 +,,
 
 
 +,,!S  
 
 
 
 +,,
 
 
 +&&!VWWW)*@D,@*@A+,Ac..A.A,AB()<)=)=>*+>+?+?@.//0***+  
 	
r   N)r   r   r   r   r*   r(   
attributesc                \     | j         | \  }	}
}}}}}}}}}}||	         j        | j        d                  }d |D             }t          |          D ]
}i }t	          ||          D ]
\  }}|||<   t	          ||          D ]\  }}||         ||<   	 |                     |          }n8# t          $ r+}t          dt          | j                   d          |d }~ww xY wt          t	          | j
        |                      fd|D             }t          |          D ]:\  }}||                             t          j         |         d                     ;|D ]+}t          j        |          }|                    |           ,|                     t#          |                    S )Nr   c                     g | ]}g S  r<   )r   _s     r   r   zScan._run.<locals>.<listcomp>   s    ...!2...r   zUnable to call 'run' for type 'z'.c                      g | ]
}|         S r<   r<   )r   nameoutputss     r   r   zScan._run.<locals>.<listcomp>   s    @@@gdm@@@r   )axis)r8   shaper   r   zip	_run_body	TypeErrorr   r   dictr!   	enumerateappendnpexpand_dimsvstack_check_and_fix_outputstuple)!r   r   r   r   r   r*   r(   r9   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   max_iterresultsitinputsr?   valueoutputs_lister   resconcr@   s!                                   @r   _runz	Scan._runc   s   2 #D"D)	
 +,243CA3FG..~...// 	I 	IBF">6:: % %e$t"=+>> ) )e$Ryt#~~f55   Id49ooIII 
 3t0,??@@G@@@@@@@F$^44 I I4
!!".Q"G"G"GHHHHI  	  	 C9S>>DMM$**5==999s   B**
C4&CC)__name__
__module____qualname__r   r8   rW   r<   r   r   r   r      sd         3  3  3D3
 3
 3
p "#4: 4: 4: 4: 4: 4: 4:r   r   )numpyrI   onnx.reference.op_runr   r   r<   r   r   <module>r]      sc        ' ' ' ' ' 'L: L: L: L: L:5 L: L: L: L: L:r   