mindspore.ops.PopulationCount

class mindspore.ops.PopulationCount[source]

Computes element-wise population count(a.k.a bitsum, bitcount).

Refer to mindspore.ops.population_count() for more details.

Inputs:
  • input_x (Tensor) - Tensor of any dimension. The data type must be int16 or uint16 (Ascend). The data type must be int8, int16, int32, int64, uint8, uint16, uint32, uint64 (CPU and GPU).

Outputs:

Tensor, with the same shape as the input, and the data type is uint8.

Supported Platforms:

Ascend GPU CPU

Examples

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