Introduction to TBuf
Some temporary variables may be used during Ascend C programming. The buffer occupied by these temporary variables can be managed using the TBuf data structure. The storage location is set using template parameters and can be set to different TPosition logical locations.
TBuf is inherited from the TQueBind parent class. The inheritance relationship is as follows:

The storage space occupied by TBuf is managed by TPipe. You can call InitBuffer to initialize the buffer for TBuf, and then call Get to obtain a tensor of a specified length for computing.
The differences between using InitBuffer to allocate buffer for TBuf and allocate buffer for queues are as follows:
- The buffer space allocated to TBuf can only be used for calculation and cannot be enqueued or dequeued.
- If the buffer initialization API is invoked once, TPipe allocates one memory block to TBuf. You can allocate multiple memory blocks for the queue by setting parameters. To use multiple temporary variables, you need to define multiple TBuf data structures and call the InitBuffer API for each TBuf data structure to initialize the buffer.
- Tensors obtained by TBuf do not need to be released.
Parent topic: TBuf