U
    rh                     @  sH   d dl mZ d dlZd dlZd dlmZ d dlmZ G dd deZ	dS )    )annotationsN)Base)expectc                   @  s   e Zd ZeddddZeddddZeddddZeddd	d
ZeddddZeddddZ	eddddZ
dS )	ReduceSumNone)returnc                  C  s   dddg} t jdgt jd}d}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ddgddgggt jd}t j|t|	 |dkd}t
|||g|gdd t jd t jdd| t j}t j|t|	 |dkd}t
|||g|gdd d S )N         Zdtyper   r   dataaxesreducedinputsoutputskeepdims               	   
         Zaxisr   Z'test_reduce_sum_do_not_keepdims_exampler   r   nameZ&test_reduce_sum_do_not_keepdims_randomnparrayint64onnxhelper	make_nodefloat32sumtupletolistr   randomseeduniformastypeshaper   r   noder   r    r2   I/tmp/pip-unpacked-wheel-xnis5xre/onnx/backend/test/case/node/reducesum.pyexport_do_not_keepdims   s:    
   , z ReduceSum.export_do_not_keepdimsc                  C  s   dddg} t jdgt jd}d}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ddgddgggt jd}t j|t|	 |dkd}t
|||g|gdd t jd t jdd| t j}t j|t|	 |dkd}t
|||g|gdd d S )Nr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z test_reduce_sum_keepdims_exampler   r   r   Ztest_reduce_sum_keepdims_randomr    r/   r2   r2   r3   export_keepdims3   s:    
   , zReduceSum.export_keepdimsc                  C  s   dddg} t jg t jd}d}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ddgddgggt jd}t j|d |dkd}t|||g|gdd t j	
d t j	dd| t j}t j|d |dkd}t|||g|gdd d S )Nr   r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z-test_reduce_sum_default_axes_keepdims_exampler   r   r   Z,test_reduce_sum_default_axes_keepdims_random)r!   r"   r#   r$   r%   r&   r'   r(   r   r+   r,   r-   r.   r/   r2   r2   r3   export_default_axes_keepdimsX   s:    
   , z&ReduceSum.export_default_axes_keepdimsc                  C  s   dddg} t jdgt jd}d}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ddgddgggt jd}t j|t|	 |dkd}t
|||g|gdd t jd t jdd| t j}t j|t|	 |dkd}t
|||g|gdd d S )Nr   r	   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z.test_reduce_sum_negative_axes_keepdims_exampler   r   r   Z-test_reduce_sum_negative_axes_keepdims_randomr    r/   r2   r2   r3   export_negative_axes_keepdims{   s:    
   , z'ReduceSum.export_negative_axes_keepdimsc                  C  s   dddg} d}t jjdddgdg|dd	}tjddgdd
ggddgddggddgddgggtjd}tjg tjd}t|}t|||g|gdd tj	d tj
dd| tj}t|}t|||g|gdd d S )Nr   r	   r
   r   r   r   r   T)r   r   r   Znoop_with_empty_axesr   r   r   r   r   r   r   r   r   r   Z-test_reduce_sum_empty_axes_input_noop_exampler   r   r   Z%test_reduce_sum_empty_axes_input_noop)r$   r%   r&   r!   r"   r'   r#   r   r+   r,   r-   r.   )r0   r   r1   r   r   r   r2   r2   r3   export_empty_axes_input_noop   s<    
, 

z&ReduceSum.export_empty_axes_input_noopc                  C  s   dddg} d}dddg}t jjdddgdg|d	}tjg tjd
| }tjdgtjd
}ttj|tjd
}t	|||g|gdd dS )z-Test case with the reduced-axis of size zero.r	   r   r   r
   r   r   r   r   r   r   Ztest_reduce_sum_empty_setr   N)
r$   r%   r&   r!   r"   r'   reshaper#   zerosr   r0   r   Zreduced_shaper1   r   r   r   r2   r2   r3   export_empty_set   s$    

zReduceSum.export_empty_setc                  C  s   dddg} d}dddg}t jjdddgdg|d	}tjg tjd
| }tjdgtjd
}tjg tjd
|}t|||g|gdd dS )z1Test case with the non-reduced-axis of size zero.r	   r   r   r
   r   r   r   r   r   r   Z/test_reduce_sum_empty_set_non_reduced_axis_zeror   N)	r$   r%   r&   r!   r"   r'   r:   r#   r   r<   r2   r2   r3   export_non_reduced_axis_zero   s$    

z&ReduceSum.export_non_reduced_axis_zeroN)__name__
__module____qualname__staticmethodr4   r5   r6   r8   r9   r=   r>   r2   r2   r2   r3   r      s   $$"$&r   )

__future__r   Znumpyr!   r$   Zonnx.backend.test.case.baser   Zonnx.backend.test.case.noder   r   r2   r2   r2   r3   <module>   s
   