SetBType

Function Usage

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

Prototype

1
int32_t SetBType(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 B is located, which can be TPosition::GM, TPosition::VECOUT, or TPosition::TSCM.

type

Input

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

dataType

Input

Data type of matrix B, which can be DataType::DT_FLOAT, DataType::DT_FLOAT16, DataType::DT_BFLOAT16, DataType::DT_FLOAT8_E4M3FN, DataType::DT_FLOAT8_E5M2, DataType::DT_HIFLOAT8, DataType::DT_INT8, or DataType::DT_INT4.

isTrans

Input

Whether matrix B should be transposed.

Values:

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

Returns

-1: setting failed; 0: setting succeeded.

Restrictions

None

Example

1
2
3
4
auto ascendcPlatform = platform_ascendc::PlatformAscendC(context->GetPlatformInfo());
matmul_tiling::MatmulApiTiling tiling(ascendcPlatform); 
// Set matrix B, with the buffer located in the GM, data format of ND, data type of bfloat16, and transpose disabled by default.
tiling.SetBType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT16);