diff --git a/nncf/experimental/quantization/algorithms/post_training/algorithm.py b/nncf/experimental/quantization/algorithms/post_training/algorithm.py index 91599f56912..2215926e245 100644 --- a/nncf/experimental/quantization/algorithms/post_training/algorithm.py +++ b/nncf/experimental/quantization/algorithms/post_training/algorithm.py @@ -17,7 +17,7 @@ from nncf.common.tensor_statistics.statistic_point import StatisticPointsContainer from nncf.common.utils.backend import BackendType from nncf.experimental.quantization.algorithms.post_training.pipeline import experimental_create_ptq_pipeline -from nncf.experimental.quantization.quantizer.quantizer import Quantizer as NNCFQuantizer +from nncf.experimental.quantization.quantizers.quantizer import Quantizer from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters from nncf.quantization.advanced_parameters import AdvancedSmoothQuantParameters from nncf.quantization.advanced_parameters import RangeEstimatorParameters @@ -37,7 +37,7 @@ class ExperimentalPostTrainingQuantization(Algorithm): def __init__( self, - quantizer: NNCFQuantizer, + quantizer: Quantizer, subset_size: int = 300, fast_bias_correction: Optional[bool] = True, smooth_quant: bool = False, @@ -48,7 +48,7 @@ def __init__( batchwise_statistics: bool = False, ): """ - :param quantizer: NNCFQuantizer to use in MiMaxRangeInit algorithm. + :param quantizer: Quantizer to use in MiMaxRangeInit algorithm. :param subset_size: Size of a subset to calculate activations statistics used for quantization. :param fast_bias_correction: Setting this option to `False` enables a different diff --git a/nncf/experimental/quantization/algorithms/post_training/pipeline.py b/nncf/experimental/quantization/algorithms/post_training/pipeline.py index b53637a6b6d..56006e7be20 100644 --- a/nncf/experimental/quantization/algorithms/post_training/pipeline.py +++ b/nncf/experimental/quantization/algorithms/post_training/pipeline.py @@ -12,7 +12,7 @@ from typing import Optional, TypeVar from nncf.experimental.quantization.algorithms.range_estimator.algorithm import MinMaxRangeEstimator -from nncf.experimental.quantization.quantizer.quantizer import Quantizer as NNCFQuantizer +from nncf.experimental.quantization.quantizers.quantizer import Quantizer from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters from nncf.quantization.advanced_parameters import AdvancedSmoothQuantParameters from nncf.quantization.advanced_parameters import RangeEstimatorParameters @@ -27,7 +27,7 @@ def experimental_create_ptq_pipeline( - quantizer: NNCFQuantizer, + quantizer: Quantizer, subset_size: int = 300, fast_bias_correction: Optional[bool] = True, smooth_quant: bool = False, @@ -45,7 +45,7 @@ def experimental_create_ptq_pipeline( 2) MinMaxRangeInit 3) FastBiasCorrection or BiasCorrection - :param quantizer: NNCFQuantizer to use in MiMaxRangeInit algorithm. + :param quantizer: Quantizer to use in MiMaxRangeInit algorithm. :param subset_size: Size of a subset to calculate activations statistics used for quantization. :param fast_bias_correction: Setting this option to `False` enables a different diff --git a/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py b/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py index b6df4af3f82..24017991699 100644 --- a/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py +++ b/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py @@ -15,7 +15,7 @@ from nncf.common.graph.graph import NNCFGraph from nncf.common.tensor_statistics.statistic_point import StatisticPointsContainer from nncf.common.utils.backend import BackendType -from nncf.experimental.quantization.quantizer.quantizer import Quantizer as NNCFQuantizer +from nncf.experimental.quantization.quantizers.quantizer import Quantizer from nncf.quantization.algorithms.algorithm import Algorithm from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantization from nncf.quantization.range_estimator import RangeEstimatorParameters @@ -26,7 +26,7 @@ class MinMaxRangeEstimator(Algorithm): def __init__( self, - quantizer: NNCFQuantizer, + quantizer: Quantizer, subset_size: int = 300, inplace_statistics: bool = True, batchwise_statistics: bool = False, @@ -34,7 +34,7 @@ def __init__( weights_range_estimator_params: Optional[RangeEstimatorParameters] = None, ): """ - :param quantizer: Instance of NNCFQuantizer to retrieve a quantization config + :param quantizer: Instance of Quantizer to retrieve a quantization config for the given model. :param subset_size: Size of a subset to calculate activations statistics used for quantization, defaults to 300. diff --git a/nncf/experimental/quantization/quantizer/__init__.py b/nncf/experimental/quantization/quantizers/__init__.py similarity index 100% rename from nncf/experimental/quantization/quantizer/__init__.py rename to nncf/experimental/quantization/quantizers/__init__.py diff --git a/nncf/experimental/quantization/quantizer/quantizer.py b/nncf/experimental/quantization/quantizers/quantizer.py similarity index 100% rename from nncf/experimental/quantization/quantizer/quantizer.py rename to nncf/experimental/quantization/quantizers/quantizer.py diff --git a/nncf/experimental/quantization/quantizer/torch_ao_adapter.py b/nncf/experimental/quantization/quantizers/torch_ao_adapter.py similarity index 96% rename from nncf/experimental/quantization/quantizer/torch_ao_adapter.py rename to nncf/experimental/quantization/quantizers/torch_ao_adapter.py index 8d98db653c9..5fc0514c46f 100644 --- a/nncf/experimental/quantization/quantizer/torch_ao_adapter.py +++ b/nncf/experimental/quantization/quantizers/torch_ao_adapter.py @@ -16,7 +16,7 @@ import torch import torch.fx -from torch.ao.quantization.quantizer import Quantizer +from torch.ao.quantization.quantizer import Quantizer as TorchAOQuantizer from torch.ao.quantization.quantizer.quantizer import QuantizationSpec from torch.ao.quantization.quantizer.quantizer import QuantizationSpecBase from torch.ao.quantization.quantizer.quantizer import SharedQuantizationSpec @@ -31,18 +31,18 @@ from nncf.common.quantization.quantizer_setup import WeightQuantizationInsertionPoint from nncf.common.quantization.structs import QuantizationScheme as QuantizationMode from nncf.common.quantization.structs import QuantizerConfig -from nncf.experimental.quantization.quantizer.quantizer import Quantizer as NNCFQuantizer +from nncf.experimental.quantization.quantizers.quantizer import Quantizer from nncf.experimental.torch.fx.nncf_graph_builder import GraphConverter EdgeOrNode = Union[Tuple[torch.fx.Node, torch.fx.Node]] -class TorchAOQuantizerAdapter(NNCFQuantizer): +class TorchAOQuantizerAdapter(Quantizer): """ Implementation of the NNCF Quantizer interface for any given torch.ao quantizer. """ - def __init__(self, quantizer: Quantizer): + def __init__(self, quantizer: TorchAOQuantizer): self._quantizer = quantizer def get_quantization_setup(self, model: torch.fx.GraphModule, nncf_graph: NNCFGraph) -> SingleConfigQuantizerSetup: diff --git a/nncf/experimental/torch/fx/quantization/quantize_pt2e.py b/nncf/experimental/torch/fx/quantization/quantize_pt2e.py index 22cc063f854..3bd25be9af0 100644 --- a/nncf/experimental/torch/fx/quantization/quantize_pt2e.py +++ b/nncf/experimental/torch/fx/quantization/quantize_pt2e.py @@ -27,7 +27,7 @@ from nncf.common.logging import nncf_logger from nncf.data import Dataset from nncf.experimental.quantization.algorithms.post_training.algorithm import ExperimentalPostTrainingQuantization -from nncf.experimental.quantization.quantizer.torch_ao_adapter import TorchAOQuantizerAdapter +from nncf.experimental.quantization.quantizers.torch_ao_adapter import TorchAOQuantizerAdapter from nncf.experimental.torch.fx.constant_folding import constant_fold from nncf.experimental.torch.fx.transformations import QUANTIZE_NODE_TARGETS from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters