mindspore.ops.PopulationCount

class mindspore.ops.PopulationCount[源代码]

Computes element-wise population count(a.k.a bitsum, bitcount). For each entry in input , calculates the number of 1 bits in the binary representation of that entry.

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]