
    wi@                    B    d dl mZ d dlZd dlmZ  G d de          ZdS )    )annotationsN)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     j/root/.openclaw/workspace/chatterbox_venv_py311/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 ]t	          t          ||d                    }|                    fdt          ||d          D                        	 |                     |          }n8# t          $ r+}t          dt          | j
                   d          |d }~ww xY wt	          t          | j        |d                    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   F)strictc                (    i | ]\  }}||         S r=   r=   )r   namevalueits      r   
<dictcomp>zScan._run.<locals>.<dictcomp>   s3       #e %)  r   zUnable to call 'run' for type 'z'.c                     g | ]
}|         S r=   r=   )r   rA   outputss     r   r   zScan._run.<locals>.<listcomp>   s    @@@gdm@@@r   )axis)r9   shaper    r   dictzipupdate	_run_body	TypeErrorr   r   r"   	enumerateappendnpexpand_dimsvstack_check_and_fix_outputstuple) r   r   r   r   r   r+   r)   r:   r,   r-   _num_scan_outputs_output_directions_max_dir_out_output_axes_max_axe_outr3   r4   r5   r6   r7   r8   max_iterresultsinputsoutputs_lister   rA   resconcrC   rF   s                                  @@r   _runz	Scan._runc   s$   2 #D"D)	
 +,243CA3FG..~...// 	I 	IB#nfUCCCDDFMM   '*=+e'T'T'T    #~~f55   Id49ooIII 
 3t0,uMMMNNG@@@@@@@F$^44 I I4
!!".Q"G"G"GHHHHI  	  	 C9S>>DMM$**5==999s   'B==
C2&C--C2)__name__
__module____qualname__r   r9   ra   r=   r   r   r   r      sd         3  3  3D3
 3
 3
p "#6: 6: 6: 6: 6: 6: 6:r   r   )
__future__r   numpyrP   onnx.reference.op_runr   r   r=   r   r   <module>rh      su    # " " " " "     ' ' ' ' ' 'N: N: N: N: N:5 N: N: N: N: N:r   