SetBias

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference product's AI Core

Atlas inference product's Vector Core

x

Atlas training products

x

Function

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 A3 training products/Atlas A3 inference products, the supported data types are half, float, and int32_t. The data type of 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's AI Core, the supported data types are half, float, and int32_t. The data type of 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 products/Atlas A2 inference products, the supported data types are half, float, and int32_t. The data type of 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 products, the supported data types are half, float, and int32_t. The data type of 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 Table 2.

inputBias

Input

Bias. The type is LocalTensor, and TPosition can be VECOUT.

For the Atlas A3 training products/Atlas A3 inference products, the supported data types are half, float, and int32_t. The data type of 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's AI Core, the supported data types are half, float, and int32_t.

For the Atlas A2 training products/Atlas A2 inference products, the supported data types are half, float, and int32_t. The data type of 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 products, the supported data types are half, float, and int32_t. The data type of 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 Table 2.

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.

Example

1
2
3
4
5
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetBias(gm_bias);    // Set the bias.
mm.IterateAll(gm_c);