ScalarGetCountOfValue

Applicability

Product

Supported/Unsupported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

Atlas inference product's Vector Core

x

Atlas training products

x

Function Usage

Obtains the number of 0s or 1s in a binary number of the uint64_t type.

Prototype

1
2
template <int countValue> 
__aicore__ inline int64_t ScalarGetCountOfValue(uint64_t valueIn)

Parameters

Table 1 Parameters in the template

Parameter

Description

countValue

0 or 1 to be counted.

Enter 0 or 1.

Table 2 Parameters

Parameter

Input/Output

Description

valueIn

Input

A binary number.

Returns

Number of 0s or 1s in valueIn.

Constraints

None

Example

1
2
3
uint64_t valueIn = 0xffff;
// Output (oneCount): 16
int64_t oneCount = AscendC::ScalarGetCountOfValue<1>(valueIn);