SetAType

Function

Sets the position, data format, data type, and transpose status of matrix A. These settings must be consistent with those in the kernel.

Prototype

1
int32_t SetAType(TPosition pos, CubeFormat type, DataType dataType, bool isTrans = false)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

pos

Input

Position in the buffer where matrix A is located, which can be TPosition::GM, TPosition::VECOUT, or TPosition::TSCM.

type

Input

Data format of matrix A, which can be CubeFormat::ND, CubeFormat::NZ, or CubeFormat::VECTOR.

dataType

Input

Data type of matrix A, which can be DataType::DT_FLOAT, DataType::DT_FLOAT16, DataType::DT_BFLOAT16, DataType::DT_INT8, or DataType::DT_INT4.

isTrans

Input

Whether matrix A should be transposed.

Values:

  • true: Matrix A is transposed.
  • false: Matrix A is not transposed.

For the Atlas inference product's AI Core, matrix A cannot be transposed when its data is of the DataType::DT_INT8 type. That is, this parameter cannot be set to true.

Returns

-1: setting failed; 0: setting succeeded.

Restrictions

None

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MatmulApiTiling tiling(ascendcPlatform); 
// Set matrix A, with the buffer located in the GM, data format of ND, data type of bfloat16, and transpose disabled by default.
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);  
tiling.SetBias(true);   
tiling.SetBufferSpace(-1, -1, -1);
optiling::TCubeTiling tilingData;   
int ret = tiling.GetTiling(tilingData);