Skip to content

Commit

Permalink
Move tests.shared to tests.cross_fw.shared (#2961)
Browse files Browse the repository at this point in the history
### Changes

Moved tests.shared to tests.cross_fw.shared
  • Loading branch information
AlexanderDokuchaev authored Sep 19, 2024
1 parent 631c3e4 commit 393c2dd
Show file tree
Hide file tree
Showing 96 changed files with 157 additions and 171 deletions.
2 changes: 1 addition & 1 deletion nncf/tensor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ tensor_a[0:2] # Tensor(array([[1],[2]]))
return torch.foo(a, arg1)
```

4. Add test of method to [test template](/tests/shared/test_templates/template_test_nncf_tensor.py) for Tensor class
4. Add test of method to [test template](/tests/cross_fw/test_templates/template_test_nncf_tensor.py) for Tensor class

### Add new backend

Expand Down
2 changes: 1 addition & 1 deletion tests/common/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# limitations under the License.


from tests.shared.logging import nncf_caplog # noqa: F401
from tests.cross_fw.shared.logging import nncf_caplog # noqa: F401
4 changes: 2 additions & 2 deletions tests/common/graph/test_dot_file_rw.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from nncf.common.utils.dot_file_rw import read_dot_graph
from nncf.common.utils.dot_file_rw import write_dot_graph
from tests.shared.nx_graph import check_nx_graph
from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.nx_graph import check_nx_graph
from tests.cross_fw.shared.paths import TEST_ROOT


@pytest.fixture(scope="module")
Expand Down
4 changes: 2 additions & 2 deletions tests/common/quantization/test_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
from nncf.common.graph.operator_metatypes import OperatorMetatype
from nncf.quantization.passes import find_constant_subgraphs
from nncf.quantization.passes import remove_nodes_and_reconnect_graph
from tests.cross_fw.shared.nx_graph import compare_nx_graph_with_reference
from tests.cross_fw.shared.paths import TEST_ROOT
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

DATA_ROOT = TEST_ROOT / "common" / "data" / "reference_graphs"

Expand Down
4 changes: 2 additions & 2 deletions tests/common/sdl/test_config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import pytest

from nncf.config import NNCFConfig
from tests.shared.paths import PROJECT_ROOT
from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.paths import PROJECT_ROOT
from tests.cross_fw.shared.paths import TEST_ROOT

GOOD_CONFIG_SOURCES = [
PROJECT_ROOT / Path("examples/torch/classification/configs"),
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from nncf.tensor import TensorDataType
from nncf.tensor.definitions import TensorBackend
from nncf.tensor.definitions import TensorDeviceType
from tests.shared.test_templates.template_test_nncf_tensor import TemplateTestNNCFTensorOperators
from tests.cross_fw.test_templates.template_test_nncf_tensor import TemplateTestNNCFTensorOperators


class TestNPNNCFTensorOperators(TemplateTestNNCFTensorOperators):
Expand Down
2 changes: 1 addition & 1 deletion tests/cross_fw/examples/run_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pathlib import Path
from typing import Dict, Tuple, Union

from tests.shared.paths import PROJECT_ROOT
from tests.cross_fw.shared.paths import PROJECT_ROOT


def post_training_quantization_mobilenet_v2(example_root_dir: str) -> Dict[str, float]:
Expand Down
16 changes: 8 additions & 8 deletions tests/cross_fw/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import pytest

from tests.shared.case_collection import skip_if_backend_not_selected
from tests.shared.command import Command
from tests.shared.helpers import create_venv_with_nncf
from tests.shared.helpers import get_pip_executable_with_venv
from tests.shared.helpers import get_python_executable_with_venv
from tests.shared.helpers import load_json
from tests.shared.paths import PROJECT_ROOT
from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.case_collection import skip_if_backend_not_selected
from tests.cross_fw.shared.command import Command
from tests.cross_fw.shared.helpers import create_venv_with_nncf
from tests.cross_fw.shared.helpers import get_pip_executable_with_venv
from tests.cross_fw.shared.helpers import get_python_executable_with_venv
from tests.cross_fw.shared.helpers import load_json
from tests.cross_fw.shared.paths import PROJECT_ROOT
from tests.cross_fw.shared.paths import TEST_ROOT

EXAMPLE_TEST_ROOT = TEST_ROOT / "cross_fw" / "examples"
EXAMPLE_SCOPE_PATH = EXAMPLE_TEST_ROOT / "example_scope.json"
Expand Down
12 changes: 6 additions & 6 deletions tests/cross_fw/install/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from nncf.common.utils.os import is_linux
from nncf.common.utils.os import is_windows
from tests.cross_fw.install.conftest import TESTED_BACKENDS
from tests.shared.case_collection import skip_if_backend_not_selected
from tests.shared.helpers import create_venv_with_nncf
from tests.shared.helpers import get_pip_executable_with_venv
from tests.shared.helpers import get_python_executable_with_venv
from tests.shared.paths import PROJECT_ROOT
from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.case_collection import skip_if_backend_not_selected
from tests.cross_fw.shared.helpers import create_venv_with_nncf
from tests.cross_fw.shared.helpers import get_pip_executable_with_venv
from tests.cross_fw.shared.helpers import get_python_executable_with_venv
from tests.cross_fw.shared.paths import PROJECT_ROOT
from tests.cross_fw.shared.paths import TEST_ROOT


def run_install_checks(venv_path: Path, tmp_path: Path, package_type: str, backend: str, install_type: str):
Expand Down
2 changes: 1 addition & 1 deletion tests/cross_fw/sdl/fuzz/quantize_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import atheris

from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.paths import TEST_ROOT

with atheris.instrument_imports():
import nncf
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/shared/helpers.py → tests/cross_fw/shared/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import nncf
from nncf.common.utils.os import is_linux
from nncf.common.utils.os import is_windows
from tests.shared.paths import GITHUB_REPO_URL
from tests.shared.paths import PROJECT_ROOT
from tests.cross_fw.shared.paths import GITHUB_REPO_URL
from tests.cross_fw.shared.paths import PROJECT_ROOT

TensorType = TypeVar("TensorType")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import pytest

from tests.shared.helpers import create_venv_with_nncf
from tests.cross_fw.shared.helpers import create_venv_with_nncf


@pytest.fixture(scope="function")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/shared/paths.py → tests/cross_fw/shared/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import os
from pathlib import Path

TEST_ROOT = Path(__file__).absolute().parents[1]
TEST_ROOT = Path(__file__).parent.absolute().parents[1]
PROJECT_ROOT = TEST_ROOT.parent.absolute()
EXAMPLES_DIR = PROJECT_ROOT / "examples"
GITHUB_REPO_URL = "https://github.com/openvinotoolkit/nncf/"


DATASET_DEFINITIONS_PATH = TEST_ROOT / "shared" / "data" / "dataset_definitions.yml"
DATASET_DEFINITIONS_PATH = TEST_ROOT / "cross_fw" / "shared" / "data" / "dataset_definitions.yml"

ROOT_PYTHONPATH_ENV = os.environ.copy().update({"PYTHONPATH": str(PROJECT_ROOT)})

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
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.shared.helpers import dump_to_json
from tests.shared.helpers import load_json
from tests.cross_fw.shared.helpers import dump_to_json
from tests.cross_fw.shared.helpers import load_json

FQ_CALCULATED_PARAMETERS_PATH = Path(__file__).parent / "fq_params" / "fq_params.json"

Expand Down
2 changes: 1 addition & 1 deletion tests/onnx/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import os

from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.paths import TEST_ROOT


def pytest_addoption(parser):
Expand Down
6 changes: 3 additions & 3 deletions tests/onnx/quantization/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
from nncf.quantization.algorithms.post_training.algorithm import PostTrainingQuantization
from nncf.quantization.fake_quantize import FakeQuantizeParameters
from nncf.tensor import Tensor
from tests.cross_fw.shared.nx_graph import check_nx_graph
from tests.cross_fw.shared.nx_graph import compare_nx_graph_with_reference
from tests.cross_fw.shared.paths import TEST_ROOT
from tests.onnx.common import get_random_generator
from tests.onnx.opset_converter import convert_opset_version
from tests.shared.nx_graph import check_nx_graph
from tests.shared.nx_graph import compare_nx_graph_with_reference
from tests.shared.paths import TEST_ROOT

REFERENCE_GRAPHS_TEST_ROOT = "data/reference_graphs/quantization"

Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/quantization/test_qdq_params_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from nncf.onnx.graph.onnx_helper import get_tensor_value
from nncf.quantization.advanced_parameters import AdvancedQuantizationParameters
from nncf.quantization.advanced_parameters import OverflowFix
from tests.cross_fw.shared.helpers import compare_stats
from tests.cross_fw.shared.helpers import load_json
from tests.onnx.conftest import ONNX_TEST_ROOT
from tests.onnx.models import EmbeddingModel
from tests.onnx.models import GEMMTransposeWeightModel
Expand All @@ -28,8 +30,6 @@
from tests.onnx.models import ReshapeWeightModel
from tests.onnx.models import WeightSharingModel
from tests.onnx.quantization.common import min_max_quantize_model
from tests.shared.helpers import compare_stats
from tests.shared.helpers import load_json

REFERENCE_SCALES_DIR = ONNX_TEST_ROOT / "data" / "reference_scales"

Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/test_e2e_ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
from yattag import indent

from nncf.common.logging.logger import nncf_logger
from tests.cross_fw.shared.paths import DATASET_DEFINITIONS_PATH
from tests.cross_fw.shared.paths import PROJECT_ROOT
from tests.onnx.conftest import ONNX_TEST_ROOT
from tests.shared.paths import DATASET_DEFINITIONS_PATH
from tests.shared.paths import PROJECT_ROOT

BG_COLOR_GREEN_HEX = "ccffcc"
BG_COLOR_YELLOW_HEX = "ffffcc"
Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/test_nncf_graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

from nncf.onnx.graph.model_transformer import ONNXModelTransformer
from nncf.onnx.graph.nncf_graph_builder import GraphConverter
from tests.cross_fw.shared.nx_graph import compare_nx_graph_with_reference
from tests.cross_fw.shared.paths import TEST_ROOT
from tests.onnx.conftest import ONNX_TEST_ROOT
from tests.onnx.models import ALL_SYNTHETIC_MODELS
from tests.onnx.models import OneConvolutionalModel
from tests.onnx.opset_converter import convert_opset_version
from tests.onnx.quantization.common import ModelToTest
from tests.onnx.weightless_model import load_model_topology_with_zeros_weights
from tests.shared.nx_graph import compare_nx_graph_with_reference
from tests.shared.paths import TEST_ROOT

REFERENCE_GRAPHS_DIR = ONNX_TEST_ROOT / "data" / "reference_graphs" / "original_nncf_graph"

Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/test_pattern_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from nncf.common.graph.patterns import HWFusedPatternNames
from nncf.common.graph.patterns import IgnoredPatternNames
from nncf.common.utils.backend import BackendType
from tests.shared.patterns import check_hw_patterns
from tests.shared.patterns import check_ignored_patterns
from tests.cross_fw.shared.patterns import check_hw_patterns
from tests.cross_fw.shared.patterns import check_ignored_patterns

IGNORING_HW_PATTERN_REASONS = {
HWFusedPatternNames.L2_NORM: "Not relevant for ONNX.",
Expand Down
4 changes: 2 additions & 2 deletions tests/onnx/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import nncf
from tests.cross_fw.shared.datasets import MockDataset
from tests.cross_fw.shared.helpers import telemetry_send_event_test_driver
from tests.onnx.models import LinearModel
from tests.shared.datasets import MockDataset
from tests.shared.helpers import telemetry_send_event_test_driver


def test_telemetry_is_sent_via_quantize(mocker):
Expand Down
8 changes: 4 additions & 4 deletions tests/openvino/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

import pytest

from tests.shared.case_collection import COMMON_SCOPE_MARKS_VS_OPTIONS
from tests.shared.case_collection import skip_marked_cases_if_options_not_specified
from tests.shared.install_fixtures import tmp_venv_with_nncf # noqa: F401
from tests.shared.paths import TEST_ROOT
from tests.cross_fw.shared.case_collection import COMMON_SCOPE_MARKS_VS_OPTIONS
from tests.cross_fw.shared.case_collection import skip_marked_cases_if_options_not_specified
from tests.cross_fw.shared.install_fixtures import tmp_venv_with_nncf # noqa: F401
from tests.cross_fw.shared.paths import TEST_ROOT


def pytest_addoption(parser):
Expand Down
4 changes: 2 additions & 2 deletions tests/openvino/native/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

from nncf import Dataset
from nncf.openvino.graph.nncf_graph_builder import GraphConverter
from tests.cross_fw.shared.nx_graph import compare_nx_graph_with_reference
from tests.cross_fw.shared.openvino_version import get_openvino_version
from tests.openvino.conftest import OPENVINO_NATIVE_TEST_ROOT
from tests.shared.nx_graph import compare_nx_graph_with_reference
from tests.shared.openvino_version import get_openvino_version


def convert_torch_model(model: torch.nn.Module, input_shape: Tuple[int], tmp_path: Path) -> ov.Model:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from nncf.parameters import QuantizationMode
from nncf.quantization.advanced_parameters import OverflowFix
from nncf.quantization.algorithms.min_max.algorithm import MinMaxQuantization
from tests.cross_fw.shared.helpers import compare_stats
from tests.cross_fw.shared.helpers import load_json
from tests.openvino.native.common import convert_torch_model
from tests.openvino.native.common import get_actual_reference_for_current_openvino
from tests.openvino.native.common import get_dataset_for_test
Expand All @@ -32,8 +34,6 @@
from tests.openvino.native.models import UnifiedScalesModel
from tests.openvino.native.models import WeightsModel
from tests.openvino.native.models import get_torch_model_info
from tests.shared.helpers import compare_stats
from tests.shared.helpers import load_json

REFERENCE_SCALES_DIR = Path("reference_scales")

Expand Down
2 changes: 1 addition & 1 deletion tests/openvino/native/quantization/test_quantize_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import nncf
from nncf import Dataset
from tests.shared.datasets import MockDataset
from tests.cross_fw.shared.datasets import MockDataset

INPUT_SHAPE = [2, 1, 1, 1]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
from nncf.quantization.algorithms.weight_compression.weight_lowering import reshape_weight_for_grouped_quantization
from nncf.scopes import IgnoredScope
from nncf.tensor import Tensor
from tests.cross_fw.shared.helpers import compare_stats
from tests.cross_fw.shared.helpers import dump_to_json
from tests.cross_fw.shared.helpers import load_json
from tests.openvino.native.common import get_actual_reference_for_current_openvino
from tests.openvino.native.models import AWQActMatmulModel
from tests.openvino.native.models import AWQMatmulModel
Expand All @@ -52,9 +55,6 @@
from tests.openvino.native.models import SequentialMatmulModel
from tests.openvino.native.models import WeightsModel
from tests.openvino.native.quantization.test_fq_params_calculation import REFERENCE_SCALES_DIR
from tests.shared.helpers import compare_stats
from tests.shared.helpers import dump_to_json
from tests.shared.helpers import load_json

TEST_MODELS = {
IntegerModel: ["matmul_2_data", "gather_2_data", "matmul_1_data"],
Expand Down
4 changes: 2 additions & 2 deletions tests/openvino/native/test_pattern_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# limitations under the License.
from nncf.common.graph.patterns import HWFusedPatternNames
from nncf.common.utils.backend import BackendType
from tests.shared.patterns import check_hw_patterns
from tests.shared.patterns import check_ignored_patterns
from tests.cross_fw.shared.patterns import check_hw_patterns
from tests.cross_fw.shared.patterns import check_ignored_patterns

IGNORING_HW_PATTERN_REASONS = {
HWFusedPatternNames.L2_NORM: "Not relevant for OpenVINO.",
Expand Down
4 changes: 2 additions & 2 deletions tests/openvino/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import nncf
from nncf import Dataset
from tests.shared.datasets import MockDataset
from tests.shared.helpers import telemetry_send_event_test_driver
from tests.cross_fw.shared.datasets import MockDataset
from tests.cross_fw.shared.helpers import telemetry_send_event_test_driver

INPUT_SHAPE = [2, 1, 1, 1]

Expand Down
2 changes: 1 addition & 1 deletion tests/post_training/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import nncf
from nncf import TargetDevice
from tests.shared.command import Command
from tests.cross_fw.shared.command import Command
from tools.memory_monitor import MemoryType
from tools.memory_monitor import MemoryUnit
from tools.memory_monitor import memory_monitor_context
Expand Down
2 changes: 1 addition & 1 deletion tests/post_training/pipelines/lm_weight_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
from whowhatbench import Evaluator

import nncf
from tests.cross_fw.shared.paths import TEST_ROOT
from tests.post_training.pipelines.base import BackendType
from tests.post_training.pipelines.base import BaseTestPipeline
from tests.post_training.pipelines.base import StatsFromOutput
from tests.shared.paths import TEST_ROOT
from tools.memory_monitor import MemoryType
from tools.memory_monitor import MemoryUnit
from tools.memory_monitor import memory_monitor_context
Expand Down
2 changes: 1 addition & 1 deletion tests/post_training/test_quantize_conformance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from packaging import version

import nncf
from tests.cross_fw.shared.openvino_version import get_openvino_version
from tests.post_training.model_scope import PTQ_TEST_CASES
from tests.post_training.model_scope import WC_TEST_CASES
from tests.post_training.pipelines.base import BackendType
from tests.post_training.pipelines.base import BaseTestPipeline
from tests.post_training.pipelines.base import RunInfo
from tests.shared.openvino_version import get_openvino_version

DATA_ROOT = Path(__file__).parent / "data"

Expand Down
4 changes: 0 additions & 4 deletions tests/shared/README.md

This file was deleted.

Loading

0 comments on commit 393c2dd

Please sign in to comment.