SetSingleShape

Function Usage

Sets the Matmul single-core computation shape parameters: singleMIn, singleNIn, and singleKIn, with the unit being elements.

Prototype

1
int32_t SetSingleShape(int32_t singleMIn = -1, int32_t singleNIn = -1, int32_t singleKIn = -1)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

singleMIn

Input

Size of singleMIn. The unit is element. The default value is -1 The value -1 indicates that singleMIn is not set. Instead, it is calculated by the tiling function.

singleNIn

Input

Size of singleNIn. The unit is element. The default value is -1. The value -1 indicates that singleNIn is not set. Instead, it is calculated by the tiling function.

singleKIn

Input

Size of singleKIn. The unit is element. The default value is -1. The value -1 indicates that singleKIn is not set. Instead, it is calculated by the tiling function.

Returns

-1: setting failed; 0: setting succeeded.

Restrictions

  • In the MxMatmul scenario, if both matrices A and B are located in GM, there is no special restriction on singleKIn. In this case, if the K dimension size of scaleA and scaleB (that is, Ceil(singleKIn, 32)) is odd, you must manually pad zeros in the K direction until it becomes even. For example, when singleKIn is 30 and Ceil (singleKIn, 32) is 1, you must manually pad zeros in the K direction of scaleA and scaleB until the K direction size becomes even. For other combinations (matrices A and B not both in GM), the value of singleKIn, after being aligned upward to 32 elements, must be an even multiple of 32.
  • In the MxMatmul scenario, if the input data type is fp4x2_e2m1_t or fp4x2_e1m2_t, the inner axis must be even.

Examples

1
2
3
4
5
6
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MultiCoreMatmulTiling tiling(ascendcPlatform); 
   
tiling.SetShape(1024, 1024, 1024);  // Set the shape of a single Matmul computation.
tiling.SetSingleShape(1024, 1024, 1024);  // Set the shape of single-core computation.
tiling.SetOrgShape(1024, 1024, 1024);