Skip to content

Interleave

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持

功能说明

头文件路径为:"basic_api/kernel_operator_vec_duplicate_intf.h"

给定源操作数src0和src1,将src0和src1中的元素交织存入结果操作数dst0和dst1中。交织排列方式如下图所示,其中每个方格代表一个元素。

函数原型

Text
template <typename T>
__aicore__ inline void Interleave(const LocalTensor<T>& dst0, const LocalTensor<T>& dst1, const LocalTensor<T>& src0, const LocalTensor<T>& src1, const int32_t count)

参数说明

表1 模板参数说明

参数名描述
T操作数数据类型。

表2 参数说明

参数名输入/输出描述
dst0/dst1输出目的操作数。类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。LocalTensor的起始地址需要32字节对齐。
src0/src1输入源操作数。类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。LocalTensor的起始地址需要32字节对齐。源操作数的数据类型需要与目的操作数保持一致。
count输入输入/输出数据元素个数,dst0/dst1/src0/src1长度大小均为count。count必须为偶数。

数据类型

支持的数据类型为:int8_t、uint8_t、int16_t、uint16_t、half、bfloat16_t、int32_t、uint32_t、float、int64_t、uint64_t。源操作数的数据类型需要与目的操作数保持一致。

返回值说明

约束说明

不支持源操作数与目的操作数地址重叠。

调用示例

Text
AscendC::Interleave(dst0Local, dst1Local, src0Local, src1Local, 512);

结果示例如下:

Text
输入数据src0Local:[1 2 3 ... 512]
输入数据src1Local:[513 514 515 ... 1024]
输出数据dst0Local:[1 513 2 ... 768]
输出数据dst1Local:[257 769 258 ... 1024]

免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区