Sort32

函数功能

排序函数,一次迭代可以完成32个数的排序,数据需要按如下描述结构进行保存:

score和index分别存储在src0Local和src1Local中,按score进行排序(score大的排前面),排序好的score与其对应的index一起以(score, index)的结构存储在dstLocal中。不论score为half还是float类型,dstLocal中的(score, index)结构总是占据8Bytes空间。

如下所示:

函数原型

1
2
template <typename T>
__aicore__ inline void Sort32(const LocalTensor<T>& dstLocal, const LocalTensor<T>& src0Local, const LocalTensor<uint32_t>& src1Local, const int32_t repeatTimes)

参数说明

表1 参数说明

参数名称

输入/输出

含义

dstLocal

输出

目的操作数。

类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。

LocalTensor的起始地址需要32字节对齐。

Atlas A2训练系列产品/Atlas 800I A2推理产品,支持的数据类型为:half/float

Atlas 200I/500 A2推理产品,支持的数据类型为:half/float

src0Local

输入

源操作数。

类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。

LocalTensor的起始地址需要32字节对齐。

此源操作数的数据类型需要与目的操作数保持一致。

Atlas A2训练系列产品/Atlas 800I A2推理产品,支持的数据类型为:half/float

Atlas 200I/500 A2推理产品,支持的数据类型为:half/float

src1Local

输入

源操作数。

类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。

LocalTensor的起始地址需要32字节对齐。

此源操作数固定为uint32_t数据类型。

repeatTimes

输入

重复迭代次数,int32_t类型,每次迭代完成32个元素的排序,下次迭代src0Local和src1Local各跳过32个elements,dstLocal跳过32*8 Byte空间。取值范围:repeatTimes∈[0,255]。

返回值

支持的型号

Atlas A2训练系列产品/Atlas 800I A2推理产品

Atlas 200I/500 A2推理产品

约束说明

调用示例