mindspore.ops.population_count

View Source On Gitee
mindspore.ops.population_count(input_x)[source]

Calculate the number of 1 bits in the binary representation of each element in the input tensor.

Parameters

input_x (Tensor) – The input tensor.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input_x = mindspore.tensor([0, 1, 3], mindspore.int16)
>>> output = mindspore.ops.population_count(input_x)
>>> print(output)
[0 1 2]