Arange
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Function Usage
Generates an ascending or descending index with the input scalar value as the start value and saves the generated index in dstReg.
Prototype
template <typename T = DefaultType, IndexOrder order = IndexOrder::INCREASE_ORDER, typename U, typename S> __simd_callee__ inline void Arange(S& dstReg, U scalarValue);
Parameters
Parameter |
Description |
|---|---|
T |
Data type of the destination operand. For the Atlas 350 Accelerator Card, the supported data types are int8_t, int16_t, int32_t, half, float, and int64_t. |
U |
Data type of the start index value. For the Atlas 350 Accelerator Card, the supported data types are int8_t, int16_t, int32_t, half, float, and int64_t. |
S |
RegTensor type of the destination operand, for example, RegTensor<half>. It is automatically inferred by the compiler and does not need to be specified. |
Parameter |
Input/Output |
Description |
|---|---|---|
dstReg |
Output |
Destination operand. The type is RegTensor. |
scalarValue |
Input |
Source operand. The type is scalar. |
Constraints
None
Example
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);
}
}