GetTiling

Function

Obtains tiling parameters.

Prototype

1
int64_t GetTiling(optiling::TCubeTiling &tiling)
1
int64_t GetTiling(AscendC::tiling::TCubeTiling &tiling)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

tiling

Output

The tiling structure stores the final tiling result. For details about the TCubeTiling structure, see Table 1.

  • optiling::TCubeTiling: TCubeTiling structure with the optiling namespace. It is the Matmul TilingData defined on the host.
  • AscendC::tiling::TCubeTiling: TCubeTiling structure with the AscendC::tiling namespace. It is the Matmul TilingData defined in the kernel. It is used together with the TilingData structure defined using the standard C++ syntax. For details, see Using the Standard C++ Syntax to Define the Tiling Structure.

Returns

If the return value is not -1, the tiling computation is successful. You can use the value of the tiling structure. If the return value is -1, the tiling computation fails and the tiling result cannot be used.

Restrictions

If the tiling computation fails and you need to view the failure cause, set the log level to WARNING and search for the keyword MatmulApi Tiling in the log. For details about how to set the log level, see Environment Variables"Log" > "ASCEND_GLOBAL_LOG_LEVEL".

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MatmulApiTiling tiling(ascendcPlatform); 
tiling.SetAType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT16); 
tiling.SetBType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT16);   
tiling.SetCType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT);   
tiling.SetBiasType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT);   
tiling.SetShape(1024, 1024, 1024);   
tiling.SetOrgShape(1024, 1024, 1024);  
tiling.SetBias(true);   
tiling.SetBufferSpace(-1, -1, -1);
optiling::TCubeTiling tilingData;   
int ret = tiling.GetTiling(tilingData);  // Obtain tiling parameters.