operator[]
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
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
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] |
Parent topic: LocalTensor