GetState

功能说明

获取指定Tensor的使用状态,仅用于调试。

函数原型

template <typename T> __aicore__ inline TBufState GetState(const LocalTensor<T>& tensor)

参数说明

参数名称

输入/输出

含义

tensor

输入

需要查询状态的Tensor。

支持的型号

Atlas 训练系列产品

Atlas推理系列产品AI Core

Atlas A2训练系列产品/Atlas 800I A2推理产品

注意事项

返回值

返回Tensor状态,TBufState类型,取值如下:

CPU调试时,该接口可以返回FREE/OCCUPIED/ENQUE/DEQUE,NPU调试时,由于在NPU上EnQue/DeQue接口不会设置对应状态,该接口只能返回FREE/OCCUPIED状态。

调用示例

// 接口: GetState
TPipe pipe;
TQueBind<TPosition::VECOUT, TPosition::GM,2> que;
int num = 4;
int len = 1024;
pipe.InitBuffer(que, num, len); // InitBuffer分配内存块数为4,每块大小为1024Bytes
LocalTensor<half> tensor1 = que.AllocTensor<half>(); // AllocTensor分配Tensor长度为1024Bytes
ASSERT(que.GetState(tensor1) == TBufState::OCCUPIED);