产品 |
是否支持 |
|---|---|
Ascend 950PR/Ascend 950DT |
√ |
√ |
|
√ |
|
√ |
|
x |
|
x |
|
x |
VECIN,VECCALC,VECOUT之间的搬运指令,支持mask操作和DataBlock间隔操作。
1 2 | template <typename T, bool isSetMask = true> __aicore__ inline void Copy(const LocalTensor<T>& dst, const LocalTensor<T>& src, const uint32_t count) |
1 2 | template <typename T, bool isSetMask = true> __aicore__ inline void Copy(const LocalTensor<T>& dst, const LocalTensor<T>& src, const uint64_t mask[], const uint8_t repeatTime, const CopyRepeatParams& repeatParams) |
1 2 | template <typename T, bool isSetMask = true> __aicore__ inline void Copy(const LocalTensor<T>& dst, const LocalTensor<T>& src, const uint64_t mask, const uint8_t repeatTime, const CopyRepeatParams& repeatParams) |
参数名 |
描述 |
|---|---|
T |
操作数数据类型。 Ascend 950PR/Ascend 950DT,支持的数据类型为:uint8_t/int8_t/hifloat8_t/fp8_e4m3fn_t/fp8_e5m2_t/fp4x2_e2m1_t/fp4x2_e1m2_t/fp8_e8m0_t/uint16_t/int16_t/half/bfloat16_t/float/uint32_t/int32_t/uint64_t/int64_t |
isSetMask |
是否在接口内部设置mask。
|
参数名 |
输入/输出 |
描述 |
|---|---|---|
dst |
输出 |
目的操作数。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。起始地址需要保证32字节对齐。 |
src |
输入 |
源操作数。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。起始地址需要保证32字节对齐。 源操作数的数据类型需要与目的操作数保持一致。 |
count |
输入 |
参与搬运的元素个数。 |
mask/mask[] |
输入 |
mask用于控制每次迭代内参与计算的元素。
|
repeatTime |
输入 |
重复迭代次数。矢量计算单元,每次读取连续的256Bytes数据进行计算,为完成对输入数据的处理,必须通过多次迭代(repeat)才能完成所有数据的读取与计算。repeatTime表示迭代的次数。 关于该参数的具体描述请参考高维切分API。 |
repeatParams |
输入 |
控制操作数地址步长的数据结构。CopyRepeatParams类型。 具体定义请参考${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_data_copy.h,${INSTALL_DIR}请替换为CANN软件安装后文件存储路径。 参数说明请参考表3。 |
参数名称 |
含义 |
|---|---|
dstStride、srcStride |
用于设置同一迭代内datablock的地址步长,取值范围为[0,65535]。 同一迭代内datablock的地址步长参数说明请参考dataBlockStride。 |
dstRepeatSize、srcRepeatSize |
用于设置相邻迭代间的地址步长,取值范围为[0,4095]。 相邻迭代间的地址步长参数说明请参考repeatStride。 |
无

本示例仅展示Compute流程中的部分代码。
本示例中操作数数据类型为int16_t。
1 | AscendC::Copy(dstLocal, srcLocal, 512); |
输入数据srcLocal:[9 -2 8 ... 9] 输出数据dstLocal: [9 -2 8 ... 9]
1 2 3 4 5 | uint64_t mask = 128; // repeatTime = 4, 128 elements one repeat, 512 elements total // dstStride, srcStride = 1, no gap between blocks in one repeat // dstRepStride, srcRepStride = 8, no gap between repeats AscendC::Copy(dstLocal, srcLocal, mask, 4, { 1, 1, 8, 8 }); |
结果示例如下:
输入数据srcLocal:[9 -2 8 ... 9] 输出数据dstLocal: [9 -2 8 ... 9]
1 2 3 4 5 | uint64_t mask[2] = { UINT64_MAX, UINT64_MAX }; // repeatTime = 4, 128 elements one repeat, 512 elements total // dstStride, srcStride = 1, no gap between blocks in one repeat // dstRepStride, srcRepStride = 8, no gap between repeats AscendC::Copy(dstLocal, srcLocal, mask, 4, { 1, 1, 8, 8 }); |
结果示例如下:
输入数据srcLocal:[9 -2 8 ... 9] 输出数据dstLocal: [9 -2 8 ... 9]