U
    9%e	                     @   sf   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rbe  dS )
    N)cuda)ENABLE_CUDASIM)CUDATestCasec                 C   s   | | S N abr   r   e/var/www/html/Darija-Ai-API/env/lib/python3.8/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Zdtype   nparangefloat64sum
sum_reduceassertEqual)selfnAexpectgotr   r   r
   _sum_reduce   s    zTestReduction._sum_reducec                 C   sH   t rddg}n"ddddddddd	d
dddddg}|D ]}| | q4d S )Nr                     i  i   i  i   i   i  i i  )r   r   )r   Z
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    s    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   Z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testingZassert_allclose)r   Z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   r   z/TestReduction.test_max_reduce.<locals>.<lambda>i  r   r   r   r)   )r   Reducer   r   r   r/   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 )Nr4   r   r   )resr   )
r   r   r   r   r&   Zzerosr   r   ZassertIsNoner   )r   r   r   r   r6   r   r   r
   test_result_on_deviceB   s    
z#TestReduction.test_result_on_deviceN)__name__
__module____qualname__r   r#   r%   r'   r.   r2   r5   r7   r   r   r   r
   r      s   r   __main__)numpyr   Znumbar   Znumba.core.configr   Znumba.cuda.testingr   Zunittestr0   r   r   r8   mainr   r   r   r
   <module>   s   @