GetPowerMaxMinTmpSize

Function Description

To perform Power computation in the kernel, developers 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. Developers 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 in the kernel can be optimized to some extent. To achieve better performance, reserve or allocate the space based on the actual buffer usage.

The API determines the API type (Power(dstTensor, srcTensor1, srcTensor2), Power(dstTensor, srcTensor1, scalarValue), or Power(dstTensor, scalarValue, srcTensor2)) based on srcShape1 and srcShape2, and then returns the size of the corresponding temporary space.

Prototype

1
void GetPowerMaxMinTmpSize(const ge::Shape& srcShape1, const ge::Shape& srcShape2, const bool typeIsInt, const uint32_t typeSize, const bool isReuseSource, uint32_t& maxValue, uint32_t& minValue)

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

srcShape1

Input

Input shape of srcTensor1.

srcShape2

Input

Input shape of srcTensor2.

typeIsInt

Input

The value is of the Boolean type. The value true indicates that the input is of the int32_t type.

typeSize

Input

Data type size of operator inputs. The unit is byte. For example, if the data type of operator inputs is half, set this parameter to 2.

isReuseSource

Input

Whether to reuse the space of the source operand input, which must be the same as that of the Power API.

maxValue

Output

Maximum size of the temporary space required by Power 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 in 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 remaining space of the Unified Buffer.

minValue

Output

Minimum size of the temporary space required by Power computation. To ensure correct functions, the size of 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

Availability

Example

For details about the complete call example, see More Examples.

  • Power (dstTensor, srcTensor1, srcTensor2) example
    1
    2
    3
    4
    5
    6
    // The input shape information of srcTensor1 and srcTensor2 is 512. The input data type of the operator is float. The source operand cannot be modified.
    std::vector<int64_t> shape_vec = {1024};
    ge::Shape shape(shape_vec);
    uint32_t maxValue = 0;
    uint32_t minValue = 0;
    AscendC::GetPowerMaxMinTmpSize(shape, shape, false, 4, false, maxValue, minValue);
    
  • Power(dstTensor, srcTensor1, scalarValue) example
    1
    2
    3
    4
    5
    6
    7
    8
    // The input shape information of srcTensor1 is 128 × 128, shape of scalarValue is 1, and the input data type of the operator is half. The source operand cannot be modified.
    std::vector<int64_t> shape1_vec = {128,128};
    std::vector<int64_t> shape2_vec = {1};
    ge::Shape shape1(shape1_vec);
    ge::Shape shape2(shape2_vec);
    uint32_t maxValue = 0;
    uint32_t minValue = 0;
    AscendC::GetPowerMaxMinTmpSize(shape1, shape2, false, 2, false, maxValue, minValue);
    
  • Power(dstTensor, scalarValue, srcTensor2) example
    1
    2
    3
    4
    5
    6
    7
    8
    // The shape of scalarValue is 1, the input shape of srcTensor2 is 128 × 128, and the input data type of the operator is float. The source operand cannot be modified.
    std::vector<int64_t> shape1_vec = {1};
    std::vector<int64_t> shape2_vec = {128,128};
    ge::Shape shape1(shape1_vec);
    ge::Shape shape2(shape2_vec);
    uint32_t maxValue = 0;
    uint32_t minValue = 0;
    AscendC::GetPowerMaxMinTmpSize(shape1, shape2, false, 4, false, maxValue, minValue);