SetAddrWithOffset
产品支持情况
- Ascend 950PR/Ascend 950DT:支持
- Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持
- Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持
- Atlas 200I/500 A2 推理产品:支持
- Atlas 推理系列产品AI Core:支持
- Atlas 推理系列产品Vector Core:支持
- Atlas 训练系列产品:支持
功能说明
设置带有偏移的Tensor地址。用于快速获取定义一个Tensor,同时指定新Tensor相对于旧Tensor首地址的偏移。偏移的长度为旧Tensor的元素个数。
函数原型
C++
template <typename S>
__aicore__ inline void SetAddrWithOffset(LocalTensor<S> &src, uint32_t offset)
参数说明
表1 参数说明
参数名 | 输入/输出 | 描述 |
|---|---|---|
src | 输入 | 基础地址的Tensor,将该Tensor的地址作为基础地址,设置偏移后的Tensor地址。 |
offset | 输入 | 偏移的长度,单位为元素。 |
返回值说明
无
约束说明
无
调用示例
C++
// 示例SetAddrWithOffset,用于快速获取定义一个Tensor,同时指定新Tensor相对于旧Tensor首地址的偏移
// 需要注意,偏移的长度为旧Tensor的元素个数
AscendC::LocalTensor<float> tmpBuffer1 = tempBmm2Queue.AllocTensor<float>();
AscendC::LocalTensor<half> tmpHalfBuffer;
tmpHalfBuffer.SetAddrWithOffset(tmpBuffer1, calcSize * 2);