AllocTensor
Function Usage
Allocates tensors from the queue. The size occupied by tensors is the length of each memory block configured when InitBuffer is used. Note that the allocated tensor content cannot all be 0. The content may be a random value.
Prototype
1 2 | template <typename T> __aicore__ inline LocalTensor<T> AllocTensor() |
Parameters
None
Availability
Precautions
None
Returns
LocalTensor object
Example
1 2 3 4 5 6 7 | // Use AllocTensor to allocate tensors. AscendC::TPipe pipe; AscendC::TQueBind<AscendC::TPosition::VECOUT, AscendC::TPosition::GM, 2> que; int num = 4; int len = 1024; pipe.InitBuffer(que, num, len); // Four memory blocks are allocated by InitBuffer, and the size of each memory block is 1024 bytes. AscendC::LocalTensor<half> tensor1 = que.AllocTensor<half>(); // The length of the tensor allocated by AllocTensor is 1024 bytes. |
Parent topic: TQueBind