LoadDataWithSparse

Applicability

Product

Supported

Atlas 350 Accelerator Card

x

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

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

Moves the 512-byte dense weight matrix stored in B1 to B2, and reads the 128-byte index matrix for sparseness of the dense matrix. The data type of the index matrix is int2, which needs to be combined into the int8 data type before the index matrix is passed to the API.

The index matrix is arranged in a reverse order in an int8 address. For example, the index matrix 1 2 0 1 0 2 1 0 is arranged as 1 0 2 1 0 1 2 0 in the address, where 1 0 2 1 (corresponding to the first 4 bits 1 2 0 1 of the index matrix) is an int8, and 0 1 2 0 (corresponding to the last 4 bits 0 2 1 0 of the index matrix) is an int8.

For details about the functions of the index matrix, see MmadWithSparse.

Prototype

1
2
template <typename T = int8_t, typename U = uint8_t, typename Std::enable_if<Std::is_same<PrimT<T>, int8_t>::value, bool>::type = true, typename Std::enable_if<Std::is_same<PrimT<U>, uint8_t>::value, bool>::type = true>
__aicore__ inline void LoadDataWithSparse(const LocalTensor<T>& dst, const LocalTensor<T>& src, const LocalTensor<U>& idx, const LoadData2dParams& loadDataParam)

Parameters

Table 1 Template parameters

Parameter

Description

T

Data types of dst and src.

U

Data type of idx.

  • When dst, src, and idx are of basic data types, T and U must be the uint8_t type. Otherwise, the compilation fails.
  • When dst, src, and idx are of the TensorTrait type, the LiteType of T and U must be the int8_t type. Otherwise, the compilation fails.

The last two template parameters are used only for checking the preceding data types.

Table 2 Parameters

Parameter

Input/Output

Description

dst

Output

Destination operand of the LocalTensor type. The supported TPosition is B2. The start address of LocalTensor must be 512-byte aligned.

The supported data type is int8_t.

The data must be arranged in the NZ format.

src

Input

Source operand of the LocalTensor type. The supported TPosition is B1. The start address of LocalTensor must be 32-byte aligned.

The supported data type is int8_t.

idx

Input

Source operand of the LocalTensor type. The supported TPosition is B1. The start address of LocalTensor must be 32-byte aligned.

The supported data type is int8_t.

loadDataParam

Input

LoadData parameter structure of the LoadData2DParams type. For details, see Table 3.

Restrictions

  • For details about the operand address alignment requirements, see General Address Alignment Restrictions.
  • If repeat is set to 0, no operation is performed.
  • The value of startIndex in each iteration must not be less than 0.
  • The transpose function is not supported.

Returns

None

Examples

For details, see MmadWithSparse.