Load2DMX

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

Supports data transfer over the following paths:

GM -> A1; GM -> B1; GM -> A2; GM -> B2;

A1 -> A2; B1 -> B2.

Prototype

  • Load2DMX API
    1
    2
    template <typename T, typename U = T>
    __aicore__ inline void LoadData(const LocalTensor<U>& dst, const LocalTensor<T>& src, const LocalTensor<fp8_e8m0_t>& srcMx, const LoadData2DParamsV2& loadDataParams, const LoadData2DMxParams& loadMxDataParams)
    
  • The Load2Dv2MX API supports different data types for source and destination operands.
    1
    2
    template <typename T, typename U>
    __aicore__ inline void LoadData(const LocalTensor<U>& dst, const LocalTensor<T>& src0, const LocalTensor<fp8_e8m0_t>& srcMx, const LoadData2DParamsV2& loadDataParams, const LoadData2DMxParams& loadMxDataParams)
    

Parameters

Table 1 Template parameters

Parameter

Description

T

Data types of the source and destination operands.

  • Load2DMX API:

    For the Atlas 350 Accelerator Card, the supported data types are fp4x2_e2m1_t, fp4x2_e1m2_t, fp8_e4m3fn_t, and fp8_e5m2_t.

U

  • For the Load2DMX API, U indicates the data type of dst. When src is of type fp8_e4m3fn_t or fp8_e5m2_t, U must be the MX data type corresponding to T, that is, AscendC::mx_fp8_e4m3_t or AscendC::mx_fp8_e5m2_t. Otherwise, the compilation fails. For other data types, T and U must be identical.
Table 2 Common parameters

Parameter

Input/Output

Description

dst

Output

Destination operand, which is of the LocalTensor type.

The sequential arrangement of data is determined by TPosition of the destination operand. The constraints are as follows:

  • When storing data in A2, use the ZZ or NZ format, with the fractal matrix size of 16 × (32 bytes/sizeof(T)).
  • When storing data in B2, use the ZN format, with the fractal matrix size of (32 bytes/sizeof(T)) × 16.
  • When storing data in A1 or B1, there is no format restriction. Generally, the data is in NZ format, with the fractal matrix size of 16 × (32 bytes/sizeof(T)).

src

Input

Source operand, which is of the LocalTensor or GlobalTensor type.

Its data type must be the same as that of dst.

srcMx

Input

Source operand, which is of the LocalTensor type. Only the fp8_e8m0_t type is supported.

loadDataParams

Input

LoadData parameter structure. Supported types are as follows:

  • LoadData2DMxParams. For details, see Table 3.

For details, see ${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_mm.h. Replace ${INSTALL_DIR} with the actual path for storing files after the CANN software is installed.

Table 3 Parameters in the LoadData2DMxParams structure

Parameter

Description

xStartPosition

Start position along the X-axis (M dimension) of the source matrix. The unit is one fractal, where one unit corresponds to a 32-byte fractal.

yStartPosition

Start position along the Y-axis (K dimension) of the source matrix. The unit is 32 bytes.

xStep

Transfer length along the X-axis (M dimension) of the source matrix. The unit is one fractal, where one unit corresponds to a 32-byte fractal. Value range: xStep ∈ [0, 255].

yStep

Transfer length along the Y-axis (K dimension) of the source matrix. The unit is 32 bytes. Value range: yStep ∈ [0, 255].

srcStride

Interval between the start addresses of adjacent fractals along the X dimension of the source matrix. The unit is 32 bytes.

dstStride

Interval between the start addresses of adjacent fractals along the X dimension of the destination matrix. The unit is 32 bytes.

The following uses an example to describe the parameters in the LoadData2DMX structure. Assume that the shape of matrix A is (M, K). Then, the shape of matrix ScaleA is (M, K/32), and the data type of ScaleA is fp8_e8m0_t. Figure 1 shows the fractal arrangement of ScaleA.

Figure 1 Fractal arrangement of ScaleA in L0A

The following figure shows the configuration parameters for transferring ScaleA from L1 to L0A. Each row is 32 bytes, corresponding to one fractal in Figure 1. xStep indicates the number of fractals along the M dimension, for example, xStep = M/16 = 3 in the figure. yStep indicates the number of 32-byte units along the K dimension, for example, yStep = K/32/2 = 21 in the figure. srcStride and dstStride work in the same way and indicate the number of 32-byte units along the K dimension.

Restrictions

Returns

None