o
    i	                     @   sj   d dl Zd dlmZ d dlmZ d dlmZ d dlZe	dd Z
G dd deZed	kr3e  dS dS )
    N)cuda)ENABLE_CUDASIM)CUDATestCasec                 C   s   | | S N abr   r   c/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/numba/cuda/tests/cudapy/test_reduction.py<lambda>       r   c                   @   sL   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dS )TestReductionc                 C   s4   t j|t jdd }| }t|}| || d S )Ndtype   nparangefloat64sum
sum_reduceassertEqual)selfnAexpectgotr   r   r
   _sum_reduce      zTestReduction._sum_reducec                 C   s.   t rddg}ng d}|D ]}| | qd S )Nr      )r      r               i  i   i  i   i   i  i i  )r   r   )r   
test_sizesr   r   r   r
   test_sum_reduce   s   
zTestReduction.test_sum_reducec                 C   s4   t jdt jdd }| }t|}| || d S Nr   r   r   r   )r   r   r   r   r   r   r
   test_empty_array_host    r   z#TestReduction.test_empty_array_hostc                 C   s>   t jdt jdd }t|}| }t|}| || d S r'   )r   r   r   r   	to_devicer   r   r   )r   r   dAr   r   r   r   r
   test_empty_array_device&   s
   
z%TestReduction.test_empty_array_devicec                 C   sH   t dd }tjdtjdd }| }||dd}tj|| d S )Nc                 S   s   | | S r   r   r   r   r   r
   r   .   r   z0TestReduction.test_prod_reduce.<locals>.<lambda>@   r   r   init)r   reducer   r   r   prodtestingassert_allclose)r   prod_reducer   r   r   r   r   r
   test_prod_reduce-   s
   zTestReduction.test_prod_reducec                 C   sF   t dd }tjdtjdd }| }||dd}| || d S )Nc                 S   s
   t | |S r   )maxr   r   r   r
   r   5   s   
 z/TestReduction.test_max_reduce.<locals>.<lambda>i  r   r   r   r-   )r   Reducer   r   r   r5   r   )r   
max_reducer   r   r   r   r   r
   test_max_reduce4   s
   zTestReduction.test_max_reducec                 C   s@   d}t jdt jdd }| | }t||d}| || d S )N   
   r   r   r-   r   )r   r.   r   r   r   r   r   r
   test_non_identity_init;   s
   z$TestReduction.test_non_identity_initc                 C   s\   t jdt jdd }tt jdt jd}| }t||d}| | | 	||d  d S )Nr:   r   r   )resr   )
r   r   r   r   r)   zerosr   r   assertIsNoner   )r   r   r   r   r<   r   r   r
   test_result_on_deviceB   s   
z#TestReduction.test_result_on_deviceN)__name__
__module____qualname__r   r&   r(   r+   r4   r8   r;   r?   r   r   r   r
   r      s    r   __main__)numpyr   numbar   numba.core.configr   numba.cuda.testingr   unittestr6   r   r   r@   mainr   r   r   r
   <module>   s    @