diff --git a/.github/workflows/run_keras_tests.yml b/.github/workflows/run_keras_tests.yml index 0bcda518f..fa32a0183 100644 --- a/.github/workflows/run_keras_tests.yml +++ b/.github/workflows/run_keras_tests.yml @@ -32,5 +32,5 @@ jobs: - name: Run pytest run: | - pytest tests_pytest/keras + pytest tests_pytest/keras_tests diff --git a/.github/workflows/run_pytorch_tests.yml b/.github/workflows/run_pytorch_tests.yml index 5f61a610d..4627ae522 100644 --- a/.github/workflows/run_pytorch_tests.yml +++ b/.github/workflows/run_pytorch_tests.yml @@ -31,5 +31,5 @@ jobs: python -m unittest discover tests/pytorch_tests -v - name: Run pytest run: | - pytest tests_pytest/pytorch + pytest tests_pytest/pytorch_tests diff --git a/.github/workflows/run_tests_suite_coverage.yml b/.github/workflows/run_tests_suite_coverage.yml index f1fe68e74..b5bef33d4 100644 --- a/.github/workflows/run_tests_suite_coverage.yml +++ b/.github/workflows/run_tests_suite_coverage.yml @@ -39,7 +39,7 @@ jobs: run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest discover tests/common_tests -v - name: Run common tests (pytest) - run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/common + run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/common_tests - name: Set up TensorFlow environment run: | @@ -56,7 +56,7 @@ jobs: - name: Run TensorFlow tests (pytest) run: | source tf_env/bin/activate - coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/keras + coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/keras_tests - name: Set up PyTorch environment run: | @@ -74,7 +74,7 @@ jobs: - name: Run PyTorch tests (pytest) run: | source torch_env/bin/activate - coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/pytorch + coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" pytest tests_pytest/pytorch_tests - name: Combine Multiple Coverage Files run: coverage combine diff --git a/.github/workflows/tests_common.yml b/.github/workflows/tests_common.yml index 563d803d5..e5a3735ff 100644 --- a/.github/workflows/tests_common.yml +++ b/.github/workflows/tests_common.yml @@ -31,5 +31,5 @@ jobs: run: python -m unittest discover tests/common_tests -v - name: Run pytest - run: pytest tests_pytest/common + run: pytest tests_pytest/common_tests diff --git a/tests_pytest/base_test_classes/__init__.py b/tests_pytest/common_tests/__init__.py similarity index 100% rename from tests_pytest/base_test_classes/__init__.py rename to tests_pytest/common_tests/__init__.py diff --git a/tests_pytest/common/__init__.py b/tests_pytest/common_tests/core/__init__.py similarity index 100% rename from tests_pytest/common/__init__.py rename to tests_pytest/common_tests/core/__init__.py diff --git a/tests_pytest/common/core/__init__.py b/tests_pytest/common_tests/core/common/__init__.py similarity index 100% rename from tests_pytest/common/core/__init__.py rename to tests_pytest/common_tests/core/common/__init__.py diff --git a/tests_pytest/common/core/common/collectors/__init__.py b/tests_pytest/common_tests/core/common/collectors/__init__.py similarity index 100% rename from tests_pytest/common/core/common/collectors/__init__.py rename to tests_pytest/common_tests/core/common/collectors/__init__.py diff --git a/tests_pytest/common/core/common/collectors/test_weighted_histogram_collector.py b/tests_pytest/common_tests/core/common/collectors/test_weighted_histogram_collector.py similarity index 100% rename from tests_pytest/common/core/common/collectors/test_weighted_histogram_collector.py rename to tests_pytest/common_tests/core/common/collectors/test_weighted_histogram_collector.py diff --git a/tests_pytest/common/core/common/__init__.py b/tests_pytest/common_tests/core/common/mixed_precision/__init__.py similarity index 100% rename from tests_pytest/common/core/common/__init__.py rename to tests_pytest/common_tests/core/common/mixed_precision/__init__.py diff --git a/tests_pytest/common/core/common/mixed_precision/__init__.py b/tests_pytest/common_tests/core/common/mixed_precision/resource_utilization_tools/__init__.py similarity index 100% rename from tests_pytest/common/core/common/mixed_precision/__init__.py rename to tests_pytest/common_tests/core/common/mixed_precision/resource_utilization_tools/__init__.py diff --git a/tests_pytest/common/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py b/tests_pytest/common_tests/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py similarity index 99% rename from tests_pytest/common/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py rename to tests_pytest/common_tests/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py index 3f37f4e35..ad3ab3558 100644 --- a/tests_pytest/common/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py +++ b/tests_pytest/common_tests/core/common/mixed_precision/resource_utilization_tools/test_resource_utilization_calculator.py @@ -31,7 +31,7 @@ RUTarget from model_compression_toolkit.core.common.mixed_precision.resource_utilization_tools.resource_utilization_calculator import \ Utilization, ResourceUtilizationCalculator, TargetInclusionCriterion, BitwidthMode -from tests_pytest.common.graph_builder_utils import build_node, full_attr_name, build_qc +from tests_pytest.test_util.graph_builder_utils import build_node, full_attr_name, build_qc @pytest.fixture diff --git a/tests_pytest/common/core/common/mixed_precision/test_filter_candidates_for_mixed_precision.py b/tests_pytest/common_tests/core/common/mixed_precision/test_filter_candidates_for_mixed_precision.py similarity index 100% rename from tests_pytest/common/core/common/mixed_precision/test_filter_candidates_for_mixed_precision.py rename to tests_pytest/common_tests/core/common/mixed_precision/test_filter_candidates_for_mixed_precision.py diff --git a/tests_pytest/common/core/common/mixed_precision/test_greedy_solution_refinement.py b/tests_pytest/common_tests/core/common/mixed_precision/test_greedy_solution_refinement.py similarity index 100% rename from tests_pytest/common/core/common/mixed_precision/test_greedy_solution_refinement.py rename to tests_pytest/common_tests/core/common/mixed_precision/test_greedy_solution_refinement.py diff --git a/tests_pytest/common/core/common/quantization/__init__.py b/tests_pytest/common_tests/core/common/quantization/__init__.py similarity index 100% rename from tests_pytest/common/core/common/quantization/__init__.py rename to tests_pytest/common_tests/core/common/quantization/__init__.py diff --git a/tests_pytest/common/core/common/quantization/quantization_params_selection/__init__.py b/tests_pytest/common_tests/core/common/quantization/quantization_params_selection/__init__.py similarity index 100% rename from tests_pytest/common/core/common/quantization/quantization_params_selection/__init__.py rename to tests_pytest/common_tests/core/common/quantization/quantization_params_selection/__init__.py diff --git a/tests_pytest/common/core/common/quantization/quantization_params_selection/test_qarams_activations_computation.py b/tests_pytest/common_tests/core/common/quantization/quantization_params_selection/test_qarams_activations_computation.py similarity index 100% rename from tests_pytest/common/core/common/quantization/quantization_params_selection/test_qarams_activations_computation.py rename to tests_pytest/common_tests/core/common/quantization/quantization_params_selection/test_qarams_activations_computation.py diff --git a/tests_pytest/common/test_model_collector.py b/tests_pytest/common_tests/test_model_collector.py similarity index 99% rename from tests_pytest/common/test_model_collector.py rename to tests_pytest/common_tests/test_model_collector.py index 0ef69d4f3..3f16dbe6c 100644 --- a/tests_pytest/common/test_model_collector.py +++ b/tests_pytest/common_tests/test_model_collector.py @@ -13,7 +13,7 @@ # limitations under the License. # ============================================================================== import pytest -from unittest.mock import Mock, call +from unittest.mock import Mock import numpy as np from numpy.testing import assert_array_equal @@ -23,7 +23,7 @@ from model_compression_toolkit.core.common.graph.edge import Edge from model_compression_toolkit.core.common.hessian import HessianInfoService from model_compression_toolkit.core.common.model_collector import create_stats_collector_for_node, create_tensor2node, ModelCollector -from tests_pytest.common.graph_builder_utils import build_node, DummyLayer, build_qc +from tests_pytest.test_util.graph_builder_utils import build_node, DummyLayer, build_qc @pytest.fixture diff --git a/tests_pytest/conftest.py b/tests_pytest/conftest.py index ae83e9e71..24e49a589 100644 --- a/tests_pytest/conftest.py +++ b/tests_pytest/conftest.py @@ -12,16 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -from mct_quantizers import QuantizationMethod from unittest.mock import Mock from pytest import fixture -from model_compression_toolkit.core import FrameworkInfo, QuantizationConfig +from model_compression_toolkit.core import FrameworkInfo from model_compression_toolkit.core.common import Graph from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation from model_compression_toolkit.target_platform_capabilities import OpQuantizationConfig, Signedness, \ - QuantizationConfigOptions, TargetPlatformCapabilities + QuantizationConfigOptions, QuantizationMethod, TargetPlatformCapabilities @fixture diff --git a/tests_pytest/common/core/common/mixed_precision/resource_utilization_tools/__init__.py b/tests_pytest/fw_tests_common_base/__init__.py similarity index 100% rename from tests_pytest/common/core/common/mixed_precision/resource_utilization_tools/__init__.py rename to tests_pytest/fw_tests_common_base/__init__.py diff --git a/tests_pytest/base_test_classes/base_tpc_attach2fw_test.py b/tests_pytest/fw_tests_common_base/base_tpc_attach2fw_test.py similarity index 100% rename from tests_pytest/base_test_classes/base_tpc_attach2fw_test.py rename to tests_pytest/fw_tests_common_base/base_tpc_attach2fw_test.py diff --git a/tests_pytest/keras/__init__.py b/tests_pytest/keras_tests/__init__.py similarity index 100% rename from tests_pytest/keras/__init__.py rename to tests_pytest/keras_tests/__init__.py diff --git a/tests_pytest/keras/core/__init__.py b/tests_pytest/keras_tests/core/__init__.py similarity index 100% rename from tests_pytest/keras/core/__init__.py rename to tests_pytest/keras_tests/core/__init__.py diff --git a/tests_pytest/keras/core/test_data_util.py b/tests_pytest/keras_tests/core/test_data_util.py similarity index 100% rename from tests_pytest/keras/core/test_data_util.py rename to tests_pytest/keras_tests/core/test_data_util.py diff --git a/tests_pytest/keras/core/test_fw_implementation.py b/tests_pytest/keras_tests/core/test_fw_implementation.py similarity index 100% rename from tests_pytest/keras/core/test_fw_implementation.py rename to tests_pytest/keras_tests/core/test_fw_implementation.py diff --git a/tests_pytest/keras/gptq/__init__.py b/tests_pytest/keras_tests/gptq/__init__.py similarity index 100% rename from tests_pytest/keras/gptq/__init__.py rename to tests_pytest/keras_tests/gptq/__init__.py diff --git a/tests_pytest/keras/gptq/test_gradual_act_quantization.py b/tests_pytest/keras_tests/gptq/test_gradual_act_quantization.py similarity index 100% rename from tests_pytest/keras/gptq/test_gradual_act_quantization.py rename to tests_pytest/keras_tests/gptq/test_gradual_act_quantization.py diff --git a/tests_pytest/keras/target_platform_capabilities/__init__.py b/tests_pytest/keras_tests/target_platform_capabilities/__init__.py similarity index 100% rename from tests_pytest/keras/target_platform_capabilities/__init__.py rename to tests_pytest/keras_tests/target_platform_capabilities/__init__.py diff --git a/tests_pytest/keras/target_platform_capabilities/targetplatform2framework/__init__.py b/tests_pytest/keras_tests/target_platform_capabilities/targetplatform2framework/__init__.py similarity index 100% rename from tests_pytest/keras/target_platform_capabilities/targetplatform2framework/__init__.py rename to tests_pytest/keras_tests/target_platform_capabilities/targetplatform2framework/__init__.py diff --git a/tests_pytest/keras/target_platform_capabilities/targetplatform2framework/test_attach2keras.py b/tests_pytest/keras_tests/target_platform_capabilities/targetplatform2framework/test_attach2keras.py similarity index 95% rename from tests_pytest/keras/target_platform_capabilities/targetplatform2framework/test_attach2keras.py rename to tests_pytest/keras_tests/target_platform_capabilities/targetplatform2framework/test_attach2keras.py index 934453da4..7a988a985 100644 --- a/tests_pytest/keras/target_platform_capabilities/targetplatform2framework/test_attach2keras.py +++ b/tests_pytest/keras_tests/target_platform_capabilities/targetplatform2framework/test_attach2keras.py @@ -16,7 +16,7 @@ from packaging import version import tensorflow as tf -from tests_pytest.base_test_classes.base_tpc_attach2fw_test import BaseTpcAttach2FrameworkTest +from tests_pytest.fw_tests_common_base.base_tpc_attach2fw_test import BaseTpcAttach2FrameworkTest if version.parse(tf.__version__) >= version.parse("2.13"): from keras.src.layers import Conv2D, Identity diff --git a/tests_pytest/keras/trainable_infrastructure/__init__.py b/tests_pytest/keras_tests/trainable_infrastructure/__init__.py similarity index 100% rename from tests_pytest/keras/trainable_infrastructure/__init__.py rename to tests_pytest/keras_tests/trainable_infrastructure/__init__.py diff --git a/tests_pytest/keras/trainable_infrastructure/test_linear_annealing.py b/tests_pytest/keras_tests/trainable_infrastructure/test_linear_annealing.py similarity index 100% rename from tests_pytest/keras/trainable_infrastructure/test_linear_annealing.py rename to tests_pytest/keras_tests/trainable_infrastructure/test_linear_annealing.py diff --git a/tests_pytest/pytorch/__init__.py b/tests_pytest/pytorch_tests/__init__.py similarity index 100% rename from tests_pytest/pytorch/__init__.py rename to tests_pytest/pytorch_tests/__init__.py diff --git a/tests_pytest/pytorch/core/__init__.py b/tests_pytest/pytorch_tests/core/__init__.py similarity index 100% rename from tests_pytest/pytorch/core/__init__.py rename to tests_pytest/pytorch_tests/core/__init__.py diff --git a/tests_pytest/pytorch/core/test_data_util.py b/tests_pytest/pytorch_tests/core/test_data_util.py similarity index 100% rename from tests_pytest/pytorch/core/test_data_util.py rename to tests_pytest/pytorch_tests/core/test_data_util.py diff --git a/tests_pytest/pytorch/core/test_fw_implementation.py b/tests_pytest/pytorch_tests/core/test_fw_implementation.py similarity index 100% rename from tests_pytest/pytorch/core/test_fw_implementation.py rename to tests_pytest/pytorch_tests/core/test_fw_implementation.py diff --git a/tests_pytest/pytorch/gptq/__init__.py b/tests_pytest/pytorch_tests/gptq/__init__.py similarity index 100% rename from tests_pytest/pytorch/gptq/__init__.py rename to tests_pytest/pytorch_tests/gptq/__init__.py diff --git a/tests_pytest/pytorch/gptq/test_annealing_cfg.py b/tests_pytest/pytorch_tests/gptq/test_annealing_cfg.py similarity index 100% rename from tests_pytest/pytorch/gptq/test_annealing_cfg.py rename to tests_pytest/pytorch_tests/gptq/test_annealing_cfg.py diff --git a/tests_pytest/pytorch/gptq/test_gradual_act_quantization.py b/tests_pytest/pytorch_tests/gptq/test_gradual_act_quantization.py similarity index 100% rename from tests_pytest/pytorch/gptq/test_gradual_act_quantization.py rename to tests_pytest/pytorch_tests/gptq/test_gradual_act_quantization.py diff --git a/tests_pytest/pytorch/target_platform_capabilities/__init__.py b/tests_pytest/pytorch_tests/target_platform_capabilities/__init__.py similarity index 100% rename from tests_pytest/pytorch/target_platform_capabilities/__init__.py rename to tests_pytest/pytorch_tests/target_platform_capabilities/__init__.py diff --git a/tests_pytest/pytorch/target_platform_capabilities/targetplatform2framework/__init__.py b/tests_pytest/pytorch_tests/target_platform_capabilities/targetplatform2framework/__init__.py similarity index 100% rename from tests_pytest/pytorch/target_platform_capabilities/targetplatform2framework/__init__.py rename to tests_pytest/pytorch_tests/target_platform_capabilities/targetplatform2framework/__init__.py diff --git a/tests_pytest/pytorch/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py b/tests_pytest/pytorch_tests/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py similarity index 95% rename from tests_pytest/pytorch/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py rename to tests_pytest/pytorch_tests/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py index 12bce2956..4a8d86379 100644 --- a/tests_pytest/pytorch/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py +++ b/tests_pytest/pytorch_tests/target_platform_capabilities/targetplatform2framework/test_attach2pytorch.py @@ -18,7 +18,7 @@ from model_compression_toolkit.target_platform_capabilities import LayerFilterParams from model_compression_toolkit.target_platform_capabilities.targetplatform2framework.attach2pytorch import \ AttachTpcToPytorch -from tests_pytest.base_test_classes.base_tpc_attach2fw_test import BaseTpcAttach2FrameworkTest +from tests_pytest.fw_tests_common_base.base_tpc_attach2fw_test import BaseTpcAttach2FrameworkTest class TestAttachTpc2Pytorch(BaseTpcAttach2FrameworkTest): diff --git a/tests_pytest/pytorch/trainable_infrastructure/__init__.py b/tests_pytest/pytorch_tests/trainable_infrastructure/__init__.py similarity index 100% rename from tests_pytest/pytorch/trainable_infrastructure/__init__.py rename to tests_pytest/pytorch_tests/trainable_infrastructure/__init__.py diff --git a/tests_pytest/pytorch/trainable_infrastructure/test_linear_annealing.py b/tests_pytest/pytorch_tests/trainable_infrastructure/test_linear_annealing.py similarity index 100% rename from tests_pytest/pytorch/trainable_infrastructure/test_linear_annealing.py rename to tests_pytest/pytorch_tests/trainable_infrastructure/test_linear_annealing.py diff --git a/tests_pytest/test_util/__init__.py b/tests_pytest/test_util/__init__.py new file mode 100644 index 000000000..5397dea24 --- /dev/null +++ b/tests_pytest/test_util/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2025 Sony Semiconductor Israel, Inc. All rights reserved. +# +# 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/tests_pytest/common/graph_builder_utils.py b/tests_pytest/test_util/graph_builder_utils.py similarity index 100% rename from tests_pytest/common/graph_builder_utils.py rename to tests_pytest/test_util/graph_builder_utils.py