o
    wi                     @  s>   d dl mZ d dlZd dlmZ dddZG dd deZdS )    )annotationsN)OpRundata
np.ndarrayindices
batch_dimsintreturntuple[np.ndarray]c                 C  s0  t | j}g }d}t|D ]}||j|  ||j| 9 }q|jd || kr3|t|j|d  n|t|j|d  t| j||jd  d   }g }||d|jd }	| |f| j|d   }
t|	jd D ]}t|	jd D ]}t|	| | }||
|g|R   quqltj|| j	d|fS )N   r   )dtype)
lenshaperangeappendlistreshapetuplenpasarrayr   )r   r   r   	data_rankbatch_dims_shapebatch_dims_sizeioutput_shapeoutput_data_bufferreshaped_indicesreshaped_data	batch_dim	outer_dimgather_index r"   [/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/onnx/reference/ops/op_gathernd.py_gather_nd_impl   s.   
	r$   c                   @  s   e Zd ZdddZdS )GatherNDNc                 C  s   t |||S N)r$   )selfr   r   r   r"   r"   r#   _run9   s   zGatherND._runr&   )__name__
__module____qualname__r(   r"   r"   r"   r#   r%   8   s    r%   )r   r   r   r   r   r   r	   r
   )
__future__r   numpyr   onnx.reference.op_runr   r$   r%   r"   r"   r"   r#   <module>   s
   
-