SetTensorB
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
x |
Function Usage
Sets the right matrix B for matrix multiplication.
Prototype
1 | __aicore__ inline void SetTensorB(const GlobalTensor<SrcBT>& gm, bool isTransposeB = false) |
1 | __aicore__ inline void SetTensorB(const LocalTensor<SrcBT>& rightMatrix, bool isTransposeB = false) |
1 | __aicore__ inline void SetTensorB(SrcBT bScalar) |
The
The
Parameters
Parameter |
Description |
|---|---|
SrcBT |
Operand data type. |
Parameter |
Input/Output |
Description |
|---|---|---|
gm |
Input |
Matrix B. The type is GlobalTensor. SrcBT indicates the data type of matrix B. For the Atlas 350 Accelerator Card, the supported data types are half, float, bfloat16_t, int8_t, fp8_e4m3fn_t, fp8_e5m2_t, and hifloat8_t. For the For the For the For the |
rightMatrix |
Input |
Matrix B. The type is LocalTensor, and TPosition can be TSCM or VECOUT. SrcBT indicates the data type of matrix B. For the Atlas 350 Accelerator Card, the supported data types are half, float, bfloat16_t, int8_t, fp8_e4m3fn_t, fp8_e5m2_t, and hifloat8_t. For the For the For the For the 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 B in the K direction by setting bScalar to 1. SrcBT indicates the data type of matrix B. For the Atlas 350 Accelerator Card, the supported data types are half and float. For the For the This parameter is not supported by the This parameter is not supported by the |
isTransposeB |
Input |
Whether matrix B should be transposed. Notes:
|
Returns
None
Restrictions
Ensure that the size of the input TensorB address space is greater than or equal to singleK x singleN.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 | REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling); mm.SetTensorA(gm_a); // Example 1: The right matrix is in the global memory. mm.SetTensorB(gm_b, isTransposeB); if (tiling.isBias) { mm.SetBias(gmBias); } mm.IterateAll(gm_c); mm.End(); // Example 2: The right matrix is in the local memory. mm.SetTensorB(local_a, isTransposeB); // Example 3: Set scalar data. mm.SetTensorB(scalar_a, isTransposeB); |