GetMeanMaxMinTmpSize
Function
To perform Mean computation in the kernel, you need to reserve or allocate the temporary space. This API is used to obtain the maximum and minimum sizes of the temporary space to be reserved or allocated on the host. You can select a proper size within this range as the tiling parameter and pass it to the kernel.
- To ensure correct functions, the temporary space to be reserved or allocated cannot be less than the minimum temporary space.
- Within the range between the minimum and maximum, as the temporary space increases, the API computing performance on the kernel can be optimized to some extent. For better performance, reserve or allocate the temporary space based on the actual memory usage. The maximum temporary space of this API is currently equal to the minimum temporary space.
Prototype
1 | void GetMeanMaxMinTmpSize(const uint32_t n, const uint32_t srcTypeSize, const uint32_t accTypeSize, const bool isReuseSource, uint32_t& maxSize, uint32_t& minSize) |
Parameters
Parameter |
Input/Output |
Function |
|---|---|---|
n |
Input |
Number of actually computed elements in each row of input data. |
srcTypeSize |
Input |
Size of the input data type, in bytes. For example, if the input data type is half, the value is 2. |
accTypeSize |
Input |
Size of the accType data type, in bytes. For details about the accType parameters, see the Mean API parameters. |
isReuseSource |
Input |
Whether to reuse the space of the source operand input, which must be the same as that of the Mean API. This parameter is reserved. |
maxSize |
Output |
Maximum size of the temporary space required by Mean computation. Any space exceeding this value will not be utilized by the API. NOTE:
maxSize is for reference only and may be larger than the remaining space of the Unified Buffer. In this case, select a proper temporary space size based on the remaining space of the Unified Buffer. |
minSize |
Output |
Minimum size of the temporary space required by Mean computation. To ensure correct functions, the size of the temporary space to be reserved or allocated during API computation cannot be smaller than the value of this parameter. |
Returns
None
Restrictions
None
Example
1 2 3 4 5 6 7 | // The data type of the operator input T is half, accType is float, and the default value false is passed for isReuseSource. uint32_t n = 3; uint32_t srcTypeSize = 2; uint32_t accTypeSize = 4; uint32_t maxValue = 0; uint32_t minValue = 0; AscendC::GetMeanMaxMinTmpSize(n, srcTypeSize, accTypeSize, false, maxValue, minValue); |