
    xKg	                         d dl Zd dlmZ d dlmZ d dlmZ d dlZ ej                  d       Z
 G d de      Zedk(  r ej                          yy)	    N)cuda)ENABLE_CUDASIM)CUDATestCasec                     | |z   S N abs     j/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/cuda/tests/cudapy/test_reduction.py<lambda>r      s    a!e    c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
TestReductionc                     t        j                  |t         j                        dz   }|j                         }t	        |      }| j                  ||       y )Ndtype   nparangefloat64sum
sum_reduceassertEqual)selfnAexpectgots        r   _sum_reducezTestReduction._sum_reduce   ?    YYq

+a/m%r   c                 R    t         rddg}ng d}|D ]  }| j                  |        y )Nr      )r      r$               i  i   i  i   i   i  i i  )r   r!   )r   
test_sizesr   s      r   test_sum_reducezTestReduction.test_sum_reduce   s2     bJJJ AQ r   c                     t        j                  dt         j                        dz   }|j                         }t	        |      }| j                  ||       y Nr   r   r   r   )r   r   r   r    s       r   test_empty_array_hostz#TestReduction.test_empty_array_host    r"   r   c                     t        j                  dt         j                        dz   }t        j                  |      }|j                         }t        |      }| j                  ||       y r-   )r   r   r   r   	to_devicer   r   r   )r   r   dAr   r    s        r   test_empty_array_devicez%TestReduction.test_empty_array_device&   sM    YYq

+a/^^An%r   c                     t        j                  d       }t        j                  dt        j                        dz   }|j                         } ||d      }t        j                  j                  ||       y )Nc                     | |z  S r   r   r	   s     r   r   z0TestReduction.test_prod_reduce.<locals>.<lambda>.   s    q1ur   @   r   r   init)r   reducer   r   r   prodtestingassert_allclose)r   prod_reducer   r   r    s        r   test_prod_reducezTestReduction.test_prod_reduce-   sU    kk"45YYr,q0!!$


""63/r   c                     t        j                  d       }t        j                  dt        j                        dz   }|j                         } ||d      }| j                  ||       y )Nc                     t        | |      S r   )maxr	   s     r   r   z/TestReduction.test_max_reduce.<locals>.<lambda>5   s
    c!Qir   i  r   r   r   r6   )r   Reducer   r   r   r@   r   )r   
max_reducer   r   r    s        r   test_max_reducezTestReduction.test_max_reduce4   sQ    [[!78
YYt2::.2#%r   c                     d}t        j                  dt         j                        dz   }|j                         |z   }t	        ||      }| j                  ||       y )N   
   r   r   r6   r   )r   r7   r   r   r    s        r   test_non_identity_initz$TestReduction.test_non_identity_init;   sK    YYr,q04&%r   c                 J   t        j                  dt         j                        dz   }t        j                  t        j
                  dt         j                              }|j                         }t        ||      }| j                  |       | j                  ||d          y )NrF   r   r   )resr   )
r   r   r   r   r0   zerosr   r   assertIsNoner   )r   r   r    r   rI   s        r   test_result_on_devicez#TestReduction.test_result_on_deviceB   sq    YYr,q0nnRXXarzz:;$#Q(r   N)__name__
__module____qualname__r!   r+   r.   r2   r=   rC   rG   rL   r   r   r   r   r      s*    & &&0&&)r   r   __main__)numpyr   numbar   numba.core.configr   numba.cuda.testingr   unittestrA   r   r   rM   mainr   r   r   <module>rW      sN      , +  T[[+,
=)L =)@ zHMMO r   