CalcTschNumBlocks
Function Usage
Computes the numBlocks for a fused operator that uses both Cube and Vector units in the Cube-Vector separated mode. Operators for Vector/Cube fusion computing are started by groups of AIVs and AICs. numBlocks is used to set the number of groups to be started. For example, if an AI processor has 40 Vector cores and 20 Cube cores, a group consists of two Vector cores and one Cube core. Set the number of groups to 20. In this case, 20 groups are started, including 40 Vector cores and 20 Cube cores. This API can be used to automatically obtain a proper value of numBlocks.
After obtaining the value, use SetBlockDim to set numBlocks.
Prototype
1
|
uint32_t CalcTschNumBlocks(uint32_t sliceNum, uint32_t aicCoreNum, uint32_t aivCoreNum) const |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
sliceNum |
Input |
Number of data slices. |
|
aicCoreNum |
Input |
If cube computation APIs are used for operator implementation, pass the number returned by GetCoreNumAic. Otherwise, pass 0. |
|
aivCoreNum |
Input |
If vector computation APIs are used for operator implementation, pass the number returned by GetCoreNumAiv. Otherwise, pass 0. |
Returns
Number of cores used for underlying task scheduling
Constraints
None
Examples
1 2 3 4 5 6 7 8 9 |
ge::graphStatus TilingXXX(gert::TilingContext* context) { auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo()); auto aicNum = ascendcPlatform.GetCoreNumAic(); auto aivNum = ascendcPlatform.GetCoreNumAiv(); // ..Split data by aivNum and perform the computation. uint32_t sliceNum = aivNum; context->SetBlockDim(ascendcPlatform.CalcTschNumBlocks(sliceNum, aicNum, aivNum)); return ret; } |