给定起始值,等差值和长度,返回一个等差数列。
以float类型,ND格式,firstValue和diffValue输入Scalar为例,描述ArithProgression高阶API内部算法框图,如下图所示。
计算过程分为如下几步,均在Vector上进行:
1 2 | template <typename T> __aicore__ inline void ArithProgression(const LocalTensor<T> &dstLocal, const T firstValue, const T diffValue, const int32_t count) |
参数名 |
描述 |
---|---|
T |
操作数的数据类型。 |
参数名 |
输入/输出 |
描述 |
---|---|---|
dstLocal |
输出 |
目的操作数。dstLocal的大小应大于等于count * sizeof(T)。 类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
firstValue |
输入 |
等差数列的首个元素值。 |
diffValue |
输入 |
等差数列元素之间的差值,应大于等于0。 |
count |
输入 |
等差数列的长度。count>0。 |
无
当前仅支持ND格式的输入,不支持其他格式。
完整算子样例请参考arithprogression算子样例。
1 2 3 | AscendC::LocalTensor<T> dstLocal = outDst.AllocTensor<T>(); AscendC::ArithProgression<T>(dstLocal, static_cast<T>(firstValue_), static_cast<T>(diffValue_), count_); outDst.EnQue<T>(dstLocal); |