DeQue

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

Extracts tensors from the queue for subsequent processing.

Prototype

  • Non-inplace API: Obtains the enqueued LocalTensor address from the queue, assigns the address to the newly created tensor, and returns the address.
    1
    2
    template <typename T>
    __aicore__ inline LocalTensor<T> DeQue()
    
  • Inplace API: Returns the result through output parameters, which reduces the overhead of repeatedly creating tensors. For details, see How to Improve Operator Performance Through Inplace Tensor Operations.
    1
    2
    template <typename T>
    __aicore__ inline void DeQue(LocalTensor<T>& tensor)
    

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of the tensor.

Table 2 Parameters

Parameter

Input/Output

Meaning

tensor

Output

The inplace API returns the tensor through output parameters.

Restrictions

  • Performing DeQue on an empty queue is abnormal behavior, and an error is reported during CPU debugging.
  • For the non-inplace API, the depth template parameter of TQueBind must be set to a non-zero value. For the inplace API, the depth template parameter of TQueBind must be set to 0.

Returns

The return value of the non-inplace API is the LocalTensor obtained from the queue. The inplace API does not return any value.

Example

  • Non-inplace API
    1
    2
    3
    4
    5
    6
    7
    8
    AscendC::TPipe pipe;
    AscendC::TQueBind<AscendC::TPosition::VECOUT, AscendC::TPosition::GM, 4> que;
    int num = 4;
    int len = 1024;
    pipe.InitBuffer(que, num, len);
    AscendC::LocalTensor<half> tensor1 = que.AllocTensor<half>();
    que.EnQue(tensor1);
    AscendC::LocalTensor<half> tensor2 = que.DeQue<half>(); // Move the tensor out of the VECOUT queue.
    
  • Inplace API
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    AscendC::TPipe pipe;
    AscendC::TQueBind<AscendC::TPosition::VECOUT, AscendC::TPosition::GM, 0> que;
    int num = 2;
    int len = 1024;
    pipe.InitBuffer(que, num, len);
    AscendC::LocalTensor<half> tensor1;
    que.AllocTensor<half>(tensor1);
    que.EnQue(tensor1);
    que.DeQue<half>(tensor1); // Move the tensor out of the VECOUT queue.
    que.FreeTensor<half>(tensor1);