GetSelectMaxMinTmpSize

Function

To perform SelectWithBytesMask computation on the kernel, you need to allocate the temporary space. This API is used to obtain the maximum and minimum sizes of the temporary space to be 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 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 is optimized to some extent. To achieve better performance, allocate the space based on the actual buffer usage.

Prototype

The GetSelectWithBytesMaskMinTmpSize, GetSelectWithBytesMaskMaxTmpSize, and GetSelectWithBytesMaskMaxMinTmpSize APIs are deprecated and will be removed in later versions. Do not use these APIs. Use the GetSelectMinTmpSize, GetSelectMaxTmpSize, and GetSelectMaxMinTmpSize APIs instead.

  • Obtain the minimum temporary space size.
    1
    uint32_t GetSelectMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask)
    
    1
    uint32_t GetSelectWithBytesMaskMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask)
    
  • Obtains the maximum size of the temporary workspace.
    1
    uint32_t GetSelectMaxTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask)
    
    1
    uint32_t GetSelectWithBytesMaskMaxTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask)
    
  • Obtains the maximum and minimum temporary space sizes.
    1
    void GetSelectMaxMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask, uint32_t& maxValue, uint32_t& minValue)
    
    1
    void GetSelectWithBytesMaskMaxMinTmpSize(const ge::Shape& src0Shape, const ge::Shape& src1Shape, const uint32_t srcTypeSize, const ge::Shape& maskShape, const uint32_t maskTypeSize, const bool isReuseMask, uint32_t& maxValue, uint32_t& minValue)
    

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

src0Shape

Input

Shape information of input src0. When src0 is a scalar, the shape should be {1}.

src1Shape

Input

Shape information of input src1. When src1 is a scalar, the shape should be {1}.

srcTypeSize

Input

Data type size of input srcTensor. For example, if the data type is half, set this parameter to 2.

maskShape

Input

Shape information of input maskTensor.

maskTypeSize

Input

Data type size of input maskTensor. For example, if the data type is bool, set this parameter to 1.

isReuseMask

Input

Whether to reuse the space of input maskTensor. The value must be the same as that in the kernel.

maxValue

Output

Maximum size of the temporary space required by the Select interface to complete the computation.

NOTE:

maxValue 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.

minValue

Output

Minimum size of the temporary space required by the Select interface to complete the computation.

Returns

GetSelectMinTmpSize returns the minimum size of the temporary space required by the Select interface to complete the computation.

GetSelectMaxTmpSize returns the maximum size of the temporary space required by the Select interface to complete the computation.

GetSelectMaxMinTmpSize does not return any value.

Restrictions

None

Example

1
2
3
4
5
6
7
8
9
std::vector<int64_t> shape0Vec = {64, 128};
std::vector<int64_t> shape1Vec = {1};
std::vector<int64_t> mask1Vec = {64, 128};
ge::Shape src0Shape(shape0Vec);
ge::Shape src1Shape(shape1Vec);
ge::Shape maskShape(mask1Vec);
uint32_t maxValue = 0;
uint32_t minValue = 0;
AscendC::GetSelectMaxMinTmpSize(src0Shape, src1Shape, 2, maskShape, 1, false, maxValue, minValue);