SetTensorA

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 left matrix A for matrix multiplication.

Prototype

1
__aicore__ inline void SetTensorA(const GlobalTensor<SrcAT>& gm, bool isTransposeA = false)
1
__aicore__ inline void SetTensorA(const LocalTensor<SrcAT>& leftMatrix, bool isTransposeA = false)
1
__aicore__ inline void SetTensorA(SrcAT aScalar)

The SetTensorA(SrcAT aScalar) API prototype is not supported by the Atlas inference product's AI Core.

The SetTensorA(SrcAT aScalar) API prototype is not supported by the Atlas 200I/500 A2 inference products.

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

gm

Input

Matrix A. The type is GlobalTensor. SrcAT indicates the data type of matrix A.

For the Atlas A3 training products/Atlas A3 inference products, the supported data types are half, float, bfloat16_t, int8_t, and int4b_t.

For the Atlas A2 training products/Atlas A2 inference products, the supported data types are half, float, bfloat16_t, int8_t, and int4b_t.

For the Atlas inference product's AI Core, the supported data types are half, float, and int8_t.

For the Atlas 200I/500 A2 inference products, the supported data types are half, float, bfloat16_t, and int8_t.

leftMatrix

Input

Matrix A. The type is LocalTensor, and TPosition can be TSCM or VECOUT. SrcAT indicates the data type of matrix A.

For the Atlas A3 training products/Atlas A3 inference products, the supported data types are half, float, bfloat16_t, int8_t, and int4b_t.

For the Atlas A2 training products/Atlas A2 inference products, the supported data types are half, float, bfloat16_t, int8_t, and int4b_t.

For the Atlas inference product's AI Core, the supported data types are half, float, and int8_t.

For the Atlas 200I/500 A2 inference products, the supported data types are half, float, bfloat16_t, and int8_t.

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.

aScalar

Input

Value set in matrix A. 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 aScalar to 1. SrcAT indicates the data type of matrix A.

For the Atlas A3 training products/Atlas A3 inference products, the supported data types are half and float.

For the Atlas A2 training products/Atlas A2 inference products, the supported data types are half and float.

This parameter is not supported by the Atlas inference product's AI Core.

This parameter is not supported by the Atlas 200I/500 A2 inference products.

isTransposeA

Input

Whether matrix A should be transposed.

Notes:

  • If MatmulType ISTRANS of matrix A 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 A.
  • If MatmulType ISTRANS of matrix A is set to false, this parameter can only be set to false. If it is forcibly set to true, the precision will be abnormal.
  • For input types other than half and bfloat16_t, to ensure that the L1 Buffer space calculation size is consistent between the Tiling side and the Kernel side, and to guarantee correct result precision, the value of this parameter must be the same as the value of ISTRANS defined for matrix A's MatmulType on the Kernel side and the value of isTrans of the SetAType() API on the tiling side. In other words, all three parameters must be set to true or false simultaneously.

For the Atlas inference product's AI Core, matrix A cannot be transposed when its data is of the int8_t type. That is, this parameter cannot be set to true.

For the Atlas A2 training products/Atlas A2 inference products, matrix A cannot be transposed when its data is of the int4b_t type. That is, this parameter cannot be set to true.

For the Atlas A3 training products/Atlas A3 inference products, matrix A cannot be transposed when its data is of the int4b_t type. That is, this parameter cannot be set to true.

Returns

None

Restrictions

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
// Example 1: The left matrix is in the global memory.
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetBias(gm_bias);
mm.IterateAll(gm_c);
// Example 2: The left matrix is in the local memory.
mm.SetTensorA(local_a);
// Example 3: Set scalar data.
mm.SetTensorA(scalar_a);