o
    toi/                     @  sH   d dl mZ d dlZd dlmZ ddd	ZdddZG dd deZdS )    )annotationsN)OpRunself
np.ndarrayindexreturnc                 C  sF   g }t | |ddD ]\}}|||d   q	tj|| jd|jS )NT)strictr   dtype)zipappendnparrayr
   reshapeshape)r   r   resab r   Y/home/ubuntu/.local/lib/python3.10/site-packages/onnx/reference/ops/op_gather_elements.pygather_numpy_2   s   r   dimintc                 C  s   |j d | |j |d d   }| j d | | j |d d   }||kr,td|dt| d|}t|d|}z
tj||dd}W n tya   t|j dkr`t|j dkr`t| | Y S  w t|d|S )N   zExcept for dimension z;, all dimensions of index and self should be the same size.r   wrap)mode   )r   
ValueErrorr   swapaxeschooselenr   )r   r   r   idx_xsection_shapeself_xsection_shapedata_swapedindex_swapedgatheredr   r   r   gather_numpy   s      
r&   c                   @  s   e Zd ZdddZdS )GatherElementsNc              	   C  sT   |j dkrtjd|jdfS zt|||fW S  ty)   t|||tf Y S w )Nr   )r   r	   )sizer   emptyr
   r&   	TypeErrorastyper   )r   dataindicesaxisr   r   r   _run(   s   
zGatherElements._run)N)__name__
__module____qualname__r/   r   r   r   r   r'   '   s    r'   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )	
__future__r   numpyr   onnx.reference.op_runr   r   r&   r'   r   r   r   r   <module>   s   

