SetBias

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

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

Table 1 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 Atlas A3 training product / Atlas A3 inference product , the supported data types are half, 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 Atlas inference product AI Core, the supported data types are half, 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 Atlas A2 training product / Atlas A2 inference product , the supported data types are half, 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 Atlas 200I/500 A2 inference product , the supported data types are half, 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 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 Atlas A3 training product / Atlas A3 inference product , the supported data types are half, 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 Atlas inference product AI Core, the supported data types are half, float, and int32_t.

For the Atlas A2 training product / Atlas A2 inference product , the supported data types are half, 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 Atlas 200I/500 A2 inference product , the supported data types are half, 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 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();