CANN/Ascend C Arange索引生成函数
·
Arange
产品支持情况
功能说明
该函数以传入的scalar的值为起始值,生成递增/递减的索引,并将索引保存在dstReg中。
函数原型
template <typename T = DefaultType, IndexOrder order = IndexOrder::INCREASE_ORDER, typename U, typename S>
__simd_callee__ inline void Arange(S& dstReg, U scalarValue);
参数说明
表 1 模板参数说明
|
Ascend 950PR/Ascend 950DT,支持的数据类型为:int8_t/int16_t/int32_t/half/float/int64_t |
|
|
Ascend 950PR/Ascend 950DT,支持的数据类型为:int8_t/int16_t/int32_t/half/float/int64_t |
|
表 2 函数参数说明
|
类型为RegTensor。 |
||
约束说明
无
调用示例
template<typename T>
__simd_vf__ inline void ArangeVF(__ubuf__ T* dstAddr, T scalarValue, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> dstReg;
AscendC::Reg::MaskReg mask;
mask = AscendC::Reg::CreateMask<T>();
for (uint16_t i = 0; i < repeatTimes; i++) {
AscendC::Reg::Arange(dstReg, scalarValue);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
更多推荐
所有评论(0)