GetPowerTmpBufferFactorSize

Function

Obtains maxLiveNodeCount and extraBuf to calculate the maximum number of elements in a single computation of an operator when the space is fixed. maxLiveNodeCount indicates how many times the temporary space is relative to the data volume in a single computation. extraBuf indicates the size of the extra temporary space.

Example:

The Power API needs to be called for operator implementation. Developers need to reserve space of the currBuff size and use the GetPowerTmpBufferFactorSize API to obtain the output values of maxLiveNodeCount and extraBuf, to calculate the maximum number of elements in a single computation of an operator.

currentShapeSize = (currBuff – extraBuf)/maxLiveNodeCount/typeSize

Note that currBuff indicates the available space for API computation. The space used for purposes, such as input and output, must be excluded. In addition, the output value of maxLiveNodeCount might be 0. Ensure that the value is not 0 to avoid the division-by-zero error.

Prototype

1
void GetPowerTmpBufferFactorSize(const bool baseIsTensor, const bool expIsTensor, const bool typeIsInt, const uint32_t typeSize, uint32_t& maxLiveNodeCount, uint32_t& extraBuffer)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

baseIsTensor

Input

If the base number is a tensor, set the value to true; otherwise, set it to false.

expIsTensor

Input

If the exponent is a tensor, set the value to true; otherwise, set it to false.

typeIsInt

Input

If the data type is int, set the value to true; otherwise, set it to false.

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 active nodes, indicating how many times the temporary space is the data volume 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 extraBuf, currentShapeSize should be rounded up based on the value of 256B/typeSize.

Example

For details about the complete calling example, see More Examples.
1
2
3
uint32_t maxLiveNodeCount = 0;
uint32_t extraBuf = 0;
AscendC::GetPowerTmpBufferFactorSize(true, true, true, 4, maxLiveNodeCount, extraBuf);