Interleave

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

Interleaves the elements from given source operands src0 and src1 and stores them in the result operands dst0 and dst1. The following figure shows the interleaving pattern, where each cell represents an element.

Prototype

1
2
template <typename T>
__aicore__ inline void Interleave(const LocalTensor<T>& dst0, const LocalTensor<T>& dst1, const LocalTensor<T>& src0, const LocalTensor<T>& src1, const int32_t count)

Parameters

Table 1 Parameters in the template

Parameter

Description

T

Operand data type.

Table 2 Parameters

Parameter

Input/Output

Description

dst0/dst1

Output

Destination operand.

The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT.

The start address of LocalTensor must be 32-byte aligned.

For the Atlas 350 Accelerator Card, the supported data types are uint8_t, int8_t, uint16_t, int16_t, half, bfloat16_t, uint32_t, int32_t, float, uint64_t, and int64_t.

src0/src1

Input

Source operand.

The type is LocalTensor, and TPosition can be VECIN, VECCALC, or VECOUT.

The start address of LocalTensor must be 32-byte aligned.

The source operand must have the same data type as the destination operand.

For the Atlas 350 Accelerator Card, the supported data types are uint8_t, int8_t, uint16_t, int16_t, half, bfloat16_t, uint32_t, int32_t, float, uint64_t, and int64_t.

count

Input

Number of input or output data elements. The length of dst0, dst1, src0, and src1 equals count. count must be an even number.

Returns

None

Restrictions

None

Examples

These examples show only part of the code used in the computation.
1
AscendC::Interleave(dst0Local, dst1Local, src0Local, src1Local, 512);

Result example:

Input (src0Local): [1 2 3 ... 512]
Input (src1Local): [513 514 515 ... 1024]
Output (dst0Local): [1 513 2 ... 768]
Output (dst1Local): [257 769 258 ... 1024]