
    bIg                    f    d dl mZ d dlZd dlZd dlmZ d dlmZ 	 	 	 	 	 	 	 	 ddZ	 G d de      Z
y)	    )annotationsN)Base)expectc                r   t        | j                        }|j                  d   |k  sJ g }d}t        |      D ]2  }|j                  |j                  |          ||j                  |   z  }4 |j                  d   ||z
  k(  r|t	        |j                        |d z   nC|t	        |j                        |d z   t	        | j                        ||j                  d   z   d  z   }g }|j                  |d|j                  d         }	| j                  |f| j                  |d  z         }
t        |	j                  d         D ]H  }t        |	j                  d         D ]+  }t        |	|   |         }|j                  |
|g|          - J t        j                  || j                        j                  |      S )N   r   dtype)
lenshaperangeappendlistreshapetuplenpasarrayr
   )dataindices
batch_dims	data_rankbatch_dims_shapebatch_dims_sizeioutput_shapeoutput_data_bufferreshaped_indicesreshaped_data	batch_dim	outer_dimgather_indexs                 a/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/backend/test/case/node/gathernd.pygather_nd_implr#      s    DJJI ==	)))  O : ,a 017==++, MM"Z!77 	4.z"==
w}}
j
,-
tzz
:b(99;
<=   GMM"<MN LL/!3djj6M!MNM +11!45 Q	/55a89 	QI !1)!<Y!GHL%%mY4N4N&OP	QQ ::(

;CCLQQ    c                  B    e Zd Zedd       Zedd       Zedd       Zy)GatherNDc                    t         j                  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       y )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 % 
 xx!Q!Q(9((QFQF+288<gq1((Aq6:~~fo666'?H.		
r$   c                    t         j                  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       y )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_float32R   s    {{$$I&J % 
 xx1a&1a&)QFQF+;<BJJO((aVH1vh/rxx@gq1((aVH1vh#7rzzJ~~fo666'?H0		
r$   c                    t         j                  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       y )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_1f   s    {{$$I&J	 % 
 xx1a&1a&)QFQF+;<BHHM((QC!:RXX6gq1((QFQF#3288D~~fo666'?H9		
r$   N)returnNone)__name__
__module____qualname__staticmethodr<   rD   rG    r$   r"   r&   r&   =   s<    
 
& 
 
& 
 
r$   r&   )r   
np.ndarrayr   rO   r   intrH   rO   )
__future__r   numpyr   r2   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r#   r&   rN   r$   r"   <module>rU      sM    #   , .-R
-R)-R7:-R-R`<
t <
r$   