SetWorkspace

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

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

In the asynchronous scenarios of Iterate computation, this API requests a temporary workspace to cache computation results. When GetTensorC is called, the C matrix tiles are retrieved from this temporary workspace.

When performing IterateNBatch computation, this API requests a temporary workspace to cache the computation results. Depending on whether the scenario is synchronous or asynchronous, other interfaces are then called to handle the results accordingly.

Prototype

It is recommended that the GlobalTensor type be used.

1
template <class T> __aicore__ inline void SetWorkspace(GlobalTensor<T>& addr)
1
template <class T> __aicore__ inline void SetWorkspace(__gm__ const T* addr, int size)

Parameters

Parameter

Input/Output

Description

addr

Input

Workspace on GM transferred by the user, of the GlobalTensor type.

addr

Input

Workspace space on GM transferred by the user, of the GM address type.

size

Input

When the GM address is transferred, the number of elements must also be transferred.

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
10
11
REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetWorkspace(workspaceGM);    // Set the temporary space used in asynchronous mode.
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
if (tiling.isBias) {
    mm.SetBias(biasGlobal);
}
mm.template Iterate<false>();
for (int i = 0; i < singleCoreM/baseM * singleCoreN/baseN; ++i) {
    mm.template GetTensorC<false>(ub_c);
}