GetWithOffset
Function Usage
Starts from the base address TBuf, offsets by a specified length, uses the offset address as the starting address, and extracts a tensor of the specified length.
Prototype
1 | LocalTensor<T> GetWithOffset<T>(uint32_t size, uint32_t bufOffset) |
Parameters
Parameter |
Input/Output |
Meaning |
|---|---|---|
size |
Input |
Number of tensor elements to be obtained. |
bufOffset |
Input |
Offset length from the start position. The unit is byte and the value must be 32-byte aligned. |
Availability
Precautions
The value of size is the number of elements in the tensor. The value of size x sizeof(T) + bufOffset cannot exceed the length during TBuf initialization.
bufOffset must be 32-byte aligned.
Returns
None
Example
1 2 3 4 5 6 7 | // Allocate buffer for TBuf initialization. The length of the allocated buffer is 1024 bytes. AscendC::TPipe pipe; AscendC::TBuf<AscendC::TPosition::VECCALC> calcBuf; // The template parameter is the VECCALC type in TPosition. uint32_t byteLen = 1024; pipe.InitBuffer(calcBuf, byteLen); // Obtain a tensor from calcBuf using an offset of 64 bytes. The tensor is the buffer size of 128 elements of the int32_t type, which is 512 bytes. AscendC::LocalTensor<int32_t> tempTensor1 = calcBuf.GetWithOffset<int32_t>(128, 64); |
Parent topic: TBuf