operator[]

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 new LocalTensor whose offset value from the start address of the original LocalTensor is offset. Note that offset cannot exceed the size of the original LocalTensor.

Prototype

1
__aicore__ inline LocalTensor operator[](const uint32_t offset) const

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

offset

Input

Offset. The unit is element.

Returns

Returns a new LocalTensor whose offset from the start address of the original LocalTensor is offset.

Restrictions

None

Examples

1
2
3
4
5
6
7
// srcLen = 256, num = 100, M=50
// Usage of operator[]. inputLocal[16] is a new tensor with an offset of 16 starting from the start address.
AscendC::Add(outputLocal[16], inputLocal[16], inputLocal2[16], M);
// The result is as follows:
// Input data (inputLocal): [100 100 100... 100]
// Input data (inputLocal2): [1 2 3... 66]
// Output data (outputLocal): [... 117 118 119... 166]