GetAtanhTmpBufferFactorSize
Function
To perform Atanh computation on the kernel, developers need to reserve or allocate the temporary space. The relationship between the maximum temporary space (maxTmpBuffer) and the space occupied by the input (inputSize × typeSize) is as follows:
maxTmpBuffer = maxLiveNodeCount × inputSize × typeSize + extraBuffer
maxLiveNodeCount indicates how many times the maximum temporary space is the space occupied by the input. extraBuffer indicates the size of the extra temporary space.
This API can be used to obtain maxLiveNodeCount and extraBuffer to calculate the maximum number of elements that can be calculated by an operator at a time when the space is fixed.
The following is an example:
The Atanh API needs to be called for operator implementation. Developers need to reserve space of the currBuff size and use the GetAtanhTmpBufferFactorSize API to obtain the output values of maxLiveNodeCount and extraBuffer, to calculate the maximum number of elements in a single computation of an Atanh operator.
currentShapeSize = (currBuff – extraBuffer)/maxLiveNodeCount/typeSize
Prototype
1 | void GetAtanhTmpBufferFactorSize(const uint32_t typeSize, uint32_t& maxLiveNodeCount, uint32_t& extraBuf) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
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 maximum temporary space is the space occupied by the input. |
extraBuf |
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
1 2 3 4 5 6 | // Obtain maxLiveNodeCount and extraBuffer of Atanh whose input type is half. uint32_t typeSize = sizeof(half); uint32_t maxLiveNodeCount = 0; uint32_t extraBuffer = 0; AscendC::GetAtanhTmpBufferFactorSize(typeSize, maxLiveNodeCount, extraBuffer); |