
    Ng                         d dl Zd dlZd dlmZ d dlmZ dej        dej        dedej        fdZ	 G d	 d
e          Z
dS )    N)Base)expectdataindices
batch_dimsreturnc                    t          | j                  }|j        d         |k    sJ g }d}t          |          D ]2}|                    |j        |                    ||j        |         z  }3|j        d         ||z
  k    r|t	          |j                  |d         z   nI|t	          |j                  |d         z   t	          | j                  ||j        d         z   d          z   }g }|                    |d|j        d                   }	|                     |f| j        |d          z             }
t          |	j        d                   D ]Y}t          |	j        d                   D ]<}t          |	|         |                   }|                    |
|g|R                     =Zt          j        || j	                                      |          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_indexs                 `/var/www/html/ai-engine/env/lib/python3.11/site-packages/onnx/backend/test/case/node/gathernd.pygather_nd_implr#      s    DJI =	))))  O : , ,a 01117=++ M"Z!777 	4..z"}===
w}

jm
,-
tz

:b(99;;
<=   GM"<MNN LL/!3dj6M!MNNM +1!455 Q Q	/5a899 	Q 	QI !1)!<Y!GHHL%%mY4N4N4N&OPPPP	Q :(
;;;CCLQQQ    c                   V    e Zd Zedd            Zedd            Zedd            ZdS )GatherNDr   Nc                     t           j                            dddgdg          } t          j        ddgdd	ggt          j        
          }t          j        ddgddggt          j        
          }t          ||d          }t          j        dd	gt          j        
          }t          j        ||          sJ t          | ||g|gd           d S )Nr&   r   r   outputinputsoutputsr   r         r   test_gathernd_example_int32r*   r+   name
onnxhelper	make_noder   arrayint32int64r#   array_equalr   noder   r   r(   expected_outputs        r"   export_int32zGatherND.export_int32=   s    {$$I&J % 
 
 x!Q!Q(999(QFQF+28<<<gq11(Aq6:::~fo66666'?H.		
 	
 	
 	
 	
 	
r$   c                     t           j                            dddgdg          } t          j        ddgdd	ggd
dgddgggt          j                  }t          j        ddggddgggt          j                  }t          ||d          }t          j        dd	ggd
dgggt          j                  }t          j        ||          sJ t          | ||g|gd           d S )Nr&   r   r   r(   r)   r   r   r,   r-               r   test_gathernd_example_float32r/   )
r2   r3   r4   r   r5   float32r7   r#   r8   r   r9   s        r"   export_float32zGatherND.export_float32Q   s   {$$I&J % 
 
 x1a&1a&)QFQF+;<BJOOO(aVH1vh/rx@@@gq11(aVH1vh#7rzJJJ~fo66666'?H0		
 	
 	
 	
 	
 	
r$   c                     t           j                            dddgdgd          } t          j        ddgdd	ggd
dgddgggt          j                  }t          j        dgdggt          j                  }t          ||d          }t          j        dd	gd
dggt          j                  }t          j        ||          sJ t          | ||g|gd           d S )Nr&   r   r   r(   r   )r*   r+   r   r   r,   r-   r>   r?   r@   rA   r   &test_gathernd_example_int32_batch_dim1r/   r1   r9   s        r"   export_int32_batchdim_1z GatherND.export_int32_batchdim_1e   s   {$$I&J	 % 
 
 x1a&1a&)QFQF+;<BHMMM(QC!:RX666gq11(QFQF#328DDD~fo66666'?H9		
 	
 	
 	
 	
 	
r$   )r   N)__name__
__module____qualname__staticmethodr<   rD   rG    r$   r"   r&   r&   <   sr        
 
 
 \
& 
 
 
 \
& 
 
 
 \
 
 
r$   r&   )numpyr   r2   onnx.backend.test.case.baser   onnx.backend.test.case.noder   ndarrayintr#   r&   rL   r$   r"   <module>rR      s   
      , , , , , , . . . . . .-R
*-R!z-R7:-RZ-R -R -R -R`<
 <
 <
 <
 <
t <
 <
 <
 <
 <
r$   