Arange

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

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

Table 1 Template 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.

Table 2 Function parameters

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);
    }
}