abs

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Obtains the absolute value of the input data.

Prototype

1
2
template <typename T>
__aicore__ inline T abs(const T src)

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of the input data src. Currently, the supported data types are int8_t, int16_t, int32_t, float, and int64_t.

Table 2 API parameters

Parameter

Input/Output

Description

src

Input

Source operand.

Restrictions

None

Returns

Absolute value of the input data.

Examples

1
2
3
4
int64_t src = -2;

int64_t result = AscendC::Std::abs(src); 
// result: 2