dpnp.count_nonzero

dpnp.count_nonzero(x1, axis=None, *, keepdims=False)[source]

Counts the number of non-zero values in the array in_array1.

For full documentation refer to numpy.count_nonzero.

Limitations

Parameter x1 is supported as dpnp.ndarray. Otherwise the function will be executed sequentially on CPU. Parameter axis is supported only with default value None. Parameter keepdims is supported only with default value False.

Examples

>>> import dpnp as np
>>> np.count_nonzero(np.array([1, 0, 3, 0, 5])
3
>>> np.count_nonzero(np.array([[1, 0, 3, 0, 5],[0, 9, 0, 7, 0]]))
5