
    bIg2                    J    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y)
    )annotationsN)OpRunc                    g }t        | |      D ]  \  }}|j                  ||d              t        j                  || j                        j                  |j                        S )Nr   dtype)zipappendnparrayr   reshapeshape)selfindexresabs        b/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/reference/ops/op_gather_elements.pygather_numpy_2r      sY    
CD%  1

1QqT788Ctzz*225;;??    c                   |j                   d | |j                   |dz   d  z   }| j                   d | | j                   |dz   d  z   }||k7  rt        d|d      t        j                  | d|      }t        j                  |d|      }	 t        j                  ||d      }t        j                  |d|      S # t        $ r@ t        |j                         dk(  r&t        |j                         dk(  rt        | |      cY S  w xY w)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   dimr   idx_xsection_shapeself_xsection_shapedata_swapedindex_swapedgathereds           r   gather_numpyr%      s   Tc*U[[q-CC**Tc*TZZa	-BB00#C7 +6 7
 	
 ++dAs+K;;ua-L99\;VD ;;xC((  |!!"a'C0A0A,Ba,G!$..s   B7 7AD >D c                      e Zd ZddZy)GatherElementsNc                    |j                   dk(  r"t        j                  d|j                        fS 	 t	        |||      fS # t
        $ r$ t	        |||j                  t                    fcY S w xY w)Nr   )r   r   )sizer
   emptyr   r%   	TypeErrorastypeint)r   dataindicesaxiss       r   _runzGatherElements._run(   sj    <<1HHT466	D tW577 	D tW^^C-@ACC	Ds   A *A.-A.)N)__name__
__module____qualname__r1    r   r   r'   r'   '   s    Dr   r'   )r   
np.ndarrayr   r6   returnr6   )r   r6   r   r-   r   r6   r7   r6   )	
__future__r   numpyr
   onnx.reference.op_runr   r   r%   r'   r5   r   r   <module>r;      s)    #  '@)*DU Dr   