目录

SetTensorB

Function Description

Sets the right matrix B for matrix multiplication.

Function Prototype

__aicore__ inline void SetTensorB(const GlobalTensor<SrcBT>& gm, bool isTransposeB = false)
__aicore__ inline void SetTensorB(const LocalTensor<SrcBT>& rightMatrix, bool isTransposeB = false)
__aicore__ inline void SetTensorB(SrcBT bScalar)

Parameters

Table 1 Parameters

Parameter Input/Output Description
gm Input

Initial address of matrix B in the Global Memory.

For Kirin 9020 and Kirin 9030 series processors, the supported data type is half.

rightMatrix Input

Initial address of matrix B in the TSCM or VECOUT.

For Kirin 9020 and Kirin 9030 series processors, the supported data type is half.

If the initial address in the TSCM is set, the matrix can be fully loaded by default. In this case, the Iterate API does not need to transfer data from GM to A1/B1.

bScalar Input

Value set in matrix B. Scalar data can be passed. The passed scalar data is expanded into a tensor with the shape of [1, K] to participate in matrix multiplication. The tensor values are all scalar values. For example, a developer can implement a reduce sum operation on matrix A in the K direction by setting bScalar to 1.

For Kirin 9020 and Kirin 9030 series processors, the supported data type is half.

isTransposeB Input

Whether matrix B should be transposed.

NOTE

- If MatmulType ISTRANS of matrix B is set to true, this parameter can be set to either true or false at runtime, allowing for alternating use of transposed and non-transposed matrix B.

- If MatmulType ISTRANS of matrix B is set to false, this parameter can only be set to false. If it is forcibly set to true, the precision will be abnormal.

Return Value

None

Supported Models

Kirin 9020 series processors

Kirin 9030 series processors

Precautions

Ensure that the size of the input TensorB address space is greater than or equal to singleK x singleN.

Calling Example

REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b); // Set the right cube B.
mm.SetBias(gm_bias);
mm.IterateAll(gm_c);