GetMeanTmpBufferFactorSize

Function Usage

Obtains maxLiveNodeCnt and extraBuf to compute the maximum number of elements that can be computed by an operator at a time when the size of space is fixed. maxLiveNodeCnt indicates how many times the buffer space is the size of data computed per time. extraBuf indicates the size of the extra temporary space.

Example:

  • The Mean API needs to be called for operator implementation. You need to reserve space of the currBuff size and use the GetMeanTmpBufferFactorSize API to obtain the output values of maxLiveNodeCnt and extraBuf and compute the maximum number of elements in a single computation.

    currentShapeSize = (currBuff - extraBuf) / maxLiveNodeCnt / typeSize

  • Two kernel APIs KernelIntf1 and KernelIntf2 need to be called for operator implementation. Two output values (maxLiveNodeCnt and extraBuf) of two GetXxxTmpBufferFactorSize API functions (Xxx indicates the two high-level APIs to be called) and the existing temporary space are used to compute the maximum number of elements in a single computation (currentShapeSize).

    currentShapeSize1 = (currBuff - extraBuf1) / maxLiveNodeCnt1 / typeSize

    currentShapeSize2 = (currBuff - extraBuf2) / maxLiveNodeCnt2 / typeSize

    currentShapeSize = min(currentShapeSize1, currentShapeSize2)

Note that currBuff indicates the available space for API computation. The space such as user input and output needs to be excluded.

Prototype

1
void GetMeanTmpBufferFactorSize(const uint32_t typeSize, uint32_t& maxLiveNodeCount, uint32_t& extraBuffer)

Parameters

Table 1 Parameter list

Parameter

Input/Output

Function

typeSize

Input

Size of the input data type, in bytes. For example, if the input data type is half, set this parameter to 2.

maxLiveNodeCount

Output

Maximum number of live nodes, indicating how many times the temporary space is the size of data computed per time.

extraBuffer

Output

Size of the used extra temporary space. The unit is byte.

Returns

None

Restrictions

If currentShapeSize × typeSize < 256B is obtained based on maxLiveNodeCount and extraBuffer, currentShapeSize should be rounded up based on the value of 256B/typeSize.

Example

For details about the complete call example, see More Examples.
1
2
3
uint32_t maxLiveNodeCnt = 0;
uint32_t extraBuf = 0;
AscendC::GetMeanTmpBufferFactorSize(typeSize, maxLiveNodeCnt, extraBuf);