目录

Get

Function Description

Obtains tensors of a specified length or all lengths from TBuf.

Function Prototype

Parameters

Table 1 Parameters

Parameter Input/Output Description
len Input Number of tensor elements to be obtained.

Supported Models

Kirin 9020 series processors

Kirin 9030 series processors

Kirin X90 series processors

Precautions

The value of len is the number of elements in the tensor. The value of len x sizeof(T) cannot exceed the length during TBuf initialization.

Return Value

None

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. The tensor is the size of all memory allocated by the pipe (1,024 bytes).
AscendC::LocalTensor<int32_t> tempTensor1 = calcBuf.Get<int32_t>();
// Obtain a tensor from calcBuf. The tensor is the memory size (512 bytes) of 128 int32_t elements.
AscendC::LocalTensor<int32_t> tempTensor2 = calcBuf.Get<int32_t>(128);