dpctl.tensor.unique_counts

dpctl.tensor.unique_counts(x)[source]

Returns the unique elements of an input array x and the corresponding counts for each unique element in x.

Parameters:

x (usm_ndarray) – input array. Inputs with more than one dimension are flattened.

Returns:

tuple[usm_ndarray, usm_ndarray]

a namedtuple (values, counts) whose

  • first element is the field name values and is an array

    containing the unique elements of x. This array has the same data type as x.

  • second element has the field name counts and is an array containing the number of times each unique element occurs in x. This array has the same shape as values and has the default array index data type.