Updated on 2022-03-13 GMT+08:00

Description of the Configuration Parameters

Table 1 Description of the device parameter

Function

Inference mode

Type

enum

Value Range

USE_CPU

Parameter

USE_CPU: Uses the CPU for inference.

Recommended Value

USE_CPU

Mandatory or Optional

Mandatory

Table 2 Description of the quantize_algo parameter

Function

Quantization mode

Type

enum

Value Range

  • NON_OFFSET
  • HALF_OFFSET

Parameter

  • NON_OFFSET: Both the weight and data are offset.
  • HALF_OFFSET: The data is offset while the weight is not.

There are two quantization mapping formulas:

  • With offset: q_uint8 = round (d_float/scale) – offset
  • Without offset: q_int8 = round (d_float/scale)

Recommended Value

HALF_OFFSET

Mandatory or Optional

Mandatory

Table 3 Description of the weight_type parameter

Function

Weight quantization mode

Type

enum

Value Range

  • VECTOR_TYPE
  • SCALAR_TYPE

Parameter

A convolution operator may have multiple filters, and the corresponding quantization parameters may be different.

  • VECTOR_TYPE: Each filter uses a separate group of quantization parameters
  • SCALAR_TYPE: The filters share the same group of quantization parameters.

Recommended Value

VECTOR_TYPE

Mandatory or Optional

Mandatory

Table 4 Description of the preprocess_parameter parameters

Function

Pre-processing and input parameters

Type

Struct

Value Range

None

Parameter

Pre-processing and input settings. The number of preprocess_parameter parameters must be the same as the number of operators input to the network.

preprocess_parameter contains the following parameters:

  • input_type
  • image_format
  • input_file_path
  • mean_value
  • standard_deviation

Recommended Value

None

Mandatory or Optional

Mandatory

Table 5 Description of the input_type parameter

Function

Input data type

Type

enum

Value Range

  • IMAGE
  • BINARY

Parameter

Input type. Currently, the image (IMAGE) and binary file (BINARY) formats are supported.
  • IMAGE: image format

    The following image formats are supported: .bmp, .dib, .jpeg, .jpg, .jpe, .jp2, .png, .webp, .pbm, .pgm, .ppm, .sr, .ras, .tiff, .tif, .BMP, .DIB, .JPEG, .JPG, .JPE, .JP2, .PNG, .WEBP, .PBM, .PGM, .PPM, .SR, .RAS, .TIFF, .TIF

  • BINARY: binary file format. For details, see Table 6. For non-4D (num, channels, height, and width) data, the data needs to be padded to four dimensions and the value of a padded dimension is 1.

Recommended Value

None

Mandatory or Optional

Mandatory

Table 6 Binary file formats

File Header/Data

Address Offset

Type

Value

Description

File header (20 bytes in total)

0000

32-bit int

510

Magic number.

When the magic number is 510, it is used to verify the validity of a file.

0004

32-bit int

50

Input num

0008

32-bit int

3

Input channels

0012

32-bit int

28

Input height

0016

32-bit int

28

Input width

Data

...

float

126

The number of data records is equal to the product of (num x channels x height x width).

Table 7 Description of the input_file_path parameter

Function

Input data address, that is, path of the calibration set images

Type

string

Value Range

None

Parameter

Folder or file to be quantified. The path cannot contain Chinese characters, special characters (including | ; & $ > < `), or spaces.

Set this parameter based on the actual network configuration.

  • For IMAGE input, specify the folder.
  • For BINARY input, specify the file.

Recommended Value

Set this parameter to an image folder or a binary file as required.

Mandatory or Optional

Mandatory

Table 8 Description of the image_format parameter

Function

Order of the three channels of the image input

Type

enum

Value Range

  • BGR
  • RGB

Parameter

Order of the three channels of the image input for model training

This parameter is mandatory when input_type is set to IMAGE. This parameter is determined based on the order of the input channels for network training. A typical order is BGR.

Recommended Value

BGR

Mandatory or Optional

Mandatory

Table 9 Description of the mean_value parameter

Function

Mean value for image preprocessing

Type

float

Value Range

[0, 255.0]

Parameter

Mean value of a channel for image preprocessing

This parameter is mandatory when input_type is set to IMAGE. The count of mean values is determined by the channel count. Three mean values need to be configured for the RGB channels respectively as follows:

  • mean_value: 104.0
  • mean_value: 117.0
  • mean_value: 123.0

Recommended Value

None

Mandatory or Optional

Mandatory

Table 10 Description of the standard_deviation parameter

Function

Standard deviation for image preprocessing

Type

float

Value Range

[0, FLOAT_MAX]

Parameter

Standard deviation for image preprocessing

This parameter is mandatory when input_type is set to IMAGE. Channels share the same standard deviation.

If the input range is beyond the range that can be represented by the FLOAT type, the quantization precision of the model cannot be guaranteed.

If 0 ≤ standard_deviation ≤ 0.00001, the value of standard_deviation is 1.0.

Recommended Value

1.0: The image value range (Source image value – Mean value) does not change.

255.0: If the image value range is [0, 0,255], the value can be condensed to [0,1, 1.0].

Mandatory or Optional

Mandatory

Table 11 Description of the bin parameter

Function

Data range of the mapping histogram

Type

uint32

Value Range

[0, 1000]

Parameter

Data range of the histogram statistics

The statistics histogram is required during the divergence computation. The value of this parameter determines the maximum value of the histogram. If this parameter is not set or set to 0, the default value 150 is used.

Recommended Value

100/150/200/250

Mandatory or Optional

Optional

Table 12 Description of the type parameter

Function

Type of the divergence computation

Type

enum

Value Range

  • KL
  • SYMKL
  • JSD

Parameter

  • KL: Kullback-Leibler Divergence
  • SYMKL: Symmetric Kullback-Leibler Divergence
  • JSD: Jensen-Shannon Divergence

Different divergence types correspond to different computation methods. The default value is KL.

Recommended Value

None

Mandatory or Optional

Optional

Table 13 Description of the inference_with_data_quantized parameter

Function

Whether to use the quantized data as the inference input

Type

bool

Value Range

  • true
  • false

Parameter

Whether to use the quantized data as the inference input

When this parameter is set to true, the quantization of the input data is simulated. The default value is false.

Recommended Value

false

Mandatory or Optional

Optional

Table 14 Description of the inference_with_weight_quantized parameter

Function

Whether to use the quantized weight as the inference input

Type

bool

Value Range

  • true
  • false

Parameter

Whether to use the quantized weight as the inference input

When this parameter is set to true, the quantization and de-quantization of the weight data are simulated. The default value is true.

Recommended Value

true

Mandatory or Optional

Optional

Table 15 Description of the super_parameter parameters

Function

Search parameters

Type

Struct

Value Range

None

Parameter

Search parameters

super_parameter contains the following parameters:

  • min_percentile
  • max_percentile
  • start_ratio
  • end_ratio
  • step_ratio

Recommended Value

None

Mandatory or Optional

Optional

Table 16 Description of the min_percentile parameter

Function

Searched minimum number

Type

enum

Value Range

  • PERCENTILE_HIGH
  • PERCENTILE_MID
  • PERCENTILE_LOW

Parameter

Indicates the minimum number to be considered as the search result among a group of numbers in ascending order. For example, if there are 100 numbers, the value 1.0 indicates that number 0 (100 – 100 x 1.0) is considered as the minimum, that is, the smallest number.

  • PERCENTILE_HIGH: 1.0
  • PERCENTILE_MID: 0.99999
  • PERCENTILE_LOW: 0.9999

Recommended Value

PERCENTILE_HIGH

Mandatory or Optional

Optional

Table 17 Description of the max_percentile parameter

Function

Searched maximum number

Type

enum

Value Range

  • PERCENTILE_HIGH
  • PERCENTILE_MID
  • PERCENTILE_LOW

Parameter

Indicates the maximum number to be considered as the search result among a group of numbers in descending order. For example, if there are 100 numbers, the value 1.0 indicates that number 0 (100 – 100 x 1.0) is considered as the maximum, that is, the largest number.

  • PERCENTILE_HIGH: 1.0
  • PERCENTILE_MID: 0.99999
  • PERCENTILE_LOW: 0.9999

Recommended Value

PERCENTILE_MID/PERCENTILE_HIGH

Mandatory or Optional

Optional

Table 18 Description of the start_ratio, end_ratio, and step_ratio parameters

Function

Parameter

Type

float

Value Range

end_ratio > start_ratio > 0, step_ratio > 0 (If the input range is beyond the range that can be represented by the FLOAT type, the quantization accuracy of the model cannot be guaranteed.)

Parameter

  • start_ratio indicates the search start.
  • end_ratio indicates the search end.
  • step_ratio indicates the search step.

After d_max and d_min are found in the algorithm, the ranges taken before and after d_max and d_min are determined based on start_ratio and end_ratio. Then, the step incremented each time is determined by step_ratio. For example:

If d_max is 100, start_ratio is 0.8, end_ratio is 1.2, and step_ratio is 0.01, the defined search range boundaries before and after d_max are 80 (100 x 0.8) and 120 (100 x 1.2) at a step of 1 (100 x 0.01). That is, there are 41 d_max search results in total.

Recommended Value

The following two sets of configurations are recommended:

  • start_ratio: 0.7 end_ratio: 1.3 step_ratio: 0.01
  • start_ratio: 0.3 end_ratio: 1.7 step_ratio: 0.01

Mandatory or Optional

Optional

Table 19 Description of the batch_count parameter

Function

Number of images in the quantization calibration set to be processed

Type

uint32

Value Range

[0, UINT32_MAX)

Parameter

Number of images in the quantization calibration set to be processed

If this parameter is not set or set to 0, all images in the calibration set are used. If the value is greater than 0, the smaller one in the total number of images in the calibration set path and the value of this parameter is used as the actual number of images in the calibration set. It is recommended that the number of images in the calibration set do not exceed 500.

Recommended Value

50

Mandatory or Optional

Optional

Table 20 Description of the exclude_op parameter

Function

Quantization operator blacklist

Type

string

Value Range

Operator name

Parameter

Operators in the list are not used for quantization.

  • Only the Convolution, Full Connection, and ConvolutionDepthwise operators are supported.
  • To blacklist multiple operators, multiple exclude_op parameters need to be set. Each parameter occupies a line. For example:

    exclude_op:'aaa'

    exclude_op:'bbb'

Recommended Value

None

Mandatory or Optional

Optional