目录

GetWithOffset

Function Description

Obtains tensors of a specified length from the TBuf with an offset of the specified length.

Function Prototype

LocalTensor<T> GetWithOffset<T>(uint32_t size, uint32_t bufOffset)

Parameters

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.

Supported Models

Kirin 9020 series processors

Kirin 9030 series processors

Kirin X90 series processors

Precautions

Return Value

Returns the LocalTensor object truncated from the offset position.

Calling Example

// 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);