DeQue
产品支持情况
产品 |
是否支持 |
---|---|
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
√ |
|
x |
功能说明
将Tensor从队列中取出,用于后续处理。
函数原型
- non-inplace接口:将Tensor从队列中取出并返回
1 2
template <typename T> __aicore__ inline LocalTensor<T> DeQue()
- inplace接口:通过出参的方式返回
1 2
template <typename T> __aicore__ inline void DeQue(LocalTensor<T>& tensor)
图1 将LocalTensor通过EnQue放入A1/B1的Queue中后再通过DeQue搬出


参数说明
参数名 |
说明 |
---|---|
T |
Tensor的数据类型。 |
约束说明
- TQue的depth设置为非0时,只支持non-inplace接口
- TQue的depth设置为0时,只支持inplace接口
返回值
non-inplace接口的返回值为从队列中取出的LocalTensor;inplace接口没有返回值。
调用示例
- non-inplace接口
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>(); // 将tensor从VECOUT的Queue中搬出
- inplace接口
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); // 将tensor从VECOUT的Queue中搬出 que.FreeTensor<half>(tensor1);
父主题: TQueBind