SetMatmulConfigParams
Function
Sets the MatmulConfig parameters in Table 1 for tiling computation. The functions of the parameters configured in this API must be the same in the tiling and in the kernel. Therefore, the parameter values in this API must be the same as those of the MatmulConfig parameters in the kernel. For details about the MatmulConfig parameters, see Table 2.
Prototype
1 | void SetMatmulConfigParams(int32_t mmConfigTypeIn = 1, bool enableL1CacheUBIn = false, ScheduleType scheduleTypeIn = ScheduleType::INNER_PRODUCT, MatrixTraverse traverseIn = MatrixTraverse::NOSET, bool enVecND2NZIn = false) |
1 | void SetMatmulConfigParams(const MatmulConfigParams& configParams) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
mmConfigTypeIn |
Input |
Matmul template type, which must be the same as the template created by the Matmul object. Currently, the value can only be 0 or 1.
|
||
enableL1CacheUBIn |
Input |
Whether to cache UB computing blocks in L1. It can be enabled in scenarios where MTE3 and MTE2 serial pipelines are applied.
For the For the For the For the |
||
scheduleTypeIn |
Input |
Matmul data movement mode. The values are as follows:
|
||
traverseIn |
Input |
Cyclic iteration sequence for Matmul to perform matrix computation, that is, the offset sequence in which Matmul automatically offsets to the output position of Matrix C for the next iteration after a matrix C slice with the size of [baseM, baseN] is computed in one iteration. The values are as follows:
|
||
enVecND2NZIn |
Input |
Whether to enable ND2NZ. |
||
configParams |
Input |
config parameter. It is of the MatmulConfigParams type. The structure is defined as follows: For details about the parameters, see Table 2.
|
Parameter |
Description |
||
|---|---|---|---|
mmConfigType |
Matmul template type, which must be the same as the template created by the Matmul object. Currently, the value can only be 0 or 1.
|
||
enableL1CacheUB |
Whether to cache UB computing blocks in L1. It can be enabled in scenarios where MTE3 and MTE2 serial pipelines are applied.
|
||
scheduleType |
Matmul data movement mode. The values are as follows:
|
||
traverse |
Cyclic iteration sequence for Matmul to perform matrix computation, that is, the offset sequence in which Matmul automatically offsets to the output position of Matrix C for the next iteration after a matrix C slice with the size of [baseM, baseN] is computed in one iteration. The values are as follows:
|
||
enVecND2NZ |
Whether to enable ND2NZ. |
Returns
None
Restrictions
- This API must be called before the GetTiling API.
- If the Matmul object uses the NBuffer33 template policy, which means MatmulPolicy is set to NBuffer33MatmulPolicy, before calling the GetTiling API to generate tiling parameters, you must call the API in this section to set the scheduleTypeIn parameter to ScheduleType::N_BUFFER_33 to enable the tiling generation logic of the NBuffer33 template policy.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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); tiling.SetMatmulConfigParams(0); // Additional settings // tiling.SetMatmulConfigParams({1, false, ScheduleType::OUTER_PRODUCT, MatrixTraverse::FIRSTM}); optiling::TCubeTiling tilingData; int ret = tiling.GetTiling(tilingData); |