SetDim
Function Usage
Sets the number of cores that can participate in multi-core Matmul computation. The rules vary in different scenarios.
- CUBE_ONLY (only matrix computation)
Separated architecture: The number of cores loaded by SetBlockDim is that used by the Matmul API for computation. The values of SetDim and SetBlockDim are the same.
- MIX mode (matrix computation and vector computation)
- Separated architecture: The Matmul API is initiated from the AIV. When Iterate is called for computation, the AIV only notifies the AIC to perform matrix computation. Once finished, the AIC notifies the AIV that the computation is complete. For developers, this process corresponds to the number of AIV cores. For example: When SetBlockDim is set to 20, 20 AI Cores (AIC + AIV) are started. When SetDim is set to 40, 40 AIVs are tiled.
- Coupled architecture: The number of cores loaded by SetBlockDim is the same as that used by the Matmul API for computation. The values of SetDim and SetBlockDim are the same.
Prototype
1
|
int32_t SetDim(int32_t dim) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
dim |
Input |
Number of cores that can be used in the multi-core Matmul tiling computation. |
Returns
-1: setting failed; 0: setting succeeded.
Precautions
None
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); matmul_tiling::MultiCoreMatmulTiling tiling(ascendcPlatform); tiling.SetDim (1); // Set the number of cores involved in the computation. 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.SetSingleShape(1024, 1024, 1024); tiling.SetOrgShape(1024, 1024, 1024); tiling.SetBias(true); tiling.SetBufferSpace(-1, -1, -1); optiling::TCubeTiling tilingData; int ret = tiling.GetTiling(tilingData); |
Parent topic: Matmul Tiling Class