CalcTschBlockDim

Function

针对Cube、Vector分离模式,用于计算Cube、Vector融合算子的blockDim。Operators for Vector/Cube fusion computing are started by groups of AIVs and AICs. blockDim 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 is used to automatically obtain a proper blockDim value.

After obtaining the value, use SetBlockDim to set the blockDim.

Prototype

1
uint32_t CalcTschBlockDim(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.CalcTschBlockDim(sliceNum, aicNum, aivNum));
    return ret;
}