GetBroadCastMaxMinTmpSize
Function
To perform Broadcast computation on 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. 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 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 GetBroadCastMaxMinTmpSize(const platform_ascendc::PlatformAscendC& ascendcPlatform, const ge::Shape& srcShape,const ge::Shape& dstShape, uint32_t typeSize, const bool isReuseSource, uint32_t& maxValue, uint32_t& minValue) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ascendcPlatform |
Input |
Information about the execution platform. |
srcShape |
Input |
Input shape. |
dstShape |
Input |
Output shape. |
typeSize |
Input |
Size of the input data type, in bytes. For example, if the input data type 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 API in the kernel. |
maxValue |
Output |
Maximum size of the temporary space required for Broadcast 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 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 for Broadcast computation. To ensure correct functions, the temporary space to be reserved or applied for during API computation cannot be less than the parameter value. If the minimum space size is 0, no temporary space is required. |
Returns
None
Restrictions
None
Example
1 2 3 4 5 6 7 8 9 10 | // The input shape is (1024, 1). The operator input data is in the half type. The source operand cannot be modified. auto platformInfo = context_->GetPlatformInfo(); auto ascendcPlatform = platform_ascendc::PlatformAscendC(platformInfo); std::vector<int64_t> srcShapeVec = {1024, 1}; std::vector<int64_t> dstShapeVec = {1024, 16}; ge::Shape srcShape(srcShapeVec); ge::Shape dstShape(dstShapeVec); uint32_t maxValue{0}; uint32_t minValue{0}; AscendC::GetBroadCastMaxMinTmpSize(ascendcPlatform, srcShape,dstShape, 2, false, maxValue, minValue); |