SetLocalWorkspace

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

x

Atlas A2 training products/Atlas A2 inference products

x

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

Atlas inference product's Vector Core

x

Atlas training products

x

Function

In some scenarios, Matmul needs to occupy extra VECCALC space. If users want to reuse this extra VECCALC space in the operator, reserve the space in advance, allocate the local tensor, and pass the start physical address of the local tensor to Matmul. The size of the temporary VECCALC space to be allocated is provided by MatmulGetTmpBufSize. This API is used to transfer the temporary UB space when one of the following conditions is met:

  • Position of matrix C is TPosition::GM.
  • CubeFormat of matrix C is CubeFormat::ND.
  • CubeFormat of matrix A or matrix B is CubeFormat::ND.
  • Bias exists and its Position is not VECCALC.

Call this API before calling Iterate or IterateAll.

The size of the obtained UB temporary space is in bytes.

Prototype

1
__aicore__ inline void SetLocalWorkspace(const LocalTensor<uint8_t>& tmpBuffer)

Parameters

Parameter

Input/Output

Description

tmpBuffer

Input

Temporary space with TPosition set to VECCALC. It is allocated and managed by users.

Returns

None

Restrictions

This API is not supported when enableMixDualMaster (dual-master mode) is set to true.

Example

1
2
3
4
5
6
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetLocalWorkspace(mmFormatUb);    // Set the temporary VECCALC space.
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetBias(gm_bias);
mm.IterateAll(gm_c);