文档
注册

AllocTensor

功能说明

从Que中分配Tensor,Tensor所占大小为InitBuffer时设置的每块内存长度。注意,分配的Tensor内容并非全0,可能会是随机值。

定义原型

template <typename T> __aicore__ inline LocalTensor<T> AllocTensor();

参数说明

支持的型号

Atlas 训练系列产品

Atlas推理系列产品(Ascend 310P处理器)AI Core

Atlas A2训练系列产品

注意事项

返回值

LocalTensor对象

调用示例

// 使用AllocTensor分配Tensor
TPipe pipe;
TQue<TPosition::VECOUT, 2> que;
int num = 4;
int len = 1024;
pipe.InitBuffer(que, num, len); // InitBuffer分配内存块数为4,每块大小为1024Bytes
LocalTensor<half> tensor1 = que.AllocTensor(); // AllocTensor分配Tensor长度为1024Bytes
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词