U
    rha                     @  s^   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dddddd	Z	G d
d deZ
dS )    )annotationsN)Base)expectz
np.ndarrayint)datashape	allowzeroreturnc                 C  sD   t |}|dkr4t |dk}t | j| ||< t | |}|S )Nr   )npcopywherearrayr   Zreshape)r   r   r   Z	new_shapeZzeros_indexreshaped r   G/tmp/pip-unpacked-wheel-xnis5xre/onnx/backend/test/case/node/reshape.py reshape_reference_implementation   s    
r   c                   @  s0   e Zd ZeddddZeddddZdS )ReshapeNone)r	   c                  C  s,  dddg} t jdddgt jdt jdddgt jdt jddgt jdt jddddgt jdt jdgt jdt jdddgt jdt jddddgt jdt jdddd	gt jdt jddd	dgt jdd
	}t j| t j}| D ]D\}}tj	j
dddgdgd}t||}t|||g|gd| d qd S )N         Zdtype      r      )	Zreordered_all_dimsZreordered_last_dimsZreduced_dimsZextended_dimsZone_dimZnegative_dimZnegative_extended_dimsZzero_dimZzero_and_negative_dimr   r   r   r   )inputsoutputstest_reshape_r   r   namer
   r   Zint64randomZrandom_sampleZastypeZfloat32itemsonnxhelperZ	make_noder   r   Zoriginal_shapeZ
test_casesr   Z	test_namer   noder   r   r   r   export_reshape   s2    

zReshape.export_reshapec                  C  s   dddg} dt jdddgt jdi}t j| t j}| D ]J\}}tj	j
dddgd	gd
d}t||d
d}t|||g|gd| d q@d S )Nr   r   r   Zallowzero_reorderedr   r   r   r   r   r   )r   r   r   )r   r   r   r!   r&   r   r   r   export_allowzero;   s&    
 zReshape.export_allowzeroN)__name__
__module____qualname__staticmethodr(   r)   r   r   r   r   r      s   r   )r   )
__future__r   Znumpyr
   r$   Zonnx.backend.test.case.baser   Zonnx.backend.test.case.noder   r   r   r   r   r   r   <module>   s    