GetAscendAntiQuantMaxMinTmpSize

Function

To perform AscendAntiQuant computation in the kernel, developers need to reserve or allocate the temporary space. This API is used to obtain the maximum and minimum temporary space sizes to be reserved or allocated on the host. Developers can select proper sizes within this range as the tiling parameters and pass them 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. For better performance, reserve or allocate the temporary space based on the actual memory usage.

Prototype

1
void GetAscendAntiQuantMaxMinTmpSize(const ge::Shape& srcShape, const ge::Shape& scaleShape, bool isTranspose, ge::DataType inputDataType, ge::DataType outputDataType, uint32_t& maxValue, uint32_t& minValue)
1
uint32_t GetAscendAntiQuantMaxTmpSize(const ge::Shape& srcShape, const ge::Shape& scaleShape, bool isTranspose, ge::DataType inputDataType, ge::DataType outputDataType)
1
uint32_t GetAscendAntiQuantMinTmpSize(const ge::Shape& srcShape, const ge::Shape& scaleShape, bool isTranspose, ge::DataType inputDataType, ge::DataType outputDataType)

Parameters

Table 1 API parameters

Parameter

Input/Output

Description

srcShape

Input

Shape of the input src.

scaleShape

Input

Shape of the input scale.

isTranspose

Input

Whether to apply transposing.

inputDataType

Input

Input data type. The value is ge::DataType. For details about the definition of this type, see DataType.

outputDataType

Input

Output data type. The value is ge::DataType. For details about the definition of this type, see DataType.

maxValue

Output

Maximum size of the temporary space required by AscendAntiQuant 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. For better performance, reserve or allocate the temporary space based on the actual memory 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 by AscendAntiQuant computation. To ensure correct functions, 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

GetAscendAntiQuantMaxMinTmpSize: none

GetAscendAntiQuantMaxTmpSize: maximum temporary space required by AscendAntiQuant computation

GetAscendAntiQuantMinTmpSize: minimum temporary space required by AscendAntiQuant computation

Restrictions

None

Example

1
2
3
4
5
6
7
8
uint32_t maxValue = 0;
uint32_t minValue = 0;
std::vector<int64_t> srcDims = { 64, 512 };
auto srcShape = ge::Shape(srcDims);
std::vector<int64_t> scaleDims = { 1, 512 };
auto scaleShape = ge::Shape(scaleDims);
bool isTranspose = false;
AscendC::GetAscendAntiQuantMaxMinTmpSize(srcShape, scaleShape, isTranspose, ge::DT_INT8, ge::DT_BF16, maxValue, minValue);