SetOrgShape

Function

Sets the original complete shape M, N, K, Ka, or Kb for Matmul computation. The unit is the number of elements.

Prototype

1
int32_t SetOrgShape(int32_t orgMIn, int32_t orgNIn, int32_t orgKIn)
1
int32_t SetOrgShape(int32_t orgMIn, int32_t orgNIn, int32_t orgKaIn, int32_t orgKbIn)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

orgMIn

Input

Sets the size of the original complete shape M. The unit is element.

orgNIn

Input

Sets the size of the original complete shape N. The unit is element.

orgKIn

Input

Sets the size of the original complete shape K. The unit is element. This parameter can be set if the original complete shape meets the condition of Ka = Kb.

orgKaIn

Input

Sets the size of the original complete shape Ka of matrix A. The unit is element.

orgKbIn

Input

Sets the size of the original complete shape Kb of matrix B. The unit is element.

Returns

-1: setting failed; 0: setting succeeded.

Restrictions

Values of the orgKaIn and orgKbIn parameters can be different, that is, the original matrix shapes Ka and Kb can be different. They are not the actual K value used in Matmul computation. These parameters are used only to assist in offset computation during data movement by the Matmul API.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MatmulApiTiling tiling(ascendcPlatform); 
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.SetOrgShape(1024, 1024, 1024);  // Set the original complete shape.
tiling.SetBias(true);   
tiling.SetBufferSpace(-1, -1, -1);
optiling::TCubeTiling tilingData;   
int ret = tiling.GetTiling(tilingData);