
    /j5                    R    d dl mZ d dlZd dlmZ ddZddZ G d de          ZdS )    )annotationsN)OpRunself
np.ndarrayindexreturnc                    g }t          | |d          D ]&\  }}|                    ||d                             't          j        || j                                      |j                  S )NT)strictr   dtype)zipappendnparrayr   reshapeshape)r   r   resabs        j/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/onnx/reference/ops/op_gather_elements.pygather_numpy_2r      sm    
CD%---  1

1QqT78Ctz***225;???    dimintc                   |j         d |         |j         |dz   d          z   }| j         d |         | j         |dz   d          z   }||k    rt          d|d          t          j        | d|          }t          j        |d|          }	 t          j        ||d          }nQ# t          $ rD t          |j                   dk    r*t          |j                   dk    rt          | |          cY S  w xY wt          j        |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_swappedindex_swappedgathereds           r   gather_numpyr)      s:   TcT*U[q-CC*TcT*TZa		-BB0007C 7 7 7
 
 	
 ;tQ,,LKq#..M9]LvFFF   }"##q((S1C-D-D-I-I!$.....
 ;xC(((s   B# #A
C1/C1c                      e Zd ZddZdS )GatherElementsNc                    |j         dk    rt          j        d|j                  fS 	 t	          |||          fS # t
          $ r- t	          |||                    t                              fcY S w xY w)Nr   )r   r   )sizer   emptyr   r)   	TypeErrorastyper   )r   dataindicesaxiss       r   _runzGatherElements._run(   s    <1HT44466	D tW5577 	D 	D 	D tW^^C-@-@AACCCC	Ds   ; 4A21A2)N)__name__
__module____qualname__r4    r   r   r+   r+   '   s.        D D D D D Dr   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+   r8   r   r   <module>r<      s    # " " " " "     ' ' ' ' ' '@ @ @ @) ) ) )*D D D D DU D D D D Dr   