SetWorkspace
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function
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 | 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); mm.SetBias(gm_bias); mm.template Iterate<false>(); for (int i = 0; i < singleCoreM/baseM * singleCoreN/baseN; ++i) { mm.template GetTensorC<false>(ub_c); } |