max

Applicability

Product

Supported

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

Compares two numbers of the same data type and returns the maximum value.

Prototype

1
2
template <typename T, typename U>
__aicore__ inline T max(const T src0, const U src1)

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of the input data src0. Currently, the supported data types are bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, float, int64_t, and uint64_t.

U

Data type of the input data src1. Currently, the supported data types are bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, float, int64_t, and uint64_t.

Reserved type. Currently, the value must be the same as that of T.

Table 2 API parameters

Parameter

Input/Output

Description

src0

Input

Source operand. This is the input for comparison.

src1

Input

Source operand. This is the input for comparison.

Restrictions

The data types of the two source operands must be the same.

Returns

Maximum value of the two input data elements.

Example

1
2
3
4
5
int64_t src0 = 1;
int64_t src1 = 2;
 
int64_t result = AscendC::Std::max(src0, src1); 
// result: 2