SetSplitK

Function

This API has the same functions as the EnableMultiCoreSplitK API. You are advised to use the EnableMultiCoreSplitK API.

In the multi-core scenario, this API is used to enable K-axis splitting. If this API is not called, the K axis is not split by default. This API is used before the GetTiling API is called.

Prototype

1
void SetSplitK(bool flag)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

flag

Input

Whether to enable K-axis splitting.

  • true: K-axis splitting is enabled.
  • false: K-axis splitting is disabled.

Returns

None

Restrictions

  • If this API is used in an operator, the matrix C result can be output only to the Global Memory.
  • If this API is used in an operator, clear the Global Memory before writing the matrix C slice result to the Global Memory in code in the kernel for the first time, and then enable the AtomicAdd operation when obtaining the matrix C slice result. If the Global Memory is not cleared in advance, precision problems may occur due to original invalid data in Global Memory during accumulation.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo())
matmul_tiling::MultiCoreMatmulTiling tiling(ascendcPlatform);  
tiling->SetDim(useCoreNums);
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(M, N, K);
tiling->SetOrgShape(M, N, K);
tiling->SetBias(true);
tiling->SetBufferSpace(-1, -1, -1);
tiling->SetSplitK(true);

optiling::TCubeTiling tilingData;
int ret = tiling.GetTiling(tilingData);