FilesLast commitLast update
4 days ago
4 months ago
24 days ago
4 months ago
22 days ago
11 months ago
1 month ago
17 days ago
README

QuantizedBatchNorm

English | 简体中文

Applicable Products

Product Support
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×
Kirin X90 processor series products √
Kirin 9030 processor series products √

Function

  • Operator function: it performs a dequantization computation on the input tensor, then performs normalization according to the input weight, bias, and epsilon, and finally performs quantization according to the input outputScale and outputZeroPoint.

  • Formula:

    1. Dequantization computation:

      x′=(x−inputZeroPoint)∗inputScalex' = (x - inputZeroPoint) * inputScale

    2. Normalization computation:

      y=x′−meanvar+ϵ∗γ+βy =\frac{x' - mean}{\sqrt{var + ϵ}} * γ + β

    3. Quantization computation:

      out=round(youtputScale+outputZeroPoint)out = round(\frac{y}{outputScale} + outputZeroPoint)

Parameters

Parameter name Input/Output/Attribute Description Data type Data format
x Input The quantized data of the model input, corresponding to `x` in the formula. INT8, UINT8, INT32 NCHW
mean Input The mean of the model input data, corresponding to `mean` in the formula. The shape is limited to 1D, and its length must match C in the input NCHW. FLOAT32 ND
var Input The variance of the model input data, corresponding to `var` in the formula. The shape is limited to 1D, and its length must match C in the input NCHW. FLOAT32 ND
input_scale Input An input scalar, the scaling coefficient of the model input data, corresponding to `inputScale` in the formula. FLOAT32 ND
input_zero_point Input An input scalar, the offset of the model input data, corresponding to `inputZeroPoint` in the formula. The passed-in value must not exceed the upper and lower bounds of the data type of input, for example the bounds of INT8 are [-128,127]. INT32 ND
output_scale Input An input scalar, the scaling coefficient of the model output data, corresponding to `outputScale` in the formula. FLOAT32 ND
output_zero_point Input An input scalar, the offset of the model output data, corresponding to `outputZeroPoint` in the formula. The passed-in value must not exceed the upper and lower bounds of the data type of input, for example the bounds of INT8 are [-128,127]. INT32 ND
weight Input The weight for batch normalization, corresponding to `γ` in the formula. The shape is limited to 1D, and its length must match C in the NCHW data format of the input parameter input. FLOAT32 ND
bias Input The bias value for batch normalization, corresponding to `β` in the formula. The shape is limited to 1D, and its length must match C in the input NCHW. FLOAT32 ND
epsilon Optional attribute
  • A small value added to the variance to avoid division by zero, corresponding to `ε` in the formula.
  • Default value: empty.
FLOAT32 -
y Output The quantized data of the model output, corresponding to `out` in the formula. Its data type, data format, and shape match the input `x`. INT8, UINT8, INT32 NCHW

Constraints

None

Invocation Description

Invocation method Sample code Description
aclnn API test_aclnn_quantized_batch_norm Calls the QuantizedBatchNorm operator through the aclnnQuantizedBatchNorm API.