Files
openvino/tools/pot/configs/default_quantization_spec.json

183 lines
8.0 KiB
JSON

{
/* Model parameters */
"model": {
"model_name": "model_name", // Model name
"model": "<MODEL_PATH>", // Path to model (.xml format)
"weights": "<PATH_TO_WEIGHTS>" // Path to weights (.bin format)
},
/* Parameters of the engine used for model inference */
// Post-Training Optimization Tool supports engine based on accuracy checker and custom engine.
// For custom engine you should specify your own set of parameters.
// The engine based on accuracy checker uses accuracy checker parameters.
// You can specify the parameters via accuracy checker config file or directly in engine section.
// More information about accuracy checker parameters can be found here:
// https://github.com/opencv/open_model_zoo/tree/master/tools/accuracy_checker
"engine": {
/* Accuracy checker mode (default) */
"stat_requests_number": 8, // Number of requests during statistcs collection
"eval_requests_number": 8, // Number of requests during evaluation
"config": "<CONFIG_PATH>",
/* OR */
"name": "model_name",
"launchers": [
{
"framework": "dlsdk",
"device": "CPU",
"adapter": "classification"
}
],
"datasets": [
{
"name": "dataset_name",
"data_source": "<DATASET_PATH>",
"annotation": "<ANNOTATION_PATH>",
"preprocessing": [
{
"type": "resize",
"interpolation": "BILINEAR",
"aspect_ratio_scale": "greater",
"size": 224
}
],
"metrics": [
{
"name": "accuracy@top1",
"type": "accuracy",
"top_k": 1
}
]
}
],
/* OR */
/* Simplified mode */
"type": "simplified", // OR default value "type": "accuracy_checker" for non simplified mode
"data_source": "PATH_TO_SOURCE" // You can specify path to directory with images. Also you can
// specify template for file names to filter images to load.
// Templates are unix style (This option valid only in simplified mode)
},
/* Optimization hyperparameters */
"compression": {
"target_device": "ANY", // Target device, the specificity of which will be taken
// into account during optimization
"model_type": "None", // An optional parameter, needed for additional patterns in the model,
// default value is None (supported only transformer now)
"dump_intermediate_model": false, // Save intermediate models for DefaultAlgorithm
"inplace_statistics": true, // An optional parameter, change method collect statistics,
// reduces the amount of memory consumed,
// but increases the calibration time
// the default value is true
"algorithms": [
{
"name": "DefaultQuantization", // Optimization algorithm name
"params": {
"ignored": {
// List of nodes that are excluded from optimization
"scope": [
"<NODE_NAME>"
],
// List of types that are excluded from optimization
"operations": [
{
"type": "<NODE_TYPE>",
// Includes excluding by attributes
"attributes": {
"<NAME>": "<VALUE>" // Lists of values is not included
}
},
{
"type": "<NODE_TYPE>" // Excluding only by type
}
]
},
"preset": "mixed", // A preset is a collection of optimization algorithm parameters
// that will specify to the algorithm to improve which metric
// the algorithm needs to concentrate. Each optimization algorithm
// supports [performance, mixed, accuracy] presets
"stat_subset_size": 100, // Size of subset to calculate activations statistics that can be used
// for quantization parameters calculation
"shuffle_data": false, // Shuffle data before selecting the subset to calculate activation
// statistics. An optional parameter, the default value is false
"seed": 0, // Seed for data shuffle. An optional parameter, the default value is 0
/* Manually specification quantization parametrs */
/* Quantization parameters for weights */
"weights": {
"bits": 8, // Number of quantization bits
"mode": "symmetric", // Quantization mode
"granularity": "perchannel", // Granularity: a scale for each output channel
"level_low": -127, // Low quantization level
"level_high": 127, // High quantization level
/* Parameters specify how to calculate the minimum and maximum of quantization range */
"range_estimator": {
"max": {
"type": "quantile",
"outlier_prob": 0.0001
}
}
},
/* Quantization parameters for activations */
"activations": {
"bits": 8, // Number of quantization bits
"mode": "symmetric", // Quantization mode
"granularity": "pertensor", // Granularity: one scale for output tensor
/* Parameters specify how to calculate the minimum and maximum of quantization range */
"range_estimator": {
"preset": "quantile",
/* OR */
/* Minimum of quantization range */
"min": {
"clipping_value": 0, // Threshold for min statistic value clipping (lower bound)
"aggregator": "mean", // Batch aggregation type [mean, max, min, median,
// mean_no_outliers, median_no_outliers, hl_estimator]
"type": "quantile", // Estimator type [min, max, abs_max, quantile, abs_quantile]
"outlier_prob": 0.0001 // Outlier probability: estimator consider samples which
},
/* Maximum of quantization range */
"max": {
"clipping_value": 6, // Threshold for max statistic value clipping (upper bound)
"aggregator": "mean", // Batch aggregation type [mean, max, min, median,
// mean_no_outliers, median_no_outliers, hl_estimator]
"type": "quantile", // Estimator type [min, max, abs_max, quantile, abs_quantile]
"outlier_prob": 0.0001 // Outlier probability: estimator consider samples which
}
}
}
}
}
]
}
}