GET_TILING_DATA_WITH_STRUCT

Function Usage

Specifies a structure name to obtain the specified tiling information and fill the information in the corresponding tiling structure. This function is compiled in macro expansion mode. The difference between GET_TILING_DATA and this API is that GET_TILING_DATA can obtain only the default registered structure. This API can obtain the corresponding structure based on the specified structure name and is used when different structures are registered based on different tiling keys.

Prototype

1
GET_TILING_DATA_WITH_STRUCT(struct_name, tiling_data, tiling_arg)

Parameters

Parameter

Input/Output

Description

struct_name

Input

Name of the specified structure.

tiling_data

Output

Tiling data, for which the specified tiling structure variable is returned.

tiling_arg

Input

Tiling argument of the entrypoint function of the operator.

Availability

Atlas Training Series Product

Constraints

  • This function needs to be used in the operator kernel code, and the type of tiling_data does not need to be declared.
  • Currently, the kernel launch project is not supported.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
extern "C" __global__ __aicore__ void add_custom(__gm__ uint8_t *x, __gm__ uint8_t *y, __gm__ uint8_t *z, __gm__ uint8_t *tiling)
{
    KernelAdd op;
    if (TILING_KEY_IS(1)) {
        GET_TILING_DATA_WITH_STRUCT(Add_Struct_Special, tilingData, tiling); // Use the specified structure registered by the operator.
	op.Init(x, y, z, tilingData.totalLengthSpecial, tilingData.tileNumSpecial);
    } else {
        GET_TILING_DATA(tilingData, tiling);   // Use the default structure registered by the operator.
	op.Init(x, y, z, tilingData.totalLength, tilingData.tileNum);
    }
    if (TILING_KEY_IS(1)) {
        op.Process();
    }  else  if (TILING_KEY_IS(2)) {
        op.Process();
    } else  if (TILING_KEY_IS(3)) {
        op.Process();
    }
}