GetMatmulApiTiling
Function Usage
Obtains the Matmul static tiling parameters at compile time.
When the API is called to obtain a MatmulConfig template, if you set (baseM, baseN, and baseK) or (baseM, baseN, baseK, singleCoreM, singleCoreN, and singleCoreK) to constants, you will obtain a MatmulConfig template with these constant parameter values. Subsequently, by using this API, the tiling information can be converted into constants. This API returns the Matmul static tiling information and MatmulConfig template.
When the API is called to obtain a MatmulConfig template, if only baseM, baseN, and baseK are set to constants (referred to as partial constants), singleCoreM, singleCoreN, and singleCoreK remain at their default value (0), tiling is still required for initializing the Matmul object on the Kernel with REGIST_MATMUL_OBJ. If baseM, baseN, baseK, singleCoreM, singleCoreN, and singleCoreK are set to constants (referred to as full constants), a null pointer can be used in the place where the tiling parameters are passed to REGIST_MATMUL_OBJ.
Prototype
1 2 | template<class A_TYPE, class B_TYPE, class C_TYPE, class BIAS_TYPE> __aicore__ constexpr MatmulApiStaticTiling GetMatmulApiTiling(const MatmulConfig& mmCFG, int32_t l1Size = L1_SIZE) |
Parameters
Parameter |
Description |
|---|---|
A_TYPE |
Type of matrix A, which is defined by MatmulType. |
B_TYPE |
Type of matrix B, which is defined by MatmulType. |
C_TYPE |
Type of matrix C, which is defined by MatmulType. |
BIAS_TYPE |
Type of matrix BIAS, which is defined by MatmulType. |
Parameter |
Input/Output |
Description |
|---|---|---|
mmCFG |
Input |
Obtained MatmulConfig template. |
l1Size |
Input |
Available space on L1. The default value is L1_SIZE. |
Returns
Availability
Precautions
- When the API is called to obtain a MatmulConfig template, set (baseM, baseN, and baseK) or (baseM, baseN, baseK, singleCoreM, singleCoreN, and singleCoreK) to constants, which must be consistent with the calculated values of Tiling.
- In the Batch Matmul scenario, full constants are supported, but a null pointer cannot be used to replace the input parameter Tiling of REGIST_MATMUL_OBJ.
Example
1 2 3 4 5 6 7 8 | // Define the Matmul object. typedef matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> aType; typedef matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, half> bType; typedef matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> cType; typedef matmul::MatmulType<AscendC::TPosition::GM, CubeFormat::ND, float> biasType; // Use the GetNormalConfig API to obtain CFG and set the known singleshape information and baseM, baseN, and baseK to values the same as those of Tiling during runtime. constexpr auto staticTiling = GetMatmulApiTiling<aType, bType, cType, biasType>(CFG, 524288); matmul::Matmul<aType, bType, cType, biasType, staticTiling > mm; |