BroadCastVecToMM(ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

x

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

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Broadcasts vector data to a matrix. Every 16 elements in each data block are consecutively copied 16 times. The data is moved from VECIN, VECCALC, or VECOUT to CO1.

Figure 1 Example

Prototype

1
2
template <typename T, typename U>
__aicore__ inline void BroadCastVecToMM(const LocalTensor<T> &dst, const LocalTensor<U> &src, const int32_t blockCount, const uint8_t blockLen, const uint8_t srcGap, const uint8_t dstGap)

Parameters

Table 1 Template parameters

Parameter

Description

T

Data type of dst.

For the Atlas inference product AI Core, the supported data types are half, int16_t, and uint16_t.

U

Data type of src.

For the Atlas inference product AI Core, the supported data types are half, int16_t, and uint16_t.

Table 2 Parameters

Parameter

Input/Output

Description

dst

Output

Destination operand. It represents the result matrix, which must be of type LocalTensor, and its TPosition is CO1.

The start address of LocalTensor must be 256-element aligned.

The supported data types are half, float, and int32_t.

src

Input

The source operand is a vector that will be broadcast into the matrix. It must be of type LocalTensor, and its TPosition can be VECIN, VECCALC, or VECOUT.

The supported data types must be the same as those of dst.

blockCount

Input

Number of data chunks to be broadcasted. Value range: blockCount ∈ [1, 255].

blockLen

Input

Length of each data chunk to be broadcasted. The unit is 16 elements. Value range: blockLen ∈ [1, 255].

srcGap

Input

Interval between adjacent data chunks of the source operand (the interval between the tail of one data chunk and the head of the next). The unit is a data block (32 bytes).

dstGap

Input

Interval between adjacent data chunks of the destination operand (the interval between the tail of one data chunk and the head of the next). The unit is 256 elements.

Restrictions

Examples

In this example, the shape of the input bias is [1, 32], the shape of the output c is [32, 32], and the format is Nz.

Figure 2 Examples

This example shows only part of the code in the example.

// brcLocal is a floating-point local tensor located at CO1, and biasLocal is a floating-point local tensor located at VECOUT.
// blockCount = 1 indicates that the number of data chunks to be broadcasted is 1. blockLen = 1 indicates that each data chunk contains 16 elements. A total of 256 elements are output.
// srcGap = 0 indicates that the source operand has no gap between consecutive elements. dstGap = 1 indicates that the destination operand has a stride of 1 between consecutive elements.
AscendC::BroadCastVecToMM(brcLocal, biasLocal, 1, 1, 0, 1)