SetLocalWorkspace

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

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
7
8
9
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetLocalWorkspace(mmFormatUb);    // Set the temporary VECCALC space.
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
if (tiling.isBias) {
    mm.SetBias(biasGlobal);
}
mm.IterateAll(gm_c);
mm.End();