SetALayout

Function

Sets the layout axes of matrix A, including the B, S, N, G, and D axes. For the BSNGD, SBNGD, and BNGS1S2 layouts, before calling the IterateBatch API, you need to use this API to set the layout axes of matrix A in the tiling implementation on the host.

Prototype

1
int32_t SetALayout(int32_t b, int32_t s, int32_t n, int32_t g, int32_t d)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

b

Input

Layout B axis information of matrix A

s

Input

Layout S axis information of matrix A

n

Input

Layout N axis information of matrix A

g

Input

Layout G axis information of matrix A

d

Input

Layout D axis information of matrix A

Returns

-1: setting failed; 0: setting succeeded.

Restrictions

For the BSNGD, SBNGD, and BNGS1S2 layouts, before calling the IterateBatch API, you need to use this API to set the layout axes of matrix A in the tiling implementation on the host.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MultiCoreMatmulTiling tiling(ascendcPlatform);   
int32_t M = 32;
int32_t N = 256;
int32_t K = 64;
tiling->SetDim(1);
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(M, N, K);
tiling->SetOrgShape(M, N, K);
tiling->SetBias(true);
tiling->SetBufferSpace(-1, -1, -1);

constexpr int32_t A_BNUM = 2;
constexpr int32_t A_SNUM = 32;
constexpr int32_t A_GNUM = 3;
constexpr int32_t A_DNUM = 64;
constexpr int32_t B_BNUM = 2;
constexpr int32_t B_SNUM = 256;
constexpr int32_t B_GNUM = 3;
constexpr int32_t B_DNUM = 64;
constexpr int32_t C_BNUM = 2;
constexpr int32_t C_SNUM = 32;
constexpr int32_t C_GNUM = 3;
constexpr int32_t C_DNUM = 256;
constexpr int32_t BATCH_NUM = 3;
tiling->SetALayout(A_BNUM, A_SNUM, 1, A_GNUM, A_DNUM);  // Set the layout of matrix A.
tiling->SetBLayout(B_BNUM, B_SNUM, 1, B_GNUM, B_DNUM);
tiling->SetCLayout(C_BNUM, C_SNUM, 1, C_GNUM, C_DNUM);
tiling->SetBatchNum(BATCH_NUM);
tiling->SetBufferSpace(-1, -1, -1);

optiling::TCubeTiling tilingData;
int ret = tiling.GetTiling(tilingData);