SetSparseIndex

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

Sets the index matrix generated during the dense process of sparse matrices.

For details about the role of the index matrix in the dense process, see MmadWithSparse.

Prototype

1
__aicore__ inline void SetSparseIndex(const GlobalTensor<uint8_t>& indexGlobal)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

indexGlobal

Input

First address of the index matrix in the global memory. The data type is GlobalTensor.

If the data type of the index matrix is uint2, you need to convert it to uint8 and then pass it to this API. The index matrix supports only the NZ format.

Returns

None

Restrictions

  • The format of the index matrix must be NZ.
  • This API is supported only in CUBE_ONLY mode and the MDL template scenario.

Example

1
2
3
4
5
6
7
#define ASCENDC_CUBE_ONLY // Enable the CUBE_ONLY mode.
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetSparseIndex(gm_index); // Set the index matrix.
mm.SetBias(gm_bias);  
mm.IterateAll(gm_c);