Obtains tensors of a specified length from the TBuf with an offset of the specified length.
Table 1 Parameters
| Parameter | Input/Output | Description |
|---|---|---|
| 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. |
Kirin 9020 series processors
Kirin 9030 series processors
Kirin X90 series processors
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.
// 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);