File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 21
21
from numpy .testing import assert_allclose
22
22
23
23
import dpctl .tensor as dpt
24
+ from dpctl .tensor ._tensor_impl import default_device_index_type
24
25
from dpctl .tests .helper import get_queue_or_skip , skip_if_dtype_not_supported
25
26
from dpctl .utils import ExecutionPlacementError
26
27
@@ -669,3 +670,21 @@ def test_reduction_out_kwarg_arg_validation():
669
670
keepdims = True ,
670
671
out = dpt .empty_like (out_wrong_keepdims , dtype = ind_dt ),
671
672
)
673
+
674
+
675
+ @pytest .mark .parametrize ("dt" , _all_dtypes )
676
+ def test_count_nonzero (dt ):
677
+ q = get_queue_or_skip ()
678
+ skip_if_dtype_not_supported (dt , q )
679
+
680
+ expected_dt = default_device_index_type (q .sycl_device )
681
+
682
+ x = dpt .ones (10 , dtype = dt , sycl_queue = q )
683
+ res = dpt .count_nonzero (x )
684
+ assert res == 10
685
+ assert x .dtype == expected_dt
686
+
687
+ x [3 :6 ] = 0
688
+ res = dpt .count_nonzero (x )
689
+ assert res == 7
690
+ assert x .dtype == expected_dt
You can’t perform that action at this time.
0 commit comments