SetBlockDim

Description

Sets blockDim, which refers to the number of Vector cores or Cube cores involved in computation.

Prototype

ge::graphStatus SetBlockDim(const uint32_t block_dim)

Parameters

Parameter

Input/Output

Description

block_dim

Input

blockDim is a concept about logical cores, and its value range is [1, 65535]. To fully utilize hardware resources, set this parameter to the number of physical cores or a multiple of the number of physical cores. For the coupled architecture and separated architecture, the meaning and setting rules of blockDim during running are different. The details are as follows:

  • Coupled architecture: Because the Vector and Cube Units are integrated, blockDim is used to start multiple AI Core instances, without differentiating Vector Units and Cube Units. The number of AI Cores can be obtained by calling GetCoreNumAiv or GetCoreNumAic.
  • Separated architecture:
    • For operators that contain only Vector Units, blockDim is used to set the number of Vector (AIV) instances to be started. For example, if an AI processor has 40 Vector cores, set blockDim to 40.
    • For operators that contain only Cube Units, blockDim is used to set the number of Cube (AIC) instances to be started. For example, if an AI processor has 20 Cube cores, set blockDim to 20.
    • 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. Note: In this scenario, the value of blockDim (logical cores) cannot exceed the number of physical cores (a physical core contains two Vector cores and one Cube core).
    • The number of AIC and AIV cores can be obtained by calling GetCoreNumAic and GetCoreNumAiv, respectively.

Returns

ge::GRAPH_SUCCESS on success.

For details about the definition of graphStatus, see ge::graphStatus.

Restrictions

None

Example

ge::graphStatus Tiling4XXX(TilingContext* context) {
  auto ret = context->SetBlockDim(32);
  // ...
}