SetCType

Function

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

Prototype

1
int32_t SetCType(TPosition pos, CubeFormat type, DataType dataType)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

pos

Input

Position in the buffer where matrix C is located, which can be TPosition::GM or TPosition::VECIN.

type

Input

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

dataType

Input

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

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); 
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);  
// Set matrix C, with the buffer located in the GM, data format of ND, data type of float, and transpose disabled by default.
tiling.SetCType(matmul_tiling::TPosition::GM, matmul_tiling::CubeFormat::ND, matmul_tiling::DataType::DT_FLOAT);
tiling.SetBiasType(AscendC::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);