GetSortMaxMinTmpSize
Function Usage
To perform Sort computation with SortConfig template parameters on 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 that needs 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 function, 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 in the kernel can be optimized to some extent. To achieve better performance, reserve or allocate the space based on the actual buffer usage.
Prototype
1 | void GetSortMaxMinTmpSize(const ge::Shape &srcShape, ge::DataType valueType, ge::DataType indexType, bool isReuseSource, const SortConfig &config, uint32_t &maxValue, uint32_t &minValue) |
Parameters
Parameter |
Input/Output |
Description |
||||
|---|---|---|---|---|---|---|
srcShape |
Input |
Input shape. |
||||
valueType |
Input |
Data type of the input and output values. The data types must be the same as the template parameter T of the Sort API. |
||||
indexType |
Input |
Data type of the input and output indexes. The data types must be the same as the template parameter U of the Sort API. |
||||
isReuseSource |
Input |
Whether to reuse the space of the source operand input. The value must be the same as that of isReuseSource of the Sort API. |
||||
config |
Input |
Sort configuration: includes the selected sorting algorithm, ascending or descending order of the sorting result, and whether the input and output contain index data. The data type SortConfig is defined as follows: The hasSrcIndex and hasDstIndex parameters must be consistent with the input and output indexes of the Sort API. Currently, the combination of hasSrcIndex = true and hasDstIndex = false is not supported.
The values of SortType are as follows:
|
||||
maxValue |
Output |
Maximum size of the temporary space required by Sort computation. Any space exceeding this value will not be utilized by the API. 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. To achieve better performance, reserve or allocate the space based on the actual buffer usage. If the maximum space size is 0, no temporary space is required. NOTE:
maxValue is for reference only and may be larger than the available space of the Unified Buffer. In this case, select a proper temporary space size based on the available space of the Unified Buffer. |
||||
minValue |
Output |
Minimum size of the temporary space required by Sort computation. To ensure correct function, the temporary space to be reserved or allocated during API computation cannot be less than the value of this parameter. If the minimum space size is 0, no temporary space is required. |
Returns
None
Constraints
None
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // The input shape is 1024. The operator input data is of the uint32_t type. The source operand cannot be modified. std::vector<int64_t> shape_vec = {1024}; ge::Shape srcShape(shape_vec); ge::DataType valueType = ge::DT_UINT32; ge::DataType indexType = ge::DT_UINT32; bool isDescend = true; bool hasSrcIndex = false; bool hasDstIndex = false; bool isReuseSource = false; AscendC::SortConfig config; config.type = AscendC::SortType::RADIX_SORT; config.isDescend = isDescend; config.hasSrcIndex = hasSrcIndex; config.hasDstIndex = hasDstIndex; uint32_t maxValue = 0; uint32_t minValue = 0; AscendC::GetSortMaxMinTmpSize(srcShape, valueType, indexType, isReuseSource, config, maxValue, minValue); |