Init

Applicability

Product

API with Tiling Parameter Passed as a Stack Address

API with Tiling Parameter Passed as a Global Memory Address

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

x

Atlas inference product's Vector Core

x

x

Atlas training products

x

x

Function

Initializes tiling data in Matmul objects. Resources are divided based on the tiling parameters. For details about the tiling parameters, see Matmul Tiling APIs.

You can use REGIST_MATMUL_OBJ to initialize a single Matmul object without passing the tiling parameters. Later, you can use the Init API to pass the tiling parameters to adjust the tiling data of the Matmul object. For example, in scenarios where tiling is variable, you can call Init to reset the tiling parameters for multiple times.

If no tiling change is required, you are advised to use REGIST_MATMUL_OBJ to pass tiling parameters for initialization.

Prototype

  • Tiling parameter passed as a stack address:
    1
    __aicore__ inline void Init(const TCubeTiling* __restrict cubeTiling, TPipe* tpipe = nullptr)
    
  • Tiling parameter passed as a global memory address:
    1
    __aicore__ inline void Init(const __gm__ TCubeTiling* gmCubeTiling, TPipe* tpipe = nullptr)
    

Parameters

Table 1 Parameters of the API with the tiling parameter passed as a stack address

Parameter

Input/Output

Description

cubeTiling

Input

Matmul tiling parameter. For details about the definition of the TCubeTiling structure, see Table 1.

The tiling parameter can be obtained through GetTiling on the host side and passed to the kernel side for use. On the kernel side, GET_TILING_DATA is called to move the tiling parameter to the stack space of AI Core. This API receives the tiling parameter by passing the stack address of the TCubeTiling structure.

tpipe

Input

Tpipe object.

Table 2 Parameters of the API with the tiling parameter passed as a global memory address

Parameter

Input/Output

Description

gmCubeTiling

Input

Matmul tiling parameter. It points to a memory address in GM, where the data type is the TCubeTiling structure. For details about the definition of the TCubeTiling struct, see Table 1.

The tiling parameter can be obtained through GetTiling on the host side and passed to the kernel side for use. On the kernel side, GET_TILING_DATA_PTR_WITH_STRUCT is called to obtain the pointer to the tiling parameter in GM. This API receives the tiling parameter by passing the GM address of the TCubeTiling structure.

tpipe

Input

Tpipe object.

Returns

None

Restrictions

  • API with the tiling parameter passed as a stack address:

    None

  • API with the tiling parameter passed as a global memory address:

Example

  • Tiling parameter passed as a stack address:
    1
    2
    3
    4
    GET_TILING_DATA(tilingData, tiling);
    // ...
    REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm);
    mm.Init(&(tiling.cubeTilingData));
    
  • Tiling parameter passed as a global memory address:
    • CUBE-ONLY mode
      1
      2
      3
      4
      5
      6
      7
      #define ASCENDC_CUBE_ONLY
      
      GET_TILING_DATA_PTR_WITH_STRUCT(MatmulCustomTilingData, tilingDataPtr, tiling);
      KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_AIC_ONLY);
      // ...
      REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm);
      mm.Init(&(tilingDataPtr->cubeTilingData));
      
    • MIX mode
      GET_TILING_DATA_PTR_WITH_STRUCT(MatmulCustomTilingData, tilingDataPtr, tiling);
      KERNEL_TASK_TYPE_DEFAULT(KERNEL_TYPE_MIX_AIC_1_2);
      // ...
      // In MIX mode, only the REGIST_MATMUL_OBJ interface is called to pass the GM address of the tiling parameter. The Init interface does not need to be called.
      REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &(tilingDataPtr->cubeTilingData));