
    bIgt                    :    d dl mZ d dlZd dlmZ  G d de      Zy)    )annotationsN)OpRunc                  0    e Zd Zd Zd ZdddddddddZy)Scanc                "   t        j                  | ||       t        | j                  d      s"t	        dt        | j                         d      t        | j                        D cg c]7  }| j                  |t        | j                        k\  rdn| j                  |   9 c}| _
        t        | j                        }|dk7  rt	        d      t        | j                        D cg c]7  }| j                  |t        | j                        k\  rdn| j                  |   9 c}| _        t        | j                        }|dk7  rt	        d      | j                  j                  | _        | j                  j                  | _        y c c}w c c}w )Nrunz0Parameter 'body' must have a method 'run', type .r   z@Scan is not implemented for other output input_direction than 0.z4Scan is not implemented for other input axes than 0.)r   __init__hasattrbodyRuntimeErrortyperangenum_scan_inputsscan_input_directionsleninput_directions_maxscan_input_axesinput_axes_input_namesoutput_names)self	onnx_node
run_paramsi
max_dir_in
max_axe_ins         W/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/reference/ops/op_scan.pyr
   zScan.__init__   s|   tY
3tyy%(B4		?BSSTU  4//0"
 	 --5D6677  //23"
 //0
?R  4//0
  ''/1D<P<P8Q3Q ))!,-
 ))*
?UVV9900 II225"

s   '<F'<Fc                   t        |      | j                  z
  }t        |      |z
  }t        |      D cg c]7  }| j                  |t        | j                        k\  rdn| j                  |   9 }}t	        |      }|dk7  rt        d      t        |      D cg c]7  }| j                  |t        | j                        k\  rdn| j                  |   9 }}t	        |      }|dk7  rt        d      | j                  d | j                   }	| j                  d t        |	       }
| j                  |d  }| j                  |d  }||d  }|d | }|||||||	|
||||fS c c}w c c}w )Nr   zAScan is not implemented for other output output_direction than 0.z5Scan is not implemented for other output axes than 0.)	r   r   r   scan_output_directionsr   r   scan_output_axesr   r   )r   argsnum_loop_state_varsnum_scan_outputsr   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   !$i$*>*>>t9':: +,
 	 ..6D7788  0034
 
 +,!S  +,
  ((0AT=R=R9S4S **1-.
 
 +&!VWW))*@D,@,@A++,Ac..AB(()<)=>**+>+?@./0**+  
 	
E

s   <E<EN)r   r   r   r   r"   r!   
attributesc               2    | j                   | \  }	}
}}}}}}}}}}||	   j                  | j                  d      }|D cg c]  }g  }}t        |      D ]  }i }t	        ||      D ]
  \  }}|||<    t	        ||      D ]  \  }}||   ||<    	 | j                  |      }t        t	        | j                  |            }|D cg c]  }||   	 }}t        |      D ]1  \  }}||   j                  t        j                  ||   d             3  |D ](  } t        j                  |       }!|j                  |!       * | j!                  t#        |            S c c}w # t        $ r(}t        dt        | j                         d      |d }~ww xY wc c}w )Nr   zUnable to call 'run' for type 'z'.)axis)r0   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!   r1   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   max_iter_resultsitinputsnamevalueoutputs_listeoutputsr   resconcs"                                     r   _runz	Scan._runc   s   2 #D""D)	
 +,2243C3CA3FG-.!2../ 	IBF">6: %e$t%"=+> )e$Ryt)#~~f5 3t00,?@G0?@gdm@F@$^4 I4
!!"..Q"GHI!	I&  	 C99S>DMM$	  **5=991 /  5d499o5FbI As$    	EE F 	F)#FF)__name__
__module____qualname__r
   r0   rL        r   r   r      s*     3D3
p "#4:rQ   r   )
__future__r   numpyr;   onnx.reference.op_runr   r   rP   rQ   r   <module>rU      s    #  'L:5 L:rQ   