o
    wid                     @  sP   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 deZ
dS )	    )annotationsN)Base)expectc                 C  s.   t j| t jdt j|t jdt j|t jdfS )Ndtype)nparrayint64)indicesinverse_indicescounts r   _/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/onnx/backend/test/case/node/unique.pyspecify_int64   s   r   c                   @  s`   e Zd ZedddZedddZedddZedd	d
ZedddZedddZ	dS )UniquereturnNonec                  C  st   t jjddgg dd} tjg dtjd}t|ddd\}}}}t|||\}}}t| |g||||gdd	 d S )
Nr   XYr
   r   r   )inputsoutputs       @      ?r         @g      @r   r   Ttest_unique_sorted_without_axisr   r   name)	onnxhelper	make_noder   r   float32uniquer   r   node_sortedxyr
   r   r   r   r   r   export_sorted_without_axis   s    


z!Unique.export_sorted_without_axisc                    s   t jjddgg ddd} tjg dtjd}t|ddd\}}}}t|}tt	|t
t| || }tj||dd	}tj fd
d|D tjd}|| }t|||\}}}t| |g||||gdd d S )Nr   r   r   r   r   r   sortedr   r   Taxisc                   s   g | ]} | qS r   r   ).0iinverse_indices_mapr   r   
<listcomp>A   s    z9Unique.export_not_sorted_without_axis.<locals>.<listcomp>#test_unique_not_sorted_without_axisr   )r   r    r!   r   r   r"   r#   argsortdictziparangelentakeasarrayr	   r   r   )node_not_sortedr&   r'   r
   r   r   argsorted_indicesr   r/   r   export_not_sorted_without_axis*   s6   	



z%Unique.export_not_sorted_without_axisc                  C  s   t jjddgg dddd} tjg dg dg dgtjd	}tj|d
d
d
dd\}}}}t|||\}}}|d}t	| |g||||gdd d S )Nr   r   r      r   r   r   r*   r,   r=   r   r   )         r   Tr+   test_unique_sorted_with_axisr   
r   r    r!   r   r   r"   r#   r   reshaper   r$   r   r   r   export_sorted_with_axisW   s&   "



zUnique.export_sorted_with_axisc                  C  s   t jjddgg dddd} tjddgddgddgddggddgddgddgddgggtjd	}tj|d
d
d
dd\}}}}t|||\}}}|d}t	| |g||||gdd d S )Nr   r   r   r=   r>   r   g        r   r   Tr+   rC   test_unique_sorted_with_axis_3dr   rE   r$   r   r   r   export_sorted_with_axis_3dy   s0   



z!Unique.export_sorted_with_axis_3dc                  C  s   t jjddgg dddd} tjg dg dg dgtjd	}tj|d
d
d
dd\}}}}t|||\}}}|d}t	| |g||||gdd d S )Nr   r   r   r=   rC   r>   r?   )r@   rA   rA   r   Tr+   %test_unique_sorted_with_negative_axisr   rE   r$   r   r   r    export_sorted_with_negative_axis   s&   "



z'Unique.export_sorted_with_negative_axisc                  C  s~   t jjddgg ddd} tjdgtjd}t|ddd\}}}}t|||\}}}|d	}t	| |g||||gd
d d S )Nr   r   r   r=   r)   r   r   TrC   test_unique_length_1r   )
r   r    r!   r   r   r	   r#   r   rF   r   r$   r   r   r   export_length_1   s$   




zUnique.export_length_1N)r   r   )
__name__
__module____qualname__staticmethodr(   r<   rG   rI   rK   rM   r   r   r   r   r      s    ,!*"r   )
__future__r   numpyr   r   onnx.backend.test.case.baser   onnx.backend.test.case.noder   r   r   r   r   r   r   <module>   s   