IsFinite

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

Checks whether the input floating-point number is a non-NAN or non-±INF value. The output is a floating-point number or Boolean value. For non-NAN or non-±INF input, if the output is of the floating-point type, the result of the corresponding position is 1 of the floating-point type. If not, the result is 0. If the output is of the Boolean type, the result of the corresponding position is true. If not, the result is false. The formula is as follows:

  • If the output is of the floating-point type:

  • If the output is of the bool type:

Prototype

1
2
template<typename T, typename U>
__aicore__ inline void IsFinite(const LocalTensor<U>& dst, const LocalTensor<T>& src, uint32_t calCount)

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of the source operand.

For the Atlas 350 Accelerator Card, the supported data types are half, bfloat16_t, and float.

U

Data type of the destination operand.

For the Atlas 350 Accelerator Card, the supported data types are bool, half, bfloat16_t, and float.

Table 2 API parameters

Parameter

Input/Output

Description

dst

Output

Destination operand.

The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT.

The data type of the destination operand is the same as that of the source operand, or the data type of the destination operand is bool. For details about the supported data type groups, see Table 3.

src

Input

Source operand.

The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT.

calCount

Input

Number of elements involved in the computation.

Table 3 Data type groups supported by the input and output.

srcDtype

dstDtype

half

half

half

bool

float

float

float

bool

bfloat16_t

bfloat16_t

bfloat16_t

bool

Returns

None

Constraints

  • The source operand address must not overlap the destination operand address.
  • For details about the alignment requirements of the operand address offset, see General Description and Restrictions.

Examples

For details about the complete operator example, see isfinite operator sample.

1
2
3
4
// dstLocal: tensor for storing the IsFinite computation result
// srcLocal: input tensor for storing data for IsFinite computation
// The number of elements involved in the computation is 8.
AscendC::IsFinite(dstLocal, srcLocal, 8);
Result example:
1
2
3
4
5
The input data type is float, and the output data type is bool.
Input (src):
[1.0,+inf,3.0,4.0,nan,6.0,-inf,8.0]
Output (dst):
[true,false,true,true,false,true,false,true]