From b4e216d0cc71c0c7b8601e9e264670e57018202d Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Wed, 28 Aug 2024 18:12:34 +0300 Subject: [PATCH] Move test_templates to cross_fw directory (#2887) ### Changes Move all templates classes to separate directory. ### Reason Improve organization of test files and maintainability --- tests/common/quantization/test_layerwise_scheduler.py | 2 +- tests/common/quantization/test_passes.py | 4 ++-- .../test_templates}/fq_params/fq_params.json | 0 .../test_templates/helpers.py | 0 .../test_templates/models.py | 0 .../test_templates/test_bias_correction.py | 8 ++++---- .../test_calculate_quantizer_parameters.py | 4 +++- .../test_templates/test_channel_alignment.py | 4 ++-- .../test_templates/test_fast_bias_correction.py | 6 +++--- .../test_templates/test_layerwise.py | 4 ++-- .../test_templates/test_min_max.py | 0 .../test_templates/test_ptq_params.py | 0 .../test_templates/test_quantizer_config.py | 6 +++--- .../test_templates/test_smooth_quant.py | 10 +++++----- tests/onnx/quantization/test_bias_correction.py | 8 ++++---- .../quantization/test_calculation_quantizer_params.py | 2 +- tests/onnx/quantization/test_fast_bias_correction.py | 2 +- tests/onnx/quantization/test_min_max.py | 10 +++++----- tests/onnx/quantization/test_ptq_params.py | 6 +++--- tests/onnx/quantization/test_quantizer_config.py | 8 ++++---- .../quantization/test_calculation_quantizer_params.py | 2 +- .../native/quantization/test_channel_alignment.py | 2 +- tests/openvino/native/quantization/test_min_max.py | 8 ++++---- tests/openvino/native/quantization/test_ptq_params.py | 4 ++-- .../native/quantization/test_quantizer_config.py | 8 ++++---- tests/openvino/native/test_bias_correction.py | 8 ++++---- tests/openvino/native/test_fast_bias_correction.py | 2 +- tests/openvino/native/test_layerwise.py | 2 +- tests/openvino/native/test_smooth_quant.py | 8 ++++---- tests/post_training/conftest.py | 5 ----- tests/torch/fx/test_fast_bias_correction.py | 2 +- tests/torch/fx/test_smooth_quant.py | 8 ++++---- tests/torch/ptq/helpers.py | 6 +++--- tests/torch/ptq/test_calculation_quantizer_params.py | 2 +- tests/torch/ptq/test_fast_bias_correction.py | 2 +- tests/torch/ptq/test_graphs.py | 4 ++-- tests/torch/ptq/test_min_max.py | 8 ++++---- tests/torch/ptq/test_ptq_params.py | 2 +- tests/torch/ptq/test_quantizer_config.py | 8 ++++---- tests/torch/ptq/test_smooth_quant.py | 8 ++++---- tests/torch/test_extractor.py | 2 +- tests/torch/test_model_graph_manager.py | 2 +- tests/torch/test_nncf_graph.py | 2 +- 43 files changed, 93 insertions(+), 96 deletions(-) rename tests/{post_training/data => cross_fw/test_templates}/fq_params/fq_params.json (100%) rename tests/{post_training => cross_fw}/test_templates/helpers.py (100%) rename tests/{post_training => cross_fw}/test_templates/models.py (100%) rename tests/{post_training => cross_fw}/test_templates/test_bias_correction.py (95%) rename tests/{post_training => cross_fw}/test_templates/test_calculate_quantizer_parameters.py (98%) rename tests/{post_training => cross_fw}/test_templates/test_channel_alignment.py (99%) rename tests/{post_training => cross_fw}/test_templates/test_fast_bias_correction.py (95%) rename tests/{post_training => cross_fw}/test_templates/test_layerwise.py (97%) rename tests/{post_training => cross_fw}/test_templates/test_min_max.py (100%) rename tests/{post_training => cross_fw}/test_templates/test_ptq_params.py (100%) rename tests/{post_training => cross_fw}/test_templates/test_quantizer_config.py (98%) rename tests/{post_training => cross_fw}/test_templates/test_smooth_quant.py (96%) diff --git a/tests/common/quantization/test_layerwise_scheduler.py b/tests/common/quantization/test_layerwise_scheduler.py index 6a59b6f63fc..41d1df61590 100644 --- a/tests/common/quantization/test_layerwise_scheduler.py +++ b/tests/common/quantization/test_layerwise_scheduler.py @@ -12,7 +12,7 @@ import pytest from nncf.quantization.algorithms.layerwise.scheduler import LayerwiseScheduler -from tests.post_training.test_templates.models import NNCFGraphCAWithBias +from tests.cross_fw.test_templates.models import NNCFGraphCAWithBias @pytest.mark.parametrize("add_additional_outputs", [False, True]) diff --git a/tests/common/quantization/test_passes.py b/tests/common/quantization/test_passes.py index 3c10f196bf0..bbf75b5ef67 100644 --- a/tests/common/quantization/test_passes.py +++ b/tests/common/quantization/test_passes.py @@ -18,8 +18,8 @@ from nncf.common.graph.operator_metatypes import OperatorMetatype from nncf.quantization.passes import filter_constant_nodes from nncf.quantization.passes import remove_nodes_and_reconnect_graph -from tests.post_training.test_templates.models import NNCFGraphDropoutRemovingCase -from tests.post_training.test_templates.models import NNCFGraphToTestConstantFiltering +from tests.cross_fw.test_templates.models import NNCFGraphDropoutRemovingCase +from tests.cross_fw.test_templates.models import NNCFGraphToTestConstantFiltering from tests.shared.nx_graph import compare_nx_graph_with_reference from tests.shared.paths import TEST_ROOT diff --git a/tests/post_training/data/fq_params/fq_params.json b/tests/cross_fw/test_templates/fq_params/fq_params.json similarity index 100% rename from tests/post_training/data/fq_params/fq_params.json rename to tests/cross_fw/test_templates/fq_params/fq_params.json diff --git a/tests/post_training/test_templates/helpers.py b/tests/cross_fw/test_templates/helpers.py similarity index 100% rename from tests/post_training/test_templates/helpers.py rename to tests/cross_fw/test_templates/helpers.py diff --git a/tests/post_training/test_templates/models.py b/tests/cross_fw/test_templates/models.py similarity index 100% rename from tests/post_training/test_templates/models.py rename to tests/cross_fw/test_templates/models.py diff --git a/tests/post_training/test_templates/test_bias_correction.py b/tests/cross_fw/test_templates/test_bias_correction.py similarity index 95% rename from tests/post_training/test_templates/test_bias_correction.py rename to tests/cross_fw/test_templates/test_bias_correction.py index e27a8ad0868..b154e0870a7 100644 --- a/tests/post_training/test_templates/test_bias_correction.py +++ b/tests/cross_fw/test_templates/test_bias_correction.py @@ -21,10 +21,10 @@ from nncf.quantization.algorithms.bias_correction.algorithm import BiasCorrection from nncf.quantization.algorithms.bias_correction.backend import BiasCorrectionAlgoBackend from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantization -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import MultipleConvTestModel -from tests.post_training.test_templates.helpers import SplittedModel -from tests.post_training.test_templates.helpers import StaticDatasetMock +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import MultipleConvTestModel +from tests.cross_fw.test_templates.helpers import SplittedModel +from tests.cross_fw.test_templates.helpers import StaticDatasetMock TModel = TypeVar("TModel") TTensor = TypeVar("TTensor") diff --git a/tests/post_training/test_templates/test_calculate_quantizer_parameters.py b/tests/cross_fw/test_templates/test_calculate_quantizer_parameters.py similarity index 98% rename from tests/post_training/test_templates/test_calculate_quantizer_parameters.py rename to tests/cross_fw/test_templates/test_calculate_quantizer_parameters.py index 7ab3d0ab318..45bb3c65956 100644 --- a/tests/post_training/test_templates/test_calculate_quantizer_parameters.py +++ b/tests/cross_fw/test_templates/test_calculate_quantizer_parameters.py @@ -12,6 +12,7 @@ from abc import ABC from abc import abstractmethod from dataclasses import dataclass +from pathlib import Path import numpy as np import pytest @@ -24,10 +25,11 @@ from nncf.quantization.fake_quantize import FakeQuantizeParameters from nncf.quantization.fake_quantize import calculate_quantizer_parameters from nncf.tensor import functions as fns -from tests.post_training.conftest import FQ_CALCULATED_PARAMETERS_PATH from tests.shared.helpers import dump_to_json from tests.shared.helpers import load_json +FQ_CALCULATED_PARAMETERS_PATH = Path(__file__).parent / "fq_params" / "fq_params.json" + def compare_fq_parameters(ref_params, params): assert ref_params.levels == params.levels diff --git a/tests/post_training/test_templates/test_channel_alignment.py b/tests/cross_fw/test_templates/test_channel_alignment.py similarity index 99% rename from tests/post_training/test_templates/test_channel_alignment.py rename to tests/cross_fw/test_templates/test_channel_alignment.py index f1e0fbf440d..7995f91961c 100644 --- a/tests/post_training/test_templates/test_channel_alignment.py +++ b/tests/cross_fw/test_templates/test_channel_alignment.py @@ -31,8 +31,8 @@ from nncf.quantization.algorithms.channel_alignment.algorithm import ChannelAlignment from nncf.quantization.algorithms.channel_alignment.backend import ChannelAlignmentAlgoBackend from nncf.quantization.algorithms.channel_alignment.backend import LayoutDescriptor -from tests.post_training.test_templates.models import NNCFGraphCA -from tests.post_training.test_templates.models import NNCFGraphCAWithBias +from tests.cross_fw.test_templates.models import NNCFGraphCA +from tests.cross_fw.test_templates.models import NNCFGraphCAWithBias EPS = 1e-3 diff --git a/tests/post_training/test_templates/test_fast_bias_correction.py b/tests/cross_fw/test_templates/test_fast_bias_correction.py similarity index 95% rename from tests/post_training/test_templates/test_fast_bias_correction.py rename to tests/cross_fw/test_templates/test_fast_bias_correction.py index edaf979d74e..899be7d9a1a 100644 --- a/tests/post_training/test_templates/test_fast_bias_correction.py +++ b/tests/cross_fw/test_templates/test_fast_bias_correction.py @@ -20,9 +20,9 @@ from nncf.quantization.algorithms.fast_bias_correction.algorithm import FastBiasCorrection from nncf.quantization.algorithms.fast_bias_correction.backend import FastBiasCorrectionAlgoBackend from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantization -from tests.post_training.test_templates.helpers import ConvBNTestModel -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import get_static_dataset +from tests.cross_fw.test_templates.helpers import ConvBNTestModel +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import get_static_dataset TModel = TypeVar("TModel") TTensor = TypeVar("TTensor") diff --git a/tests/post_training/test_templates/test_layerwise.py b/tests/cross_fw/test_templates/test_layerwise.py similarity index 97% rename from tests/post_training/test_templates/test_layerwise.py rename to tests/cross_fw/test_templates/test_layerwise.py index ea6227f6f2b..9bda65851a0 100644 --- a/tests/post_training/test_templates/test_layerwise.py +++ b/tests/cross_fw/test_templates/test_layerwise.py @@ -16,8 +16,8 @@ from nncf.common.factory import StatisticsAggregatorFactory from nncf.quantization.algorithms.layerwise.engine import LayerwiseEngine from nncf.tensor import functions as fns -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import get_static_dataset +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import get_static_dataset TModel = TypeVar("TModel") diff --git a/tests/post_training/test_templates/test_min_max.py b/tests/cross_fw/test_templates/test_min_max.py similarity index 100% rename from tests/post_training/test_templates/test_min_max.py rename to tests/cross_fw/test_templates/test_min_max.py diff --git a/tests/post_training/test_templates/test_ptq_params.py b/tests/cross_fw/test_templates/test_ptq_params.py similarity index 100% rename from tests/post_training/test_templates/test_ptq_params.py rename to tests/cross_fw/test_templates/test_ptq_params.py diff --git a/tests/post_training/test_templates/test_quantizer_config.py b/tests/cross_fw/test_templates/test_quantizer_config.py similarity index 98% rename from tests/post_training/test_templates/test_quantizer_config.py rename to tests/cross_fw/test_templates/test_quantizer_config.py index 259b506d08f..79e3a8e5171 100644 --- a/tests/post_training/test_templates/test_quantizer_config.py +++ b/tests/cross_fw/test_templates/test_quantizer_config.py @@ -38,9 +38,9 @@ from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantization from nncf.quantization.passes import transform_to_inference_graph from nncf.quantization.range_estimator import RangeEstimatorParametersSet -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestDepthwiseConv -from tests.post_training.test_templates.models import NNCFGraphToTestSumAggregation +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestDepthwiseConv +from tests.cross_fw.test_templates.models import NNCFGraphToTestSumAggregation class TemplateTestQuantizerConfig: diff --git a/tests/post_training/test_templates/test_smooth_quant.py b/tests/cross_fw/test_templates/test_smooth_quant.py similarity index 96% rename from tests/post_training/test_templates/test_smooth_quant.py rename to tests/cross_fw/test_templates/test_smooth_quant.py index c90801674b9..f4ea260c14e 100644 --- a/tests/post_training/test_templates/test_smooth_quant.py +++ b/tests/cross_fw/test_templates/test_smooth_quant.py @@ -28,11 +28,11 @@ from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantization from nncf.quantization.algorithms.smooth_quant.algorithm import SmoothQuant from nncf.quantization.algorithms.smooth_quant.backend import SmoothQuantAlgoBackend -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import LinearMultiShapeModel -from tests.post_training.test_templates.helpers import NonZeroLinearModel -from tests.post_training.test_templates.helpers import ShareWeghtsConvAndShareLinearModel -from tests.post_training.test_templates.helpers import get_static_dataset +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import LinearMultiShapeModel +from tests.cross_fw.test_templates.helpers import NonZeroLinearModel +from tests.cross_fw.test_templates.helpers import ShareWeghtsConvAndShareLinearModel +from tests.cross_fw.test_templates.helpers import get_static_dataset TModel = TypeVar("TModel") TTensor = TypeVar("TTensor") diff --git a/tests/onnx/quantization/test_bias_correction.py b/tests/onnx/quantization/test_bias_correction.py index 2fef33e00b3..40cdf0dc8e1 100644 --- a/tests/onnx/quantization/test_bias_correction.py +++ b/tests/onnx/quantization/test_bias_correction.py @@ -21,11 +21,11 @@ from nncf.onnx.graph.nncf_graph_builder import GraphConverter from nncf.onnx.graph.node_utils import get_bias_value from nncf.quantization.algorithms.bias_correction.onnx_backend import ONNXBiasCorrectionAlgoBackend +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import MultipleConvTestModel +from tests.cross_fw.test_templates.helpers import SplittedModel +from tests.cross_fw.test_templates.test_bias_correction import TemplateTestBCAlgorithm from tests.onnx.quantization.common import compare_nncf_graph -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import MultipleConvTestModel -from tests.post_training.test_templates.helpers import SplittedModel -from tests.post_training.test_templates.test_bias_correction import TemplateTestBCAlgorithm from tests.shared.paths import TEST_ROOT diff --git a/tests/onnx/quantization/test_calculation_quantizer_params.py b/tests/onnx/quantization/test_calculation_quantizer_params.py index 8de2d758fd5..eb0a8864c1e 100644 --- a/tests/onnx/quantization/test_calculation_quantizer_params.py +++ b/tests/onnx/quantization/test_calculation_quantizer_params.py @@ -15,7 +15,7 @@ from nncf.onnx.quantization.quantizer_parameters import get_level_low_level_high from nncf.quantization.fake_quantize import calculate_scale_zero_point from nncf.tensor import Tensor -from tests.post_training.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams +from tests.cross_fw.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams EPS = np.finfo(np.float32).eps diff --git a/tests/onnx/quantization/test_fast_bias_correction.py b/tests/onnx/quantization/test_fast_bias_correction.py index 9a6322e9b76..0ed364ecb80 100644 --- a/tests/onnx/quantization/test_fast_bias_correction.py +++ b/tests/onnx/quantization/test_fast_bias_correction.py @@ -19,7 +19,7 @@ from nncf.onnx.graph.node_utils import get_bias_value from nncf.onnx.graph.node_utils import is_node_with_bias from nncf.quantization.algorithms.fast_bias_correction.onnx_backend import ONNXFastBiasCorrectionAlgoBackend -from tests.post_training.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm +from tests.cross_fw.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm def get_data_from_node(model: onnx.ModelProto, node_name: str): diff --git a/tests/onnx/quantization/test_min_max.py b/tests/onnx/quantization/test_min_max.py index 940b6e0e7bf..5854ccf0761 100644 --- a/tests/onnx/quantization/test_min_max.py +++ b/tests/onnx/quantization/test_min_max.py @@ -21,11 +21,11 @@ from nncf.onnx.graph.transformations.commands import ONNXTargetPoint from nncf.quantization.algorithms.min_max.backend import MinMaxAlgoBackend from nncf.quantization.algorithms.min_max.onnx_backend import ONNXMinMaxAlgoBackend -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.test_min_max import MATMUL_WEIGHT_SHAPE -from tests.post_training.test_templates.test_min_max import TemplateTestGetChannelAxes -from tests.post_training.test_templates.test_min_max import TemplateTestGetTargetPointShape -from tests.post_training.test_templates.test_min_max import TemplateTestMinMaxAlgorithm +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.test_min_max import MATMUL_WEIGHT_SHAPE +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetChannelAxes +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetTargetPointShape +from tests.cross_fw.test_templates.test_min_max import TemplateTestMinMaxAlgorithm class TestONNXMinMaxAlgorithm(TemplateTestMinMaxAlgorithm): diff --git a/tests/onnx/quantization/test_ptq_params.py b/tests/onnx/quantization/test_ptq_params.py index c8bcc04f533..be5ca8669d6 100644 --- a/tests/onnx/quantization/test_ptq_params.py +++ b/tests/onnx/quantization/test_ptq_params.py @@ -34,11 +34,11 @@ from tests.common.quantization.metatypes import Conv2dTestMetatype from tests.common.quantization.metatypes import LinearTestMetatype from tests.common.quantization.metatypes import SoftmaxTestMetatype +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestMatMul +from tests.cross_fw.test_templates.test_ptq_params import TemplateTestPTQParams from tests.onnx.models import LinearModel from tests.onnx.models import OneDepthwiseConvolutionalModel -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestMatMul -from tests.post_training.test_templates.test_ptq_params import TemplateTestPTQParams def get_hw_patterns(device: TargetDevice = TargetDevice.ANY) -> GraphPattern: diff --git a/tests/onnx/quantization/test_quantizer_config.py b/tests/onnx/quantization/test_quantizer_config.py index 593d026d8e8..b82318b34db 100644 --- a/tests/onnx/quantization/test_quantizer_config.py +++ b/tests/onnx/quantization/test_quantizer_config.py @@ -16,10 +16,10 @@ from nncf.onnx.graph.metatypes.onnx_metatypes import ONNXDepthwiseConvolutionMetatype from nncf.onnx.graph.nncf_graph_builder import ONNXLayerAttributes from nncf.quantization.algorithms.min_max.onnx_backend import ONNXMinMaxAlgoBackend -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestDepthwiseConv -from tests.post_training.test_templates.models import NNCFGraphToTestSumAggregation -from tests.post_training.test_templates.test_quantizer_config import TemplateTestQuantizerConfig +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestDepthwiseConv +from tests.cross_fw.test_templates.models import NNCFGraphToTestSumAggregation +from tests.cross_fw.test_templates.test_quantizer_config import TemplateTestQuantizerConfig class TestQuantizerConfig(TemplateTestQuantizerConfig): diff --git a/tests/openvino/native/quantization/test_calculation_quantizer_params.py b/tests/openvino/native/quantization/test_calculation_quantizer_params.py index 217d03d6cd1..aa070771671 100644 --- a/tests/openvino/native/quantization/test_calculation_quantizer_params.py +++ b/tests/openvino/native/quantization/test_calculation_quantizer_params.py @@ -9,7 +9,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from nncf.tensor import Tensor -from tests.post_training.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams +from tests.cross_fw.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams class TestFQParams(TemplateTestFQParams): diff --git a/tests/openvino/native/quantization/test_channel_alignment.py b/tests/openvino/native/quantization/test_channel_alignment.py index 7cae18d975b..a376dbd2fba 100644 --- a/tests/openvino/native/quantization/test_channel_alignment.py +++ b/tests/openvino/native/quantization/test_channel_alignment.py @@ -29,7 +29,7 @@ from nncf.openvino.graph.transformations.commands import OVWeightUpdateCommand from nncf.quantization.algorithms.channel_alignment.backend import LayoutDescriptor from nncf.quantization.algorithms.channel_alignment.openvino_backend import OVChannelAlignmentAlgoBackend -from tests.post_training.test_templates.test_channel_alignment import TemplateTestChannelAlignment +from tests.cross_fw.test_templates.test_channel_alignment import TemplateTestChannelAlignment class TestOVChannelAlignment(TemplateTestChannelAlignment): diff --git a/tests/openvino/native/quantization/test_min_max.py b/tests/openvino/native/quantization/test_min_max.py index 6873a05dd45..fcccf04bf5f 100644 --- a/tests/openvino/native/quantization/test_min_max.py +++ b/tests/openvino/native/quantization/test_min_max.py @@ -22,10 +22,10 @@ from nncf.openvino.graph.transformations.commands import OVTargetPoint from nncf.quantization.algorithms.min_max.backend import MinMaxAlgoBackend from nncf.quantization.algorithms.min_max.openvino_backend import OVMinMaxAlgoBackend -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.test_min_max import TemplateTestGetChannelAxes -from tests.post_training.test_templates.test_min_max import TemplateTestGetTargetPointShape -from tests.post_training.test_templates.test_min_max import TemplateTestMinMaxAlgorithm +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetChannelAxes +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetTargetPointShape +from tests.cross_fw.test_templates.test_min_max import TemplateTestMinMaxAlgorithm class TestOVMinMaxAlgorithm(TemplateTestMinMaxAlgorithm): diff --git a/tests/openvino/native/quantization/test_ptq_params.py b/tests/openvino/native/quantization/test_ptq_params.py index 73b73e511ea..e0200ec07f1 100644 --- a/tests/openvino/native/quantization/test_ptq_params.py +++ b/tests/openvino/native/quantization/test_ptq_params.py @@ -34,10 +34,10 @@ from tests.common.quantization.metatypes import Conv2dTestMetatype from tests.common.quantization.metatypes import LinearTestMetatype from tests.common.quantization.metatypes import SoftmaxTestMetatype +from tests.cross_fw.test_templates.models import NNCFGraphToTestMatMul +from tests.cross_fw.test_templates.test_ptq_params import TemplateTestPTQParams from tests.openvino.native.models import DepthwiseConv4DModel from tests.openvino.native.models import LinearModel -from tests.post_training.test_templates.models import NNCFGraphToTestMatMul -from tests.post_training.test_templates.test_ptq_params import TemplateTestPTQParams def get_hw_patterns(device: TargetDevice = TargetDevice.ANY) -> GraphPattern: diff --git a/tests/openvino/native/quantization/test_quantizer_config.py b/tests/openvino/native/quantization/test_quantizer_config.py index 63472133787..020ef951009 100644 --- a/tests/openvino/native/quantization/test_quantizer_config.py +++ b/tests/openvino/native/quantization/test_quantizer_config.py @@ -16,10 +16,10 @@ from nncf.openvino.graph.metatypes.openvino_metatypes import OVDepthwiseConvolutionMetatype from nncf.openvino.graph.metatypes.openvino_metatypes import OVSumMetatype from nncf.quantization.algorithms.min_max.openvino_backend import OVMinMaxAlgoBackend -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestDepthwiseConv -from tests.post_training.test_templates.models import NNCFGraphToTestSumAggregation -from tests.post_training.test_templates.test_quantizer_config import TemplateTestQuantizerConfig +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestDepthwiseConv +from tests.cross_fw.test_templates.models import NNCFGraphToTestSumAggregation +from tests.cross_fw.test_templates.test_quantizer_config import TemplateTestQuantizerConfig class TestQuantizerConfig(TemplateTestQuantizerConfig): diff --git a/tests/openvino/native/test_bias_correction.py b/tests/openvino/native/test_bias_correction.py index 47ba2789a36..e90ad6c92f0 100644 --- a/tests/openvino/native/test_bias_correction.py +++ b/tests/openvino/native/test_bias_correction.py @@ -22,12 +22,12 @@ from nncf.openvino.graph.nncf_graph_builder import GraphConverter from nncf.openvino.graph.node_utils import get_bias_value from nncf.quantization.algorithms.bias_correction.openvino_backend import OVBiasCorrectionAlgoBackend +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import MultipleConvTestModel +from tests.cross_fw.test_templates.helpers import SplittedModel +from tests.cross_fw.test_templates.test_bias_correction import TemplateTestBCAlgorithm from tests.openvino.native.common import compare_nncf_graphs from tests.openvino.native.common import get_actual_reference_for_current_openvino -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import MultipleConvTestModel -from tests.post_training.test_templates.helpers import SplittedModel -from tests.post_training.test_templates.test_bias_correction import TemplateTestBCAlgorithm class TestOVBCAlgorithm(TemplateTestBCAlgorithm): diff --git a/tests/openvino/native/test_fast_bias_correction.py b/tests/openvino/native/test_fast_bias_correction.py index 32bc605a30d..d788e7b401e 100644 --- a/tests/openvino/native/test_fast_bias_correction.py +++ b/tests/openvino/native/test_fast_bias_correction.py @@ -19,7 +19,7 @@ from nncf.openvino.graph.node_utils import get_bias_value from nncf.openvino.graph.node_utils import is_node_with_bias from nncf.quantization.algorithms.fast_bias_correction.openvino_backend import OVFastBiasCorrectionAlgoBackend -from tests.post_training.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm +from tests.cross_fw.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm class TestOVFBCAlgorithm(TemplateTestFBCAlgorithm): diff --git a/tests/openvino/native/test_layerwise.py b/tests/openvino/native/test_layerwise.py index c964d4c00bf..444647701c7 100644 --- a/tests/openvino/native/test_layerwise.py +++ b/tests/openvino/native/test_layerwise.py @@ -21,7 +21,7 @@ from nncf.quantization.algorithms.layerwise.scheduler import LayerwiseStep from nncf.quantization.algorithms.layerwise.scheduler import NodeOutputPort from nncf.tensor import Tensor -from tests.post_training.test_templates.test_layerwise import TemplateTestLayerwiseEngine +from tests.cross_fw.test_templates.test_layerwise import TemplateTestLayerwiseEngine class TestOVLayerwiseEngine(TemplateTestLayerwiseEngine): diff --git a/tests/openvino/native/test_smooth_quant.py b/tests/openvino/native/test_smooth_quant.py index 27b7f28386d..c4cd64d1a18 100644 --- a/tests/openvino/native/test_smooth_quant.py +++ b/tests/openvino/native/test_smooth_quant.py @@ -22,10 +22,10 @@ from nncf.openvino.graph.metatypes.openvino_metatypes import OVConvolutionMetatype from nncf.openvino.graph.metatypes.openvino_metatypes import OVMatMulMetatype from nncf.quantization.algorithms.smooth_quant.openvino_backend import OVSmoothQuantAlgoBackend -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import LinearMultiShapeModel -from tests.post_training.test_templates.helpers import ShareWeghtsConvAndShareLinearModel -from tests.post_training.test_templates.test_smooth_quant import TemplateTestSQAlgorithm +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import LinearMultiShapeModel +from tests.cross_fw.test_templates.helpers import ShareWeghtsConvAndShareLinearModel +from tests.cross_fw.test_templates.test_smooth_quant import TemplateTestSQAlgorithm OV_LINEAR_MODEL_MM_OP_MAP = { "MatMul1": "aten::matmul/MatMul", diff --git a/tests/post_training/conftest.py b/tests/post_training/conftest.py index 04947f79e6c..a05d20d0d5c 100644 --- a/tests/post_training/conftest.py +++ b/tests/post_training/conftest.py @@ -9,11 +9,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from tests.shared.paths import TEST_ROOT - -PTQ_TEST_ROOT = TEST_ROOT / "post_training" -FQ_CALCULATED_PARAMETERS_PATH = PTQ_TEST_ROOT / "data" / "fq_params" / "fq_params.json" - def pytest_addoption(parser): parser.addoption("--data", action="store", help="Data directory") diff --git a/tests/torch/fx/test_fast_bias_correction.py b/tests/torch/fx/test_fast_bias_correction.py index f66ab71e1a5..dcc5b1e5e8d 100644 --- a/tests/torch/fx/test_fast_bias_correction.py +++ b/tests/torch/fx/test_fast_bias_correction.py @@ -21,7 +21,7 @@ from nncf.quantization.algorithms.fast_bias_correction.torch_fx_backend import FXFastBiasCorrectionAlgoBackend from nncf.torch.dynamic_graph.patch_pytorch import disable_patching from nncf.torch.model_graph_manager import OPERATORS_WITH_BIAS_METATYPES -from tests.post_training.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm +from tests.cross_fw.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm class TestTorchFXFBCAlgorithm(TemplateTestFBCAlgorithm): diff --git a/tests/torch/fx/test_smooth_quant.py b/tests/torch/fx/test_smooth_quant.py index 754786ec0e9..a6b468fc58e 100644 --- a/tests/torch/fx/test_smooth_quant.py +++ b/tests/torch/fx/test_smooth_quant.py @@ -29,10 +29,10 @@ from nncf.torch import disable_patching from nncf.torch.graph.operator_metatypes import PTConv2dMetatype from nncf.torch.graph.operator_metatypes import PTLinearMetatype -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import LinearMultiShapeModel -from tests.post_training.test_templates.helpers import ShareWeghtsConvAndShareLinearModel -from tests.post_training.test_templates.test_smooth_quant import TemplateTestSQAlgorithm +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import LinearMultiShapeModel +from tests.cross_fw.test_templates.helpers import ShareWeghtsConvAndShareLinearModel +from tests.cross_fw.test_templates.test_smooth_quant import TemplateTestSQAlgorithm PT_LINEAR_MODEL_MM_MAP = {"Linear1": "linear_3", "Linear2": "linear_2", "Linear3": "linear", "Linear4": "linear_1"} diff --git a/tests/torch/ptq/helpers.py b/tests/torch/ptq/helpers.py index 55658ff3c35..0eb186857ae 100644 --- a/tests/torch/ptq/helpers.py +++ b/tests/torch/ptq/helpers.py @@ -22,9 +22,9 @@ from nncf.torch.graph.operator_metatypes import PTModuleDepthwiseConv2dSubtype from nncf.torch.graph.operator_metatypes import PTModuleLinearMetatype from nncf.torch.graph.operator_metatypes import PTSumMetatype -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestDepthwiseConv -from tests.post_training.test_templates.models import NNCFGraphToTestSumAggregation +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestDepthwiseConv +from tests.cross_fw.test_templates.models import NNCFGraphToTestSumAggregation def get_single_conv_nncf_graph() -> NNCFGraphToTest: diff --git a/tests/torch/ptq/test_calculation_quantizer_params.py b/tests/torch/ptq/test_calculation_quantizer_params.py index 06c0ad1b64c..556b5f9e387 100644 --- a/tests/torch/ptq/test_calculation_quantizer_params.py +++ b/tests/torch/ptq/test_calculation_quantizer_params.py @@ -34,7 +34,7 @@ from nncf.tensor import functions as fns from nncf.torch.model_creation import wrap_model from nncf.torch.statistics.aggregator import PTStatisticsAggregator -from tests.post_training.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams +from tests.cross_fw.test_templates.test_calculate_quantizer_parameters import TemplateTestFQParams from tests.torch.helpers import get_all_inputs_for_graph_node from tests.torch.helpers import get_nodes_by_type diff --git a/tests/torch/ptq/test_fast_bias_correction.py b/tests/torch/ptq/test_fast_bias_correction.py index 5ad49040499..5b3c6c0ce3c 100644 --- a/tests/torch/ptq/test_fast_bias_correction.py +++ b/tests/torch/ptq/test_fast_bias_correction.py @@ -19,7 +19,7 @@ from nncf.torch.model_graph_manager import get_fused_bias_value from nncf.torch.model_graph_manager import is_node_with_fused_bias from nncf.torch.nncf_network import NNCFNetwork -from tests.post_training.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm +from tests.cross_fw.test_templates.test_fast_bias_correction import TemplateTestFBCAlgorithm from tests.torch.ptq.helpers import get_nncf_network diff --git a/tests/torch/ptq/test_graphs.py b/tests/torch/ptq/test_graphs.py index aa427735b53..2dd649712f7 100644 --- a/tests/torch/ptq/test_graphs.py +++ b/tests/torch/ptq/test_graphs.py @@ -22,8 +22,8 @@ from nncf.torch import wrap_model from nncf.torch.layers import NNCF_RNN from nncf.torch.layers import LSTMCellNNCF -from tests.post_training.test_templates.helpers import EmbeddingModel -from tests.post_training.test_templates.helpers import ScaledDotProductAttentionModel +from tests.cross_fw.test_templates.helpers import EmbeddingModel +from tests.cross_fw.test_templates.helpers import ScaledDotProductAttentionModel from tests.torch import test_models from tests.torch.quantization.test_algo_quantization import SharedLayersModel from tests.torch.test_compressed_graph import ModelDesc diff --git a/tests/torch/ptq/test_min_max.py b/tests/torch/ptq/test_min_max.py index 73003157865..5c005592d4e 100644 --- a/tests/torch/ptq/test_min_max.py +++ b/tests/torch/ptq/test_min_max.py @@ -25,10 +25,10 @@ from nncf.torch.graph.operator_metatypes import PTDepthwiseConv2dSubtype from nncf.torch.graph.operator_metatypes import PTLinearMetatype from nncf.torch.graph.transformations.commands import PTTargetPoint -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.test_min_max import TemplateTestGetChannelAxes -from tests.post_training.test_templates.test_min_max import TemplateTestGetTargetPointShape -from tests.post_training.test_templates.test_min_max import TemplateTestMinMaxAlgorithm +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetChannelAxes +from tests.cross_fw.test_templates.test_min_max import TemplateTestGetTargetPointShape +from tests.cross_fw.test_templates.test_min_max import TemplateTestMinMaxAlgorithm class TestTorchMinMaxAlgorithm(TemplateTestMinMaxAlgorithm): diff --git a/tests/torch/ptq/test_ptq_params.py b/tests/torch/ptq/test_ptq_params.py index 7404c211002..026d1da3086 100644 --- a/tests/torch/ptq/test_ptq_params.py +++ b/tests/torch/ptq/test_ptq_params.py @@ -33,7 +33,7 @@ from tests.common.quantization.metatypes import Conv2dTestMetatype from tests.common.quantization.metatypes import LinearTestMetatype from tests.common.quantization.metatypes import SoftmaxTestMetatype -from tests.post_training.test_templates.test_ptq_params import TemplateTestPTQParams +from tests.cross_fw.test_templates.test_ptq_params import TemplateTestPTQParams from tests.torch.helpers import create_bn from tests.torch.helpers import create_conv from tests.torch.helpers import create_depthwise_conv diff --git a/tests/torch/ptq/test_quantizer_config.py b/tests/torch/ptq/test_quantizer_config.py index 2ce6fc4d177..acc8cb4002d 100644 --- a/tests/torch/ptq/test_quantizer_config.py +++ b/tests/torch/ptq/test_quantizer_config.py @@ -12,10 +12,10 @@ import pytest from nncf.quantization.algorithms.min_max.torch_backend import PTMinMaxAlgoBackend -from tests.post_training.test_templates.models import NNCFGraphToTest -from tests.post_training.test_templates.models import NNCFGraphToTestDepthwiseConv -from tests.post_training.test_templates.models import NNCFGraphToTestSumAggregation -from tests.post_training.test_templates.test_quantizer_config import TemplateTestQuantizerConfig +from tests.cross_fw.test_templates.models import NNCFGraphToTest +from tests.cross_fw.test_templates.models import NNCFGraphToTestDepthwiseConv +from tests.cross_fw.test_templates.models import NNCFGraphToTestSumAggregation +from tests.cross_fw.test_templates.test_quantizer_config import TemplateTestQuantizerConfig from tests.torch.ptq.helpers import get_depthwise_conv_nncf_graph from tests.torch.ptq.helpers import get_single_conv_nncf_graph from tests.torch.ptq.helpers import get_sum_aggregation_nncf_graph diff --git a/tests/torch/ptq/test_smooth_quant.py b/tests/torch/ptq/test_smooth_quant.py index 52e740aa0c8..3d4f83df3a0 100644 --- a/tests/torch/ptq/test_smooth_quant.py +++ b/tests/torch/ptq/test_smooth_quant.py @@ -22,10 +22,10 @@ from nncf.torch.graph.operator_metatypes import PTLinearMetatype from nncf.torch.graph.transformations.commands import ExtraCompressionModuleType from nncf.torch.model_creation import wrap_model -from tests.post_training.test_templates.helpers import ConvTestModel -from tests.post_training.test_templates.helpers import LinearMultiShapeModel -from tests.post_training.test_templates.helpers import ShareWeghtsConvAndShareLinearModel -from tests.post_training.test_templates.test_smooth_quant import TemplateTestSQAlgorithm +from tests.cross_fw.test_templates.helpers import ConvTestModel +from tests.cross_fw.test_templates.helpers import LinearMultiShapeModel +from tests.cross_fw.test_templates.helpers import ShareWeghtsConvAndShareLinearModel +from tests.cross_fw.test_templates.test_smooth_quant import TemplateTestSQAlgorithm PT_LINEAR_MODEL_SQ_MAP = { ("Linear1",): "LinearMultiShapeModel/split_0_1_0/nncf_smooth_quant", diff --git a/tests/torch/test_extractor.py b/tests/torch/test_extractor.py index e592e6491d8..7d7219ce3fc 100644 --- a/tests/torch/test_extractor.py +++ b/tests/torch/test_extractor.py @@ -13,7 +13,7 @@ import torch from torch import nn -import tests.post_training.test_templates.helpers as helpers +import tests.cross_fw.test_templates.helpers as helpers from nncf.common.graph.transformations.commands import TargetType from nncf.torch import wrap_model from nncf.torch.extractor import extract_model diff --git a/tests/torch/test_model_graph_manager.py b/tests/torch/test_model_graph_manager.py index 457ae7c0af1..ef1501a9fc5 100644 --- a/tests/torch/test_model_graph_manager.py +++ b/tests/torch/test_model_graph_manager.py @@ -17,7 +17,7 @@ from torch import nn import nncf.torch.graph.operator_metatypes as om -import tests.post_training.test_templates.helpers as helpers +import tests.cross_fw.test_templates.helpers as helpers from nncf.common.graph.graph import NNCFGraph from nncf.common.graph.graph import NNCFNode from nncf.common.graph.transformations.commands import TargetType diff --git a/tests/torch/test_nncf_graph.py b/tests/torch/test_nncf_graph.py index 67cb0d63b48..72f92e68bc0 100644 --- a/tests/torch/test_nncf_graph.py +++ b/tests/torch/test_nncf_graph.py @@ -15,7 +15,7 @@ from nncf.common.graph.operator_metatypes import OperatorMetatype from nncf.torch.graph.graph import PTNNCFGraph from nncf.torch.graph.operator_metatypes import PTModuleConv2dMetatype -from tests.post_training.test_templates.models import NNCFGraphToTestConstantFiltering +from tests.cross_fw.test_templates.models import NNCFGraphToTestConstantFiltering class DummyConstantMetatype(OperatorMetatype):