mindspore.ops.PopulationCount

class mindspore.ops.PopulationCount[source]

Calculates population count.

Inputs:
  • input (Tensor) - The data type must be int16 or uint16.

Outputs:

Tensor, with the same shape as the input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend

Examples

>>> population_count = ops.PopulationCount()
>>> x_input = Tensor([0, 1, 3], mindspore.int16)
>>> output = population_count(x_input)
>>> print(output)
[0 1 2]