Obtains tensors of all lengths.
LocalTensor<T> Get<T>()
Obtains tensors of a specified length.
LocalTensor<T> Get<T>(uint32_t len)
Table 1 Parameters
| Parameter | Input/Output | Description |
|---|---|---|
| len | Input | Number of tensor elements to be obtained. |
Kirin 9020 series processors
Kirin 9030 series processors
Kirin X90 series processors
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.
// 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);