Arange
产品支持情况
产品 |
是否支持 |
|---|---|
Atlas 350 加速卡 |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
功能说明
以传入的scalar的值为起始值,生成递增/递减的索引,并将产生的索引保存在dstReg中。
函数原型
template <typename T = DefaultType, IndexOrder order = IndexOrder::INCREASE_ORDER, typename U, typename S> __simd_callee__ inline void Arange(S& dstReg, U scalarValue);
参数说明
参数名 |
描述 |
|---|---|
T |
目的操作数的数据类型。 Atlas 350 加速卡,支持的数据类型为:int8_t/int16_t/int32_t/half/float/int64_t |
U |
起始索引值的数据类型。 Atlas 350 加速卡,支持的数据类型为:int8_t/int16_t/int32_t/half/float/int64_t |
S |
目的操作数的RegTensor类型, 例如RegTensor<half>,由编译器自动推导,用户不需要填写。 |
参数名 |
输入/输出 |
描述 |
|---|---|---|
dstReg |
输出 |
目的操作数。 类型为RegTensor。 |
scalarValue |
输入 |
源操作数。 类型为标量。 |
约束说明
无
调用示例
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);
}
}
父主题: 索引操作