Moved quantization templates to openvino/tools/pot (#10814)

This commit is contained in:
Liubov Talamanova 2022-03-21 14:17:55 +03:00 committed by GitHub
parent 0b444ab2db
commit bdc89b1571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 13 deletions

View File

@ -18,7 +18,7 @@ Post-training quantization is a basic feature of the POT and it has lots of knob
quantized model. However, as a starting point we suggest using the `DefaultQuantization` algorithm with default settings. quantized model. However, as a starting point we suggest using the `DefaultQuantization` algorithm with default settings.
In many cases it leads to satisfied accuracy and performance speedup. In many cases it leads to satisfied accuracy and performance speedup.
A fragment of the configuration file (`config/default_quantization_template.json` in the POT directory) with default settings is shown below: A fragment of the configuration file (`openvino/tools/pot/configs/templates/default_quantization_template.json` in the POT directory) with default settings is shown below:
``` ```
"compression": { "compression": {
"target_device": "ANY", // Target device, the specificity of which will be taken into account during optimization. "target_device": "ANY", // Target device, the specificity of which will be taken into account during optimization.
@ -78,7 +78,7 @@ For example, the following `range_estimator` for activations can improve the acc
} }
``` ```
Find the possible options and their description in the `config/default_quantization_spec.json` file in the POT directory. Find the possible options and their description in the `configs/default_quantization_spec.json` file in the POT directory.
4. The next option is `stat_subset_size`. It controls the size of the calibration dataset used by POT to collect statistics for quantization parameters initialization. 4. The next option is `stat_subset_size`. It controls the size of the calibration dataset used by POT to collect statistics for quantization parameters initialization.
It is assumed that this dataset should contain a sufficient number of representative samples. Thus, varying this parameter may affect accuracy (higher is better). It is assumed that this dataset should contain a sufficient number of representative samples. Thus, varying this parameter may affect accuracy (higher is better).
@ -92,7 +92,7 @@ In case when the steps above do not lead to the accurate quantized model you may
The whole idea behind that is to revert quantized layers back to floating-point precision based on their contribution to the accuracy drop until the desired accuracy degradation with respect to The whole idea behind that is to revert quantized layers back to floating-point precision based on their contribution to the accuracy drop until the desired accuracy degradation with respect to
the full-precision model is satisfied. the full-precision model is satisfied.
A fragment of the configuration file with default settings is shown below (`configs/accuracy_aware_quantization_template.json`): A fragment of the configuration file with default settings is shown below (`openvino/tools/pot/configs/templates/accuracy_aware_quantization_template.json`):
``` ```
"compression": { "compression": {
"target_device": "ANY", // Target device, the specificity of which will be taken into account during optimization. "target_device": "ANY", // Target device, the specificity of which will be taken into account during optimization.

View File

@ -58,7 +58,7 @@ quantization time. Default value is `False`.
## Examples ## Examples
A template and full specification for AccuracyAwareQuantization algorithm: A template and full specification for AccuracyAwareQuantization algorithm:
* [Template](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/accuracy_aware_quantization_template.json) * [Template](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/openvino/tools/pot/configs/templates/accuracy_aware_quantization_template.json)
* [Full specification](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/accuracy_aware_quantization_spec.json) * [Full specification](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/accuracy_aware_quantization_spec.json)
Example of using POT API with Accuracy-aware algorithm: Example of using POT API with Accuracy-aware algorithm:

View File

@ -116,7 +116,7 @@ Enabling this option may increase compressed model accuracy, but will result in
## Examples ## Examples
A template and full specification for DefaultQuantization algorithm: A template and full specification for DefaultQuantization algorithm:
* [Template](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/default_quantization_template.json) * [Template](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/openvino/tools/pot/configs/templates/default_quantization_template.json)
* [Full specification](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/default_quantization_spec.json) * [Full specification](https://github.com/openvinotoolkit/openvino/blob/master/tools/pot/configs/default_quantization_spec.json)
Command-line example: Command-line example:

View File

@ -76,7 +76,7 @@ def _create_log_path(config):
def _update_config_path(args): def _update_config_path(args):
config_template_folder = os.path.join(Path(__file__).parents[4], 'configs') config_template_folder = os.path.join(Path(__file__).parents[1], 'configs', 'templates')
if args.quantize is not None: if args.quantize is not None:
if args.quantize == 'default': if args.quantize == 'default':

View File

@ -0,0 +1,2 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

View File

@ -25,11 +25,6 @@ class InstallCmd(install):
# install requires # install requires
self.do_egg_install() self.do_egg_install()
def_quant_path = os.path.join("configs", "default_quantization_template.json")
aa_quant_path = os.path.join("configs", "accuracy_aware_quantization_template.json")
copyfile(def_quant_path, os.path.join(self.install_purelib, prefix, "pot", def_quant_path))
copyfile(aa_quant_path, os.path.join(self.install_purelib, prefix, "pot", aa_quant_path))
version_txt = os.path.join(prefix, "pot", "version.txt") version_txt = os.path.join(prefix, "pot", "version.txt")
if os.path.exists(version_txt): if os.path.exists(version_txt):
copyfile(os.path.join(version_txt), copyfile(os.path.join(version_txt),
@ -143,8 +138,9 @@ setup(
url='https://software.intel.com/openvino-toolkit', url='https://software.intel.com/openvino-toolkit',
packages=find_packages(exclude=["tests", "tests.*", packages=find_packages(exclude=["tests", "tests.*",
"tools", "tools.*"]), "tools", "tools.*"]),
package_data={"openvino.tools.pot.configs.hardware": ['*.json'], package_data={'openvino.tools.pot.configs.hardware': ['*.json'],
"openvino.tools.pot.api.samples": ['*.md', '*/*.md']}, 'openvino.tools.pot.api.samples': ['*.md', '*/*.md'],
'openvino.tools.pot.configs.templates': ['*.json']},
include_package_data=True, include_package_data=True,
cmdclass={ cmdclass={
'install': InstallCmd, 'install': InstallCmd,