From 9cba6915a0c19e10ff09141c2e76cfbf14cf2e67 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Wed, 5 Feb 2025 09:04:05 +0200 Subject: [PATCH] [ruff] INP rule, extend install tests (#3245) https://github.com/openvinotoolkit/nncf/pull/3244 ### Changes - Enabled INP rule for ruff https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp - Added missed `__init__.py` files - Extended install tests for torch and tf to load modules - Moved fx quantizers to fx directory - Removed import openvino in torch backend files ### Reason for changes Some files are not added to package ### Tests https://github.com/openvinotoolkit/nncf/actions/runs/13142880275 --- .../quantization/{quantizers => }/__init__.py | 0 .../quantization/algorithms/__init__.py | 10 ++++++++++ .../algorithms/post_training/algorithm.py | 2 +- .../algorithms/post_training/pipeline.py | 2 +- .../algorithms/range_estimator/__init__.py | 10 ++++++++++ .../algorithms/range_estimator/algorithm.py | 2 +- .../quantization/{quantizers => }/quantizer.py | 0 .../torch/fx/quantization/quantize_pt2e.py | 6 +++--- .../torch/fx/quantization/quantizer/__init__.py | 10 ++++++++++ .../quantization/quantizer}/openvino_adapter.py | 4 ++-- .../quantization/quantizer}/openvino_quantizer.py | 0 .../quantization/quantizer}/torch_ao_adapter.py | 2 +- nncf/experimental/torch2/quantization/__init__.py | 10 ++++++++++ nncf/experimental/torch2/statistics/__init__.py | 10 ++++++++++ .../algorithms/smooth_quant/torch_backend.py | 7 +++---- .../algorithms/smooth_quant/torch_fx_backend.py | 6 ++---- pyproject.toml | 2 ++ tests/cross_fw/install/common.py | 6 +++++- tests/cross_fw/install/install_checks_onnx.py | 6 +++--- tests/cross_fw/install/install_checks_openvino.py | 7 +++---- tests/cross_fw/install/install_checks_tf.py | 15 +++++++++++++++ tests/cross_fw/install/install_checks_torch.py | 15 +++++++++++++++ tests/cross_fw/shared/helpers.py | 2 +- tests/torch/fx/test_quantizer.py | 4 ++-- 24 files changed, 110 insertions(+), 28 deletions(-) rename nncf/experimental/quantization/{quantizers => }/__init__.py (100%) create mode 100644 nncf/experimental/quantization/algorithms/__init__.py create mode 100644 nncf/experimental/quantization/algorithms/range_estimator/__init__.py rename nncf/experimental/quantization/{quantizers => }/quantizer.py (100%) create mode 100644 nncf/experimental/torch/fx/quantization/quantizer/__init__.py rename nncf/experimental/{quantization/quantizers => torch/fx/quantization/quantizer}/openvino_adapter.py (88%) rename nncf/experimental/{quantization/quantizers => torch/fx/quantization/quantizer}/openvino_quantizer.py (100%) rename nncf/experimental/{quantization/quantizers => torch/fx/quantization/quantizer}/torch_ao_adapter.py (99%) create mode 100644 nncf/experimental/torch2/quantization/__init__.py create mode 100644 nncf/experimental/torch2/statistics/__init__.py diff --git a/nncf/experimental/quantization/quantizers/__init__.py b/nncf/experimental/quantization/__init__.py similarity index 100% rename from nncf/experimental/quantization/quantizers/__init__.py rename to nncf/experimental/quantization/__init__.py diff --git a/nncf/experimental/quantization/algorithms/__init__.py b/nncf/experimental/quantization/algorithms/__init__.py new file mode 100644 index 00000000000..e5a42efc0ef --- /dev/null +++ b/nncf/experimental/quantization/algorithms/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/nncf/experimental/quantization/algorithms/post_training/algorithm.py b/nncf/experimental/quantization/algorithms/post_training/algorithm.py index 2215926e245..77479a811b9 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.quantizers.quantizer import Quantizer +from nncf.experimental.quantization.quantizer import Quantizer from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters from nncf.quantization.advanced_parameters import AdvancedSmoothQuantParameters from nncf.quantization.advanced_parameters import RangeEstimatorParameters diff --git a/nncf/experimental/quantization/algorithms/post_training/pipeline.py b/nncf/experimental/quantization/algorithms/post_training/pipeline.py index 56006e7be20..86cfd608aac 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.quantizers.quantizer import Quantizer +from nncf.experimental.quantization.quantizer import Quantizer from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters from nncf.quantization.advanced_parameters import AdvancedSmoothQuantParameters from nncf.quantization.advanced_parameters import RangeEstimatorParameters diff --git a/nncf/experimental/quantization/algorithms/range_estimator/__init__.py b/nncf/experimental/quantization/algorithms/range_estimator/__init__.py new file mode 100644 index 00000000000..e5a42efc0ef --- /dev/null +++ b/nncf/experimental/quantization/algorithms/range_estimator/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py b/nncf/experimental/quantization/algorithms/range_estimator/algorithm.py index 24017991699..91e24a226a2 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.quantizers.quantizer import Quantizer +from nncf.experimental.quantization.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 diff --git a/nncf/experimental/quantization/quantizers/quantizer.py b/nncf/experimental/quantization/quantizer.py similarity index 100% rename from nncf/experimental/quantization/quantizers/quantizer.py rename to nncf/experimental/quantization/quantizer.py diff --git a/nncf/experimental/torch/fx/quantization/quantize_pt2e.py b/nncf/experimental/torch/fx/quantization/quantize_pt2e.py index 0d9adc60ab9..a01a6618e39 100644 --- a/nncf/experimental/torch/fx/quantization/quantize_pt2e.py +++ b/nncf/experimental/torch/fx/quantization/quantize_pt2e.py @@ -27,10 +27,10 @@ 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.quantizers.openvino_adapter import OpenVINOQuantizerAdapter -from nncf.experimental.quantization.quantizers.openvino_quantizer import OpenVINOQuantizer -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.quantization.quantizer.openvino_adapter import OpenVINOQuantizerAdapter +from nncf.experimental.torch.fx.quantization.quantizer.openvino_quantizer import OpenVINOQuantizer +from nncf.experimental.torch.fx.quantization.quantizer.torch_ao_adapter import TorchAOQuantizerAdapter from nncf.experimental.torch.fx.transformations import QUANTIZE_NODE_TARGETS from nncf.experimental.torch.fx.transformations import compress_post_quantize_transformation from nncf.quantization.advanced_parameters import AdvancedBiasCorrectionParameters diff --git a/nncf/experimental/torch/fx/quantization/quantizer/__init__.py b/nncf/experimental/torch/fx/quantization/quantizer/__init__.py new file mode 100644 index 00000000000..e5a42efc0ef --- /dev/null +++ b/nncf/experimental/torch/fx/quantization/quantizer/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/nncf/experimental/quantization/quantizers/openvino_adapter.py b/nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py similarity index 88% rename from nncf/experimental/quantization/quantizers/openvino_adapter.py rename to nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py index d3793916704..ffe676bc500 100644 --- a/nncf/experimental/quantization/quantizers/openvino_adapter.py +++ b/nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py @@ -13,8 +13,8 @@ from nncf.common.graph.graph import NNCFGraph from nncf.common.quantization.quantizer_setup import SingleConfigQuantizerSetup -from nncf.experimental.quantization.quantizers.openvino_quantizer import OpenVINOQuantizer -from nncf.experimental.quantization.quantizers.quantizer import Quantizer +from nncf.experimental.quantization.quantizer import Quantizer +from nncf.experimental.torch.fx.quantization.quantizer.openvino_quantizer import OpenVINOQuantizer class OpenVINOQuantizerAdapter(Quantizer): diff --git a/nncf/experimental/quantization/quantizers/openvino_quantizer.py b/nncf/experimental/torch/fx/quantization/quantizer/openvino_quantizer.py similarity index 100% rename from nncf/experimental/quantization/quantizers/openvino_quantizer.py rename to nncf/experimental/torch/fx/quantization/quantizer/openvino_quantizer.py diff --git a/nncf/experimental/quantization/quantizers/torch_ao_adapter.py b/nncf/experimental/torch/fx/quantization/quantizer/torch_ao_adapter.py similarity index 99% rename from nncf/experimental/quantization/quantizers/torch_ao_adapter.py rename to nncf/experimental/torch/fx/quantization/quantizer/torch_ao_adapter.py index 695e4b8a4c1..0ab21252077 100644 --- a/nncf/experimental/quantization/quantizers/torch_ao_adapter.py +++ b/nncf/experimental/torch/fx/quantization/quantizer/torch_ao_adapter.py @@ -30,7 +30,7 @@ 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.quantizers.quantizer import Quantizer +from nncf.experimental.quantization.quantizer import Quantizer from nncf.experimental.torch.fx.nncf_graph_builder import GraphConverter EdgeOrNode = Union[Tuple[torch.fx.Node, torch.fx.Node]] diff --git a/nncf/experimental/torch2/quantization/__init__.py b/nncf/experimental/torch2/quantization/__init__.py new file mode 100644 index 00000000000..e5a42efc0ef --- /dev/null +++ b/nncf/experimental/torch2/quantization/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/nncf/experimental/torch2/statistics/__init__.py b/nncf/experimental/torch2/statistics/__init__.py new file mode 100644 index 00000000000..e5a42efc0ef --- /dev/null +++ b/nncf/experimental/torch2/statistics/__init__.py @@ -0,0 +1,10 @@ +# Copyright (c) 2025 Intel Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/nncf/quantization/algorithms/smooth_quant/torch_backend.py b/nncf/quantization/algorithms/smooth_quant/torch_backend.py index 910c5e886e0..c9aaa135eca 100644 --- a/nncf/quantization/algorithms/smooth_quant/torch_backend.py +++ b/nncf/quantization/algorithms/smooth_quant/torch_backend.py @@ -24,13 +24,12 @@ from nncf.experimental.common.tensor_statistics.collectors import AbsMaxReducer from nncf.experimental.common.tensor_statistics.collectors import MaxAggregator from nncf.experimental.common.tensor_statistics.collectors import TensorCollector -from nncf.openvino.graph.transformations.commands import OVMultiplyInsertionCommand -from nncf.openvino.graph.transformations.commands import OVWeightUpdateCommand from nncf.quantization.algorithms.smooth_quant.backend import SmoothQuantAlgoBackend from nncf.tensor import Tensor from nncf.torch.graph.transformations.command_creation import create_command_to_update_weight from nncf.torch.graph.transformations.commands import PTSharedFnInsertionCommand from nncf.torch.graph.transformations.commands import PTTargetPoint +from nncf.torch.graph.transformations.commands import PTWeightUpdateCommand from nncf.torch.layer_utils import COMPRESSION_MODULES from nncf.torch.layer_utils import CompressionParameter from nncf.torch.layer_utils import StatefullModuleInterface @@ -127,7 +126,7 @@ def get_weight_value(node_with_weight: NNCFNode, model: NNCFNetwork, nncf_graph: return Tensor(weight_data) @staticmethod - def weight_update_command(node_with_weight: NNCFNode, weight_value: np.ndarray) -> OVWeightUpdateCommand: + def weight_update_command(node_with_weight: NNCFNode, weight_value: np.ndarray) -> PTWeightUpdateCommand: return create_command_to_update_weight(node_with_weight, weight_value) @staticmethod @@ -137,7 +136,7 @@ def scale_insertion_command( source_output_port_id: int, nodes: List[NNCFNode], scale_node_name: str, - ) -> OVMultiplyInsertionCommand: + ) -> PTSharedFnInsertionCommand: input_port_id = 0 target_points = [] for node in nodes: diff --git a/nncf/quantization/algorithms/smooth_quant/torch_fx_backend.py b/nncf/quantization/algorithms/smooth_quant/torch_fx_backend.py index 61fe2b98496..2795436334b 100644 --- a/nncf/quantization/algorithms/smooth_quant/torch_fx_backend.py +++ b/nncf/quantization/algorithms/smooth_quant/torch_fx_backend.py @@ -28,8 +28,6 @@ from nncf.experimental.torch.fx.transformations import constant_update_transformation_builder from nncf.experimental.torch.fx.transformations import get_graph_node_by_name from nncf.experimental.torch.fx.transformations import module_insertion_transformation_builder -from nncf.openvino.graph.transformations.commands import OVMultiplyInsertionCommand -from nncf.openvino.graph.transformations.commands import OVWeightUpdateCommand from nncf.quantization.algorithms.smooth_quant.backend import SmoothQuantAlgoBackend from nncf.tensor import Tensor from nncf.torch.graph.transformations.commands import PTTargetPoint @@ -104,7 +102,7 @@ def get_weight_value(node_with_weight: NNCFNode, model: torch.fx.GraphModule, nn return Tensor(weight_data.data) @staticmethod - def weight_update_command(node_with_weight: NNCFNode, weight_value: torch.Tensor) -> OVWeightUpdateCommand: + def weight_update_command(node_with_weight: NNCFNode, weight_value: torch.Tensor) -> FXApplyTransformationCommand: # TODO(dlyakhov): Use input port id depending on the node metatype/attributes. return FXApplyTransformationCommand( constant_update_transformation_builder(node_with_weight, weight_value.data, input_port_id=1) @@ -117,7 +115,7 @@ def scale_insertion_command( source_output_port_id: int, nodes: List[NNCFNode], scale_node_name: str, - ) -> OVMultiplyInsertionCommand: + ) -> FXApplyTransformationCommand: input_port_id = 0 target_points = [] for node in nodes: diff --git a/pyproject.toml b/pyproject.toml index 3a079a2e40e..62c8b36b595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -138,6 +138,7 @@ select = [ "F", # pyflakes rules "CPY001", # copyright check "NPY", # numpy rules + "INP", # flake8-no-pep420 ] extend-select = [ "SIM", # https://pypi.org/project/flake8-simplify @@ -149,6 +150,7 @@ extend-select = [ "tests/**/*.py" = ["F403"] "tests/**/__init__.py" = ["F401"] "examples/**/*.py" = ["F403"] +"!nncf/**.py" = ["INP"] [tool.ruff.lint.flake8-copyright] notice-rgx = """\ diff --git a/tests/cross_fw/install/common.py b/tests/cross_fw/install/common.py index 3096c64a4e6..0902ae94886 100644 --- a/tests/cross_fw/install/common.py +++ b/tests/cross_fw/install/common.py @@ -32,10 +32,14 @@ def onerror(name, excluded_modules_patterns): def load_nncf_modules(excluded_modules_patterns, verbose=False): onerror_partial = partial(onerror, excluded_modules_patterns=excluded_modules_patterns) for loader, module_name, _ in pkgutil.walk_packages(nncf.__path__, nncf.__name__ + ".", onerror_partial): - if module_name in sys.modules or excluded_module(module_name, excluded_modules_patterns): + if excluded_module(module_name, excluded_modules_patterns): if verbose: print(f"Module {module_name} ------ SKIPPED") continue + if module_name in sys.modules: + if verbose: + print(f"Module {module_name} ------ LOADED") + continue loader.find_module(module_name).load_module(module_name) if verbose: print(f"Module {module_name} ------ LOADED") diff --git a/tests/cross_fw/install/install_checks_onnx.py b/tests/cross_fw/install/install_checks_onnx.py index 51916eaacd1..f763622e785 100644 --- a/tests/cross_fw/install/install_checks_onnx.py +++ b/tests/cross_fw/install/install_checks_onnx.py @@ -18,9 +18,9 @@ "nncf\\.experimental\\.tensorflow.*", "nncf\\.experimental\\.torch.*", "nncf\\.experimental\\.openvino.*", - ".*?openvino_[^\\.]*", - ".*?torch_[^\\.]*", - ".*?tf_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.onnx.*?\\.).*?openvino_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.onnx.*?\\.).*?torch_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.onnx.*?\\.).*?tf_[^\\.]*", ) load_nncf_modules(EXCLUDED_MODULES_PATTERNS) diff --git a/tests/cross_fw/install/install_checks_openvino.py b/tests/cross_fw/install/install_checks_openvino.py index 24495e72a46..ae66f2229be 100644 --- a/tests/cross_fw/install/install_checks_openvino.py +++ b/tests/cross_fw/install/install_checks_openvino.py @@ -18,10 +18,9 @@ "nncf\\.experimental\\.onnx.*", "nncf\\.experimental\\.tensorflow.*", "nncf\\.experimental\\.torch.*", - ".*?onnx_[^\\.]*", - ".*?torch_[^\\.]*", - ".*?tf_[^\\.]*", - "nncf\\.openvino\\.pot.*", + "^(?!nncf(?:\\.experimental)*\\.openvino.*?\\.).*?onnx_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.openvino.*?\\.).*?torch_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.openvino.*?\\.).*?tf_[^\\.]*", ) load_nncf_modules(EXCLUDED_MODULES_PATTERNS) diff --git a/tests/cross_fw/install/install_checks_tf.py b/tests/cross_fw/install/install_checks_tf.py index 57d2c4f6354..a2a3114b326 100644 --- a/tests/cross_fw/install/install_checks_tf.py +++ b/tests/cross_fw/install/install_checks_tf.py @@ -14,6 +14,7 @@ import nncf # noqa: F401 from nncf.common.compression import BaseCompressionAlgorithmController from nncf.tensorflow.helpers.model_creation import create_compressed_model +from tests.cross_fw.install.common import load_nncf_modules from tests.tensorflow.quantization.utils import get_basic_quantization_config # Do not remove - these imports are for testing purposes. @@ -26,3 +27,17 @@ config = get_basic_quantization_config() compression_state_to_skip_init = {BaseCompressionAlgorithmController.BUILDER_STATE: {}} compression_model, compression_ctrl = create_compressed_model(model, config, compression_state_to_skip_init) + +EXCLUDED_MODULES_PATTERNS = ( + "nncf\\.openvino.*", + "nncf\\.torch.*", + "nncf\\.onnx.*", + "nncf\\.experimental\\.torch.*", + "nncf\\.experimental\\.openvino.*", + "nncf\\.experimental\\.onnx.*", + "^(?!nncf(?:\\.experimental)*\\.tensorflow.*?\\.).*?openvino_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.tensorflow.*?\\.).*?onnx_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.tensorflow.*?\\.).*?torch_[^\\.]*", +) + +load_nncf_modules(EXCLUDED_MODULES_PATTERNS) diff --git a/tests/cross_fw/install/install_checks_torch.py b/tests/cross_fw/install/install_checks_torch.py index 7e37c392a80..00b15b88d9a 100644 --- a/tests/cross_fw/install/install_checks_torch.py +++ b/tests/cross_fw/install/install_checks_torch.py @@ -14,6 +14,7 @@ import torch import nncf +from tests.cross_fw.install.common import load_nncf_modules if len(sys.argv) != 3: raise nncf.ValidationError( @@ -54,3 +55,17 @@ ) else: raise nncf.ValidationError(f"Invalid execution type {execution_type} (expected 'cpu' or 'gpu')!") + +EXCLUDED_MODULES_PATTERNS = ( + "nncf\\.openvino.*", + "nncf\\.tensorflow.*", + "nncf\\.onnx.*", + "nncf\\.experimental\\.tensorflow.*", + "nncf\\.experimental\\.openvino.*", + "nncf\\.experimental\\.onnx.*", + "^(?!nncf(?:\\.experimental)*\\.torch.*?\\.).*?openvino_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.torch.*?\\.).*?onnx_[^\\.]*", + "^(?!nncf(?:\\.experimental)*\\.torch.*?\\.).*?tf_[^\\.]*", +) + +load_nncf_modules(EXCLUDED_MODULES_PATTERNS) diff --git a/tests/cross_fw/shared/helpers.py b/tests/cross_fw/shared/helpers.py index da827dd5867..e996cae9600 100644 --- a/tests/cross_fw/shared/helpers.py +++ b/tests/cross_fw/shared/helpers.py @@ -36,7 +36,7 @@ def get_cli_dict_args(args): MAP_BACKEND_PACKAGES = { - "torch": ["torch"], + "torch": ["torch", "torchvision"], "openvino": ["openvino"], "onnx": ["onnx", "onnxruntime"], "tf": ["tensorflow"], diff --git a/tests/torch/fx/test_quantizer.py b/tests/torch/fx/test_quantizer.py index 7015182fe4e..3b75e86bcc3 100644 --- a/tests/torch/fx/test_quantizer.py +++ b/tests/torch/fx/test_quantizer.py @@ -31,10 +31,10 @@ from torch.ao.quantization.quantizer.x86_inductor_quantizer import get_default_x86_inductor_quantization_config import nncf -from nncf.experimental.quantization.quantizers.openvino_quantizer import OpenVINOQuantizer -from nncf.experimental.quantization.quantizers.torch_ao_adapter import _get_edge_or_node_to_qspec from nncf.experimental.torch.fx.nncf_graph_builder import GraphConverter from nncf.experimental.torch.fx.quantization.quantize_pt2e import quantize_pt2e +from nncf.experimental.torch.fx.quantization.quantizer.openvino_quantizer import OpenVINOQuantizer +from nncf.experimental.torch.fx.quantization.quantizer.torch_ao_adapter import _get_edge_or_node_to_qspec from tests.torch import test_models from tests.torch.fx.helpers import get_torch_fx_model from tests.torch.test_compressed_graph import check_graph