GetValue

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

Atlas inference product AI Core

Atlas inference product Vector Core

Atlas training product

Function Usage

Obtains the value of a specified index in the LocalTensor.

This API is supported only when the TPosition of the LocalTensor is VECIN, VECCALC, or VECOUT.

Prototype

1
__aicore__ inline __inout_pipe__(S) PrimType GetValue(const uint32_t index) const

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

index

Input

LocalTensor index. The unit is element.

Returns

Value of the specified index in the LocalTensor. The value is of the PrimType type.

PrimType is defined as follows:

1
2
// PrimT is used to extract the basic data type from T. If T is of the basic data type, the data type is directly returned. If T is of the TensorTrait type, the LiteType basic data type in TensorTrait is extracted.
using PrimType = PrimT<T>;

Restrictions

None

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Example 1
// Data (inputLocal): [0 100 200 ...]
auto element = inputLocal.GetValue(2); // Obtain the value of the ith position in inputLocal.

// The result of example 1 is as follows:
// The number of elements is 200.


// Example 2
// Data (inputLocal): [0 100 200 ...]
auto element = inputLocal(1); // Obtain the value at the i th position in inputLocal.
// The result of example 2 is as follows:
// The number of elements is 100.