HasIdleBuffer

Product Support

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference product 's AI Core

Atlas inference product 's Vector Core

x

Atlas training products

Function

Queries whether there are free buffers in the queue.

Prototype

1
__aicore__ inline bool HasIdleBuffer()

Parameters

None

Restrictions

This API does not support inplace tensor operations, that is, the scenario where the depth of TQue is set to 0.

Returns

  • true: indicates that free memory exists in the queue.
  • false: No free memory exists in the queue.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
// Four buffers have been allocated in the current queue.
AscendC::TPipe pipe;
AscendC::TQue<AscendC::TPosition::VECOUT, 1> que;
int num = 4;
int len = 1024;
pipe.InitBuffer(que, num, len);
bool ret = que.HasIdleBuffer(); // AllocTensor is not called, and the return is true.
AscendC::LocalTensor<half> tensor1 = que.AllocTensor<half>();
ret = que.HasIdleBuffer(); // One buffer has been allocated by AllocTensor, and the return is true.
AscendC::LocalTensor<half> tensor2 = que.AllocTensor<half>();
AscendC::LocalTensor<half> tensor3 = que.AllocTensor<half>();
AscendC::LocalTensor<half> tensor4 = que.AllocTensor<half>();
ret = que.HasIdleBuffer(); // Four buffers have been allocated by AllocTensor. Currently, there is no idle buffer, and the return is false. An error is reported when AllocTensor is called.