max

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

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.

Examples

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