o
    toiv                     @  s4   d dl mZ d dlZd dlmZ G dd deZdS )    )annotationsN)OpRunc                   @  s   e Zd ZdddZdS )TensorScatterNlinearc                 C  sb  |dvrt d| |d u rtj|jd ftjd}|j}|j}|t| }tt|D ]2}||krH|| || krHt d| d| d| ||kr_|| || k r_t d| d| dq-|| }	|| }
t|}t|d | D ]4}|d }t|
D ])}g ||| | R }|d	krt	t
t||	}g ||R }|| ||< qqv||fS )
N>   r   circularzUnsupported mode: r   )dtypezInput shape z and update shape z! are not compatible in dimension z% are not compatible in axis dimensionr   )
ValueErrornpzerosshapeint64lenrangecopyndindextuplemodasarrayreshape)self
past_cacheupdatewrite_indicesmodeaxisinput_shapeupdate_shapeimax_sequence_lengthsequence_lengthpresent_cache
prefix_idx	batch_idxsequence_idx	cache_idx
update_idx r'   X/home/ubuntu/.local/lib/python3.10/site-packages/onnx/reference/ops/op_tensor_scatter.py_run   sD   
	zTensorScatter._run)Nr   r   )__name__
__module____qualname__r)   r'   r'   r'   r(   r      s    r   )
__future__r   numpyr
   onnx.reference.op_runr   r   r'   r'   r'   r(   <module>   s   