SetBias
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
x |
|
|
x |
Function Usage
Sets the bias for matrix multiplication.
Prototype
1
|
__aicore__ inline void SetBias(const GlobalTensor<BiasT>& biasGlobal) |
1
|
__aicore__ inline void SetBias(const LocalTensor<BiasT>& inputBias) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
biasGlobal |
Input |
Bias. The type is GlobalTensor. For the Atlas 350 Accelerator Card, the supported data types are half, bfloat16_t, float, and int32_t. The data type of the bias can be set to int32_t only when the data type of matrices A and B is int8_t. For the For the For the For the For details about the data type combinations supported by matrices A and B and the bias, see Combinations of Matmul input and output data types. For details about the data type combinations supported by matrices A and B and the bias in the MxMatmul scenario, see MatmulTypeWithScale parameters. |
|
inputBias |
Input |
Bias. The type is LocalTensor, and TPosition can be TSCM or VECOUT. For the Atlas 350 Accelerator Card, the supported data types are half, bfloat16_t, float, and int32_t. The data type of the bias can be set to int32_t only when the data type of matrices A and B is int8_t. For the For the For the For the For details about the data type combinations supported by matrices A and B and the bias, see Combinations of Matmul input and output data types. For details about the data type combinations supported by matrices A and B and the bias in the MxMatmul scenario, see MatmulTypeWithScale parameters. |
Returns
None
Restrictions
- In Matmul tiling computation, the isBias parameter in the TCubeTiling structure must be set to 1 (that is, the bias is enabled) before this API is called to set the bias.
- Ensure that the size of the input bias address space is greater than or equal to singleN.
- For the Atlas 350 Accelerator Card, if the logical memory location of the bias is TSCM and the data type is float or int32_t, the LocalTensor space of the bias must be 64-byte aligned.
Example
1 2 3 4 5 6 7 8 |
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling); mm.SetTensorA(gm_a); mm.SetTensorB(gm_b); if (tiling.isBias) { mm.SetBias(gmBias); // Set the bias. } mm.IterateAll(gm_c); mm.End(); |