产品 |
是否支持 |
|---|---|
Ascend 950PR/Ascend 950DT |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
从TSCM中分配tensor,tensor所占大小为InitBuffer时设置的每块内存长度。注意,分配的tensor内容并非全0,可能会是随机值。
1 2 | template <typename T> __aicore__ inline LocalTensor<T> AllocTensor() |
无
无
LocalTensor对象。
1 2 3 4 5 6 7 8 9 | AscendC::TPipe pipe; AscendC::TSCM<AscendC::TPosition::VECIN, 1> tscm; int num = 4; int len = 1024; pipe.InitBuffer(tscm, num, len); // InitBuffer分配内存块数为4,每块大小为1024Bytes AscendC::LocalTensor<half> tensor1 = tscm.AllocTensor<half>(); // AllocTensor分配Tensor长度为1024Bytes tscm.EnQue(tensor1); tensor1 = tscm.DeQue<half>(); tscm.FreeTensor(tensor1); |