From d8998a69e2e83b7050628bac6549798c369f7f35 Mon Sep 17 00:00:00 2001 From: reuvenp Date: Wed, 21 Aug 2024 14:35:22 +0300 Subject: [PATCH 1/5] Reorder all unittests under two packages of keras and pytorch packages --- .github/workflows/run_keras_tests.yml | 5 ++--- .github/workflows/run_pytorch_tests.yml | 1 - .../keras_tests => external_tests}/__init__.py | 8 ++++---- .../keras_tests}/__init__.py | 0 .../keras_tests/models_tests/__init__.py | 0 .../models_tests/test_networks_runner.py | 0 .../models_tests/test_networks_runner_float.py | 0 .../pytorch_tests/__init__.py | 8 ++++---- .../data_generation_tests/__init__.py | 0 .../base_keras_data_generation_test.py | 0 .../test_keras_data_generation_runner.py | 2 +- .../data_generation_tests}/test_scheduler_step.py | 0 .../trainable_infrastructure_tests}/__init__.py | 0 .../base_keras_trainable_infra_test.py | 0 .../test_keras_trainable_infra_runner.py | 4 ++-- .../trainable_keras}/__init__.py | 0 .../trainable_keras/test_get_quantizers.py | 2 +- .../trainable_keras/test_keras_base_quantizer.py | 2 +- tests/keras_tests/xquant_tests/__init__.py | 15 +++++++++++++++ .../xquant_tests}/test_model_analyzer.py | 2 +- .../xquant_tests}/test_similarity_functions.py | 0 .../xquant_tests}/test_xquant_end2end.py | 0 .../data_generation_tests}/__init__.py | 0 .../base_pytorch_data_generation_test.py | 0 .../test_pytorch_data_generation_runner.py | 2 +- .../trainable_infrastructure_tests}/__init__.py | 0 .../base_pytorch_trainable_infra_test.py | 0 .../test_pytorch_trainable_infra_runner.py | 4 ++-- .../trainable_pytorch}/__init__.py | 0 .../test_pytorch_base_quantizer.py | 2 +- .../test_pytorch_get_quantizers.py | 0 tests/pytorch_tests/xquant_tests/__init__.py | 15 +++++++++++++++ .../xquant_tests}/test_model_analyzer.py | 2 +- .../xquant_tests}/test_similarity_functions.py | 0 .../xquant_tests}/test_xquant_end2end.py | 0 tests/test_suite.py | 14 +++++++------- .../pytorch/__init__.py | 14 -------------- .../pytorch/trainable_pytorch/__init__.py | 14 -------------- 38 files changed, 58 insertions(+), 58 deletions(-) rename tests/{xquant_tests/keras_tests => external_tests}/__init__.py (97%) rename tests/{xquant_tests => external_tests/keras_tests}/__init__.py (100%) rename tests/{ => external_tests}/keras_tests/models_tests/__init__.py (100%) rename tests/{ => external_tests}/keras_tests/models_tests/test_networks_runner.py (100%) rename tests/{ => external_tests}/keras_tests/models_tests/test_networks_runner_float.py (100%) rename tests/{xquant_tests => external_tests}/pytorch_tests/__init__.py (97%) rename tests/{ => keras_tests}/data_generation_tests/__init__.py (100%) rename tests/{data_generation_tests/keras => keras_tests/data_generation_tests}/base_keras_data_generation_test.py (100%) rename tests/{data_generation_tests/keras => keras_tests/data_generation_tests}/test_keras_data_generation_runner.py (97%) rename tests/{data_generation_tests/keras => keras_tests/data_generation_tests}/test_scheduler_step.py (100%) rename tests/{data_generation_tests/keras => keras_tests/trainable_infrastructure_tests}/__init__.py (100%) rename tests/{trainable_infrastructure_tests/keras => keras_tests/trainable_infrastructure_tests}/base_keras_trainable_infra_test.py (100%) rename tests/{trainable_infrastructure_tests/keras => keras_tests/trainable_infrastructure_tests}/test_keras_trainable_infra_runner.py (96%) rename tests/{data_generation_tests/pytorch => keras_tests/trainable_infrastructure_tests/trainable_keras}/__init__.py (100%) rename tests/{trainable_infrastructure_tests/keras => keras_tests/trainable_infrastructure_tests}/trainable_keras/test_get_quantizers.py (96%) rename tests/{trainable_infrastructure_tests/keras => keras_tests/trainable_infrastructure_tests}/trainable_keras/test_keras_base_quantizer.py (98%) create mode 100644 tests/keras_tests/xquant_tests/__init__.py rename tests/{xquant_tests/keras_tests => keras_tests/xquant_tests}/test_model_analyzer.py (98%) rename tests/{xquant_tests/keras_tests => keras_tests/xquant_tests}/test_similarity_functions.py (100%) rename tests/{xquant_tests/keras_tests => keras_tests/xquant_tests}/test_xquant_end2end.py (100%) rename tests/{trainable_infrastructure_tests => pytorch_tests/data_generation_tests}/__init__.py (100%) rename tests/{data_generation_tests/pytorch => pytorch_tests/data_generation_tests}/base_pytorch_data_generation_test.py (100%) rename tests/{data_generation_tests/pytorch => pytorch_tests/data_generation_tests}/test_pytorch_data_generation_runner.py (97%) rename tests/{trainable_infrastructure_tests/keras => pytorch_tests/trainable_infrastructure_tests}/__init__.py (100%) rename tests/{trainable_infrastructure_tests/pytorch => pytorch_tests/trainable_infrastructure_tests}/base_pytorch_trainable_infra_test.py (100%) rename tests/{trainable_infrastructure_tests/pytorch => pytorch_tests/trainable_infrastructure_tests}/test_pytorch_trainable_infra_runner.py (96%) rename tests/{trainable_infrastructure_tests/keras/trainable_keras => pytorch_tests/trainable_infrastructure_tests/trainable_pytorch}/__init__.py (100%) rename tests/{trainable_infrastructure_tests/pytorch => pytorch_tests/trainable_infrastructure_tests}/trainable_pytorch/test_pytorch_base_quantizer.py (98%) rename tests/{trainable_infrastructure_tests/pytorch => pytorch_tests/trainable_infrastructure_tests}/trainable_pytorch/test_pytorch_get_quantizers.py (100%) create mode 100644 tests/pytorch_tests/xquant_tests/__init__.py rename tests/{xquant_tests/pytorch_tests => pytorch_tests/xquant_tests}/test_model_analyzer.py (98%) rename tests/{xquant_tests/pytorch_tests => pytorch_tests/xquant_tests}/test_similarity_functions.py (100%) rename tests/{xquant_tests/pytorch_tests => pytorch_tests/xquant_tests}/test_xquant_end2end.py (100%) delete mode 100644 tests/trainable_infrastructure_tests/pytorch/__init__.py delete mode 100644 tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/__init__.py diff --git a/.github/workflows/run_keras_tests.yml b/.github/workflows/run_keras_tests.yml index ec2309be4..7e0f63e74 100644 --- a/.github/workflows/run_keras_tests.yml +++ b/.github/workflows/run_keras_tests.yml @@ -29,7 +29,6 @@ jobs: # CPU environment (https://github.com/tensorflow/tensorflow/issues/41718). # For this reason, if we run them in such an environment, we need to run them first non-parallel separately. run: | - python -m unittest discover tests/keras_tests/pruning_tests -v - python -m unittest discover tests/keras_tests/non_parallel_tests -v - for script in tests/xquant_tests/keras_tests tests/keras_tests/exporter_tests tests/keras_tests/feature_networks_tests tests/keras_tests/graph_tests tests/keras_tests/layer_tests; do python -m unittest discover $script -v & pids+=($!); done; for pid in ${pids[@]}; do wait $pid || exit 1; done + python -m unittest discover tests/keras_tests -v + diff --git a/.github/workflows/run_pytorch_tests.yml b/.github/workflows/run_pytorch_tests.yml index 8a047cfa8..fa6a7d698 100644 --- a/.github/workflows/run_pytorch_tests.yml +++ b/.github/workflows/run_pytorch_tests.yml @@ -26,7 +26,6 @@ jobs: pip install torch==${{ inputs.torch-version }} torchvision onnx onnxruntime - name: Run unittests run: | - python -m unittest discover tests/xquant_tests/pytorch_tests -v python -m unittest discover tests/pytorch_tests -v diff --git a/tests/xquant_tests/keras_tests/__init__.py b/tests/external_tests/__init__.py similarity index 97% rename from tests/xquant_tests/keras_tests/__init__.py rename to tests/external_tests/__init__.py index 652e98d92..bd190025f 100644 --- a/tests/xquant_tests/keras_tests/__init__.py +++ b/tests/external_tests/__init__.py @@ -1,15 +1,15 @@ # Copyright 2024 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/xquant_tests/__init__.py b/tests/external_tests/keras_tests/__init__.py similarity index 100% rename from tests/xquant_tests/__init__.py rename to tests/external_tests/keras_tests/__init__.py diff --git a/tests/keras_tests/models_tests/__init__.py b/tests/external_tests/keras_tests/models_tests/__init__.py similarity index 100% rename from tests/keras_tests/models_tests/__init__.py rename to tests/external_tests/keras_tests/models_tests/__init__.py diff --git a/tests/keras_tests/models_tests/test_networks_runner.py b/tests/external_tests/keras_tests/models_tests/test_networks_runner.py similarity index 100% rename from tests/keras_tests/models_tests/test_networks_runner.py rename to tests/external_tests/keras_tests/models_tests/test_networks_runner.py diff --git a/tests/keras_tests/models_tests/test_networks_runner_float.py b/tests/external_tests/keras_tests/models_tests/test_networks_runner_float.py similarity index 100% rename from tests/keras_tests/models_tests/test_networks_runner_float.py rename to tests/external_tests/keras_tests/models_tests/test_networks_runner_float.py diff --git a/tests/xquant_tests/pytorch_tests/__init__.py b/tests/external_tests/pytorch_tests/__init__.py similarity index 97% rename from tests/xquant_tests/pytorch_tests/__init__.py rename to tests/external_tests/pytorch_tests/__init__.py index 652e98d92..bd190025f 100644 --- a/tests/xquant_tests/pytorch_tests/__init__.py +++ b/tests/external_tests/pytorch_tests/__init__.py @@ -1,15 +1,15 @@ # Copyright 2024 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/data_generation_tests/__init__.py b/tests/keras_tests/data_generation_tests/__init__.py similarity index 100% rename from tests/data_generation_tests/__init__.py rename to tests/keras_tests/data_generation_tests/__init__.py diff --git a/tests/data_generation_tests/keras/base_keras_data_generation_test.py b/tests/keras_tests/data_generation_tests/base_keras_data_generation_test.py similarity index 100% rename from tests/data_generation_tests/keras/base_keras_data_generation_test.py rename to tests/keras_tests/data_generation_tests/base_keras_data_generation_test.py diff --git a/tests/data_generation_tests/keras/test_keras_data_generation_runner.py b/tests/keras_tests/data_generation_tests/test_keras_data_generation_runner.py similarity index 97% rename from tests/data_generation_tests/keras/test_keras_data_generation_runner.py rename to tests/keras_tests/data_generation_tests/test_keras_data_generation_runner.py index c3e9fc80f..bd88d71d4 100644 --- a/tests/data_generation_tests/keras/test_keras_data_generation_runner.py +++ b/tests/keras_tests/data_generation_tests/test_keras_data_generation_runner.py @@ -16,7 +16,7 @@ from model_compression_toolkit.data_generation.common.enums import SchedulerType, BatchNormAlignemntLossType, \ DataInitType, BNLayerWeightingType, ImageGranularity, ImagePipelineType, ImageNormalizationType, OutputLossType -from tests.data_generation_tests.keras.base_keras_data_generation_test import BaseKerasDataGenerationTest, \ +from tests.keras_tests.data_generation_tests.base_keras_data_generation_test import BaseKerasDataGenerationTest, \ NoBNDataGenerationModel diff --git a/tests/data_generation_tests/keras/test_scheduler_step.py b/tests/keras_tests/data_generation_tests/test_scheduler_step.py similarity index 100% rename from tests/data_generation_tests/keras/test_scheduler_step.py rename to tests/keras_tests/data_generation_tests/test_scheduler_step.py diff --git a/tests/data_generation_tests/keras/__init__.py b/tests/keras_tests/trainable_infrastructure_tests/__init__.py similarity index 100% rename from tests/data_generation_tests/keras/__init__.py rename to tests/keras_tests/trainable_infrastructure_tests/__init__.py diff --git a/tests/trainable_infrastructure_tests/keras/base_keras_trainable_infra_test.py b/tests/keras_tests/trainable_infrastructure_tests/base_keras_trainable_infra_test.py similarity index 100% rename from tests/trainable_infrastructure_tests/keras/base_keras_trainable_infra_test.py rename to tests/keras_tests/trainable_infrastructure_tests/base_keras_trainable_infra_test.py diff --git a/tests/trainable_infrastructure_tests/keras/test_keras_trainable_infra_runner.py b/tests/keras_tests/trainable_infrastructure_tests/test_keras_trainable_infra_runner.py similarity index 96% rename from tests/trainable_infrastructure_tests/keras/test_keras_trainable_infra_runner.py rename to tests/keras_tests/trainable_infrastructure_tests/test_keras_trainable_infra_runner.py index e7a9a6141..263daf561 100644 --- a/tests/trainable_infrastructure_tests/keras/test_keras_trainable_infra_runner.py +++ b/tests/keras_tests/trainable_infrastructure_tests/test_keras_trainable_infra_runner.py @@ -25,9 +25,9 @@ from model_compression_toolkit.qat.keras.quantizer.lsq.uniform_lsq import LSQUniformActivationQATQuantizer, LSQUniformWeightQATQuantizer from model_compression_toolkit.qat.keras.quantizer.lsq.symmetric_lsq import LSQActivationQATQuantizer, LSQWeightQATQuantizer from model_compression_toolkit.trainable_infrastructure import BaseKerasTrainableQuantizer -from tests.trainable_infrastructure_tests.keras.trainable_keras.test_get_quantizers import \ +from tests.keras_tests.trainable_infrastructure_tests.trainable_keras.test_get_quantizers import \ TestGetTrainableQuantizer -from tests.trainable_infrastructure_tests.keras.trainable_keras.test_keras_base_quantizer import TestKerasBaseWeightsQuantizer, \ +from tests.keras_tests.trainable_infrastructure_tests.trainable_keras.test_keras_base_quantizer import TestKerasBaseWeightsQuantizer, \ TestKerasBaseActivationsQuantizer, TestKerasQuantizerWithoutMarkDecorator layers = tf.keras.layers diff --git a/tests/data_generation_tests/pytorch/__init__.py b/tests/keras_tests/trainable_infrastructure_tests/trainable_keras/__init__.py similarity index 100% rename from tests/data_generation_tests/pytorch/__init__.py rename to tests/keras_tests/trainable_infrastructure_tests/trainable_keras/__init__.py diff --git a/tests/trainable_infrastructure_tests/keras/trainable_keras/test_get_quantizers.py b/tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_get_quantizers.py similarity index 96% rename from tests/trainable_infrastructure_tests/keras/trainable_keras/test_get_quantizers.py rename to tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_get_quantizers.py index 67bf08bed..d791e949d 100644 --- a/tests/trainable_infrastructure_tests/keras/trainable_keras/test_get_quantizers.py +++ b/tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_get_quantizers.py @@ -15,7 +15,7 @@ from model_compression_toolkit.trainable_infrastructure.common.get_quantizers import \ get_trainable_quantizer_class -from tests.trainable_infrastructure_tests.keras.base_keras_trainable_infra_test import \ +from tests.keras_tests.trainable_infrastructure_tests.base_keras_trainable_infra_test import \ BaseKerasTrainableInfrastructureTest diff --git a/tests/trainable_infrastructure_tests/keras/trainable_keras/test_keras_base_quantizer.py b/tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_keras_base_quantizer.py similarity index 98% rename from tests/trainable_infrastructure_tests/keras/trainable_keras/test_keras_base_quantizer.py rename to tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_keras_base_quantizer.py index 090deed7e..13c04e39e 100644 --- a/tests/trainable_infrastructure_tests/keras/trainable_keras/test_keras_base_quantizer.py +++ b/tests/keras_tests/trainable_infrastructure_tests/trainable_keras/test_keras_base_quantizer.py @@ -19,7 +19,7 @@ TrainableQuantizerWeightsConfig, TrainableQuantizerActivationConfig from model_compression_toolkit.trainable_infrastructure.keras.config_serialization import config_serialization, \ config_deserialization -from tests.trainable_infrastructure_tests.keras.base_keras_trainable_infra_test import \ +from tests.keras_tests.trainable_infrastructure_tests.base_keras_trainable_infra_test import \ BaseKerasTrainableInfrastructureTest, ZeroWeightsQuantizer, ZeroActivationsQuantizer diff --git a/tests/keras_tests/xquant_tests/__init__.py b/tests/keras_tests/xquant_tests/__init__.py new file mode 100644 index 000000000..bd190025f --- /dev/null +++ b/tests/keras_tests/xquant_tests/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2024 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/xquant_tests/keras_tests/test_model_analyzer.py b/tests/keras_tests/xquant_tests/test_model_analyzer.py similarity index 98% rename from tests/xquant_tests/keras_tests/test_model_analyzer.py rename to tests/keras_tests/xquant_tests/test_model_analyzer.py index 7191a2abb..3210f355c 100644 --- a/tests/xquant_tests/keras_tests/test_model_analyzer.py +++ b/tests/keras_tests/xquant_tests/test_model_analyzer.py @@ -20,7 +20,7 @@ from model_compression_toolkit.xquant.keras.model_analyzer import KerasModelAnalyzer import model_compression_toolkit as mct -from tests.xquant_tests.keras_tests.test_xquant_end2end import random_data_gen +from tests.keras_tests.xquant_tests.test_xquant_end2end import random_data_gen class TestKerasModelAnalyzer(unittest.TestCase): diff --git a/tests/xquant_tests/keras_tests/test_similarity_functions.py b/tests/keras_tests/xquant_tests/test_similarity_functions.py similarity index 100% rename from tests/xquant_tests/keras_tests/test_similarity_functions.py rename to tests/keras_tests/xquant_tests/test_similarity_functions.py diff --git a/tests/xquant_tests/keras_tests/test_xquant_end2end.py b/tests/keras_tests/xquant_tests/test_xquant_end2end.py similarity index 100% rename from tests/xquant_tests/keras_tests/test_xquant_end2end.py rename to tests/keras_tests/xquant_tests/test_xquant_end2end.py diff --git a/tests/trainable_infrastructure_tests/__init__.py b/tests/pytorch_tests/data_generation_tests/__init__.py similarity index 100% rename from tests/trainable_infrastructure_tests/__init__.py rename to tests/pytorch_tests/data_generation_tests/__init__.py diff --git a/tests/data_generation_tests/pytorch/base_pytorch_data_generation_test.py b/tests/pytorch_tests/data_generation_tests/base_pytorch_data_generation_test.py similarity index 100% rename from tests/data_generation_tests/pytorch/base_pytorch_data_generation_test.py rename to tests/pytorch_tests/data_generation_tests/base_pytorch_data_generation_test.py diff --git a/tests/data_generation_tests/pytorch/test_pytorch_data_generation_runner.py b/tests/pytorch_tests/data_generation_tests/test_pytorch_data_generation_runner.py similarity index 97% rename from tests/data_generation_tests/pytorch/test_pytorch_data_generation_runner.py rename to tests/pytorch_tests/data_generation_tests/test_pytorch_data_generation_runner.py index d4dcccb6e..53adee5d8 100644 --- a/tests/data_generation_tests/pytorch/test_pytorch_data_generation_runner.py +++ b/tests/pytorch_tests/data_generation_tests/test_pytorch_data_generation_runner.py @@ -20,7 +20,7 @@ DataInitType, BNLayerWeightingType, ImageGranularity, ImagePipelineType, ImageNormalizationType, OutputLossType from model_compression_toolkit.data_generation.pytorch.optimization_functions.lr_scheduler import \ ReduceLROnPlateauWithReset -from tests.data_generation_tests.pytorch.base_pytorch_data_generation_test import BasePytorchDataGenerationTest +from tests.pytorch_tests.data_generation_tests.base_pytorch_data_generation_test import BasePytorchDataGenerationTest class PytorchDataGenerationTestRunner(unittest.TestCase): diff --git a/tests/trainable_infrastructure_tests/keras/__init__.py b/tests/pytorch_tests/trainable_infrastructure_tests/__init__.py similarity index 100% rename from tests/trainable_infrastructure_tests/keras/__init__.py rename to tests/pytorch_tests/trainable_infrastructure_tests/__init__.py diff --git a/tests/trainable_infrastructure_tests/pytorch/base_pytorch_trainable_infra_test.py b/tests/pytorch_tests/trainable_infrastructure_tests/base_pytorch_trainable_infra_test.py similarity index 100% rename from tests/trainable_infrastructure_tests/pytorch/base_pytorch_trainable_infra_test.py rename to tests/pytorch_tests/trainable_infrastructure_tests/base_pytorch_trainable_infra_test.py diff --git a/tests/trainable_infrastructure_tests/pytorch/test_pytorch_trainable_infra_runner.py b/tests/pytorch_tests/trainable_infrastructure_tests/test_pytorch_trainable_infra_runner.py similarity index 96% rename from tests/trainable_infrastructure_tests/pytorch/test_pytorch_trainable_infra_runner.py rename to tests/pytorch_tests/trainable_infrastructure_tests/test_pytorch_trainable_infra_runner.py index 87dc33472..f154e4334 100644 --- a/tests/trainable_infrastructure_tests/pytorch/test_pytorch_trainable_infra_runner.py +++ b/tests/pytorch_tests/trainable_infrastructure_tests/test_pytorch_trainable_infra_runner.py @@ -29,9 +29,9 @@ LSQUniformActivationQATQuantizer from model_compression_toolkit.trainable_infrastructure.pytorch.base_pytorch_quantizer import \ BasePytorchTrainableQuantizer -from tests.trainable_infrastructure_tests.pytorch.trainable_pytorch.test_pytorch_base_quantizer import \ +from tests.pytorch_tests.trainable_infrastructure_tests.trainable_pytorch.test_pytorch_base_quantizer import \ TestPytorchBaseWeightsQuantizer, TestPytorchBaseActivationQuantizer, TestPytorchQuantizerWithoutMarkDecorator -from tests.trainable_infrastructure_tests.pytorch.trainable_pytorch.test_pytorch_get_quantizers import \ +from tests.pytorch_tests.trainable_infrastructure_tests.trainable_pytorch.test_pytorch_get_quantizers import \ TestGetTrainableQuantizer diff --git a/tests/trainable_infrastructure_tests/keras/trainable_keras/__init__.py b/tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/__init__.py similarity index 100% rename from tests/trainable_infrastructure_tests/keras/trainable_keras/__init__.py rename to tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/__init__.py diff --git a/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/test_pytorch_base_quantizer.py b/tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/test_pytorch_base_quantizer.py similarity index 98% rename from tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/test_pytorch_base_quantizer.py rename to tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/test_pytorch_base_quantizer.py index 4bbd05292..48e577bf3 100644 --- a/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/test_pytorch_base_quantizer.py +++ b/tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/test_pytorch_base_quantizer.py @@ -16,7 +16,7 @@ TrainableQuantizerWeightsConfig, TrainableQuantizerActivationConfig from model_compression_toolkit.trainable_infrastructure.pytorch.base_pytorch_quantizer import \ BasePytorchTrainableQuantizer -from tests.trainable_infrastructure_tests.pytorch.base_pytorch_trainable_infra_test import \ +from tests.pytorch_tests.trainable_infrastructure_tests.base_pytorch_trainable_infra_test import \ BasePytorchInfrastructureTest, ZeroWeightsQuantizer, ZeroActivationsQuantizer from model_compression_toolkit.target_platform_capabilities.target_platform import QuantizationMethod diff --git a/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/test_pytorch_get_quantizers.py b/tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/test_pytorch_get_quantizers.py similarity index 100% rename from tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/test_pytorch_get_quantizers.py rename to tests/pytorch_tests/trainable_infrastructure_tests/trainable_pytorch/test_pytorch_get_quantizers.py diff --git a/tests/pytorch_tests/xquant_tests/__init__.py b/tests/pytorch_tests/xquant_tests/__init__.py new file mode 100644 index 000000000..bd190025f --- /dev/null +++ b/tests/pytorch_tests/xquant_tests/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2024 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/xquant_tests/pytorch_tests/test_model_analyzer.py b/tests/pytorch_tests/xquant_tests/test_model_analyzer.py similarity index 98% rename from tests/xquant_tests/pytorch_tests/test_model_analyzer.py rename to tests/pytorch_tests/xquant_tests/test_model_analyzer.py index 3df2a0b5b..18b68f1e3 100644 --- a/tests/xquant_tests/pytorch_tests/test_model_analyzer.py +++ b/tests/pytorch_tests/xquant_tests/test_model_analyzer.py @@ -18,7 +18,7 @@ from model_compression_toolkit.core.pytorch.utils import get_working_device, to_torch_tensor from model_compression_toolkit.xquant.pytorch.model_analyzer import PytorchModelAnalyzer -from tests.xquant_tests.pytorch_tests.test_xquant_end2end import random_data_gen +from tests.pytorch_tests.xquant_tests.test_xquant_end2end import random_data_gen import model_compression_toolkit as mct from torch import nn class TestPytorchModelAnalyzer(unittest.TestCase): diff --git a/tests/xquant_tests/pytorch_tests/test_similarity_functions.py b/tests/pytorch_tests/xquant_tests/test_similarity_functions.py similarity index 100% rename from tests/xquant_tests/pytorch_tests/test_similarity_functions.py rename to tests/pytorch_tests/xquant_tests/test_similarity_functions.py diff --git a/tests/xquant_tests/pytorch_tests/test_xquant_end2end.py b/tests/pytorch_tests/xquant_tests/test_xquant_end2end.py similarity index 100% rename from tests/xquant_tests/pytorch_tests/test_xquant_end2end.py rename to tests/pytorch_tests/xquant_tests/test_xquant_end2end.py diff --git a/tests/test_suite.py b/tests/test_suite.py index 2a3e574d1..1499018f8 100644 --- a/tests/test_suite.py +++ b/tests/test_suite.py @@ -40,7 +40,7 @@ "torchvision") is not None if found_tf: - from tests.xquant_tests.keras_tests.test_xquant_end2end import BaseTestEnd2EndKerasXQuant + from tests.keras_tests.keras_tests import BaseTestEnd2EndKerasXQuant from tests.keras_tests.function_tests.test_activation_quantization_functions import TestActivationQuantizationFunctions as TestActivationQuantizationFunctionsKeras from tests.keras_tests.function_tests.test_custom_layer import TestCustomLayer from tests.keras_tests.function_tests.test_hessian_info_calculator import TestHessianInfoCalculatorWeights, \ @@ -76,22 +76,22 @@ from tests.keras_tests.exporter_tests.test_runner import ExporterTestsRunner from tests.keras_tests.function_tests.test_get_gptq_config import TestGetGPTQConfig from tests.keras_tests.function_tests.test_gptq_loss_functions import TestGPTQLossFunctions - from tests.trainable_infrastructure_tests.keras.test_keras_trainable_infra_runner import \ + from tests.keras_tests.trainable_infrastructure_tests.test_keras_trainable_infra_runner import \ KerasTrainableInfrastructureTestRunner from tests.keras_tests.function_tests.test_gptq_soft_quantizer import TestGPTQSoftQuantizer as keras_gptq_soft_quantizer_test from tests.keras_tests.function_tests.test_activation_quantization_holder_gptq import TestGPTQModelBuilderWithActivationHolder - from tests.data_generation_tests.keras.test_keras_data_generation_runner import KerasDataGenerationTestRunner + from tests.keras_tests.data_generation_tests import KerasDataGenerationTestRunner from tests.keras_tests.pruning_tests.test_memory_calculator import TestParameterCounter from tests.keras_tests.pruning_tests.test_pretrained_models import PruningPretrainedModelsTest from tests.keras_tests.pruning_tests.feature_networks.test_pruning_feature_networks import PruningFeatureNetworksTest from tests.keras_tests.function_tests.test_hmse_error_method import TestParamSelectionWithHMSE - from tests.data_generation_tests.keras.test_scheduler_step import TestReduceLROnPlateau + from tests.keras_tests.data_generation_tests import TestReduceLROnPlateau from tests.keras_tests.function_tests.test_node_quantization_configurations import \ TestNodeQuantizationConfigurations from tests.keras_tests.function_tests.test_quant_config_filtering import TestKerasQuantConfigFiltering if found_pytorch: - from tests.xquant_tests.pytorch_tests.test_xquant_end2end import BaseTestEnd2EndPytorchXQuant + from tests.pytorch_tests.xquant_tests.test_xquant_end2end import BaseTestEnd2EndPytorchXQuant from tests.pytorch_tests.function_tests.test_activation_quantization_functions import TestActivationQuantizationFunctions as TestActivationQuantizationFunctionsPytorch from tests.pytorch_tests.function_tests.test_torch_utils import TestTorchUtils from tests.pytorch_tests.function_tests.test_device_manager import TestDeviceManager @@ -100,13 +100,13 @@ # from tests.pytorch_tests.model_tests.test_models_runner import ModelTest from tests.pytorch_tests.function_tests.test_function_runner import FunctionTestRunner from tests.pytorch_tests.function_tests.test_pytorch_tp_model import TestPytorchTPModel - from tests.trainable_infrastructure_tests.pytorch.test_pytorch_trainable_infra_runner import \ + from tests.pytorch_tests.trainable_infrastructure_tests import \ PytorchTrainableInfrastructureTestRunner from tests.pytorch_tests.function_tests.test_gptq_soft_quantizer import TestGPTQSoftQuantizer as pytorch_gptq_soft_quantier_test from tests.pytorch_tests.function_tests.test_activation_quantization_holder_gptq import \ TestGPTQModelBuilderWithActivationHolder as TestGPTQModelBuilderWithActivationHolderPytorch from tests.pytorch_tests.exporter_tests.test_runner import PytorchExporterTestsRunner - from tests.data_generation_tests.pytorch.test_pytorch_data_generation_runner import PytorchDataGenerationTestRunner + from tests.pytorch_tests.data_generation_tests.test_pytorch_data_generation_runner import PytorchDataGenerationTestRunner from tests.pytorch_tests.graph_tests.test_fx_errors import TestGraphReading from tests.pytorch_tests.pruning_tests.feature_networks.test_pruning_feature_networks import PruningFeatureNetworksTest from tests.pytorch_tests.exporter_tests.test_exporting_qat_models import TestExportingQATModelTorchscript diff --git a/tests/trainable_infrastructure_tests/pytorch/__init__.py b/tests/trainable_infrastructure_tests/pytorch/__init__.py deleted file mode 100644 index 807f5e384..000000000 --- a/tests/trainable_infrastructure_tests/pytorch/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2023 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. -# ============================================================================== \ No newline at end of file diff --git a/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/__init__.py b/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/__init__.py deleted file mode 100644 index 807f5e384..000000000 --- a/tests/trainable_infrastructure_tests/pytorch/trainable_pytorch/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2023 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. -# ============================================================================== \ No newline at end of file From 1753b687255113ebe1157223fd55d54b4751bef1 Mon Sep 17 00:00:00 2001 From: reuvenp Date: Wed, 21 Aug 2024 14:38:50 +0300 Subject: [PATCH 2/5] fix import in test suite --- tests/test_suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_suite.py b/tests/test_suite.py index 1499018f8..602bfae41 100644 --- a/tests/test_suite.py +++ b/tests/test_suite.py @@ -40,7 +40,7 @@ "torchvision") is not None if found_tf: - from tests.keras_tests.keras_tests import BaseTestEnd2EndKerasXQuant + from tests.keras_tests.xquant_tests.test_xquant_end2end import BaseTestEnd2EndKerasXQuant from tests.keras_tests.function_tests.test_activation_quantization_functions import TestActivationQuantizationFunctions as TestActivationQuantizationFunctionsKeras from tests.keras_tests.function_tests.test_custom_layer import TestCustomLayer from tests.keras_tests.function_tests.test_hessian_info_calculator import TestHessianInfoCalculatorWeights, \ From 1d8af6f631c9a2fd489071d4a209424a908461bd Mon Sep 17 00:00:00 2001 From: reuvenp Date: Wed, 21 Aug 2024 14:49:49 +0300 Subject: [PATCH 3/5] fix imports in test suite --- tests/test_suite.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_suite.py b/tests/test_suite.py index 602bfae41..66a72711c 100644 --- a/tests/test_suite.py +++ b/tests/test_suite.py @@ -80,14 +80,13 @@ KerasTrainableInfrastructureTestRunner from tests.keras_tests.function_tests.test_gptq_soft_quantizer import TestGPTQSoftQuantizer as keras_gptq_soft_quantizer_test from tests.keras_tests.function_tests.test_activation_quantization_holder_gptq import TestGPTQModelBuilderWithActivationHolder - from tests.keras_tests.data_generation_tests import KerasDataGenerationTestRunner + from tests.keras_tests.data_generation_tests.test_keras_data_generation_runner import KerasDataGenerationTestRunner from tests.keras_tests.pruning_tests.test_memory_calculator import TestParameterCounter from tests.keras_tests.pruning_tests.test_pretrained_models import PruningPretrainedModelsTest from tests.keras_tests.pruning_tests.feature_networks.test_pruning_feature_networks import PruningFeatureNetworksTest from tests.keras_tests.function_tests.test_hmse_error_method import TestParamSelectionWithHMSE - from tests.keras_tests.data_generation_tests import TestReduceLROnPlateau - from tests.keras_tests.function_tests.test_node_quantization_configurations import \ - TestNodeQuantizationConfigurations + from tests.keras_tests.data_generation_tests.test_scheduler_step import TestReduceLROnPlateau + from tests.keras_tests.function_tests.test_node_quantization_configurations import TestNodeQuantizationConfigurations from tests.keras_tests.function_tests.test_quant_config_filtering import TestKerasQuantConfigFiltering if found_pytorch: @@ -100,8 +99,7 @@ # from tests.pytorch_tests.model_tests.test_models_runner import ModelTest from tests.pytorch_tests.function_tests.test_function_runner import FunctionTestRunner from tests.pytorch_tests.function_tests.test_pytorch_tp_model import TestPytorchTPModel - from tests.pytorch_tests.trainable_infrastructure_tests import \ - PytorchTrainableInfrastructureTestRunner + from tests.pytorch_tests.trainable_infrastructure_tests.test_pytorch_trainable_infra_runner import PytorchTrainableInfrastructureTestRunner from tests.pytorch_tests.function_tests.test_gptq_soft_quantizer import TestGPTQSoftQuantizer as pytorch_gptq_soft_quantier_test from tests.pytorch_tests.function_tests.test_activation_quantization_holder_gptq import \ TestGPTQModelBuilderWithActivationHolder as TestGPTQModelBuilderWithActivationHolderPytorch From 6bb7fd4d64de62daf0b6fa023924f4e2fd3d8829 Mon Sep 17 00:00:00 2001 From: reuvenp Date: Wed, 21 Aug 2024 16:15:00 +0300 Subject: [PATCH 4/5] add scl package to keras workflow --- .github/workflows/run_keras_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_keras_tests.yml b/.github/workflows/run_keras_tests.yml index 7e0f63e74..045f8fc40 100644 --- a/.github/workflows/run_keras_tests.yml +++ b/.github/workflows/run_keras_tests.yml @@ -23,7 +23,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt - pip install tensorflow==${{ inputs.tf-version }} + pip install tensorflow==${{ inputs.tf-version }} sony-custom-layers - name: Run unittests # Some tests are sensitive to memory because we use tf gradients on a multi-thread/process # CPU environment (https://github.com/tensorflow/tensorflow/issues/41718). From ff1c22c5ffe9449f8e8c97165f553cce906f53b7 Mon Sep 17 00:00:00 2001 From: reuvenp Date: Wed, 21 Aug 2024 16:18:11 +0300 Subject: [PATCH 5/5] change import of adam optimizer --- tests/keras_tests/data_generation_tests/test_scheduler_step.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/keras_tests/data_generation_tests/test_scheduler_step.py b/tests/keras_tests/data_generation_tests/test_scheduler_step.py index 91188f6dc..21bc8fd04 100644 --- a/tests/keras_tests/data_generation_tests/test_scheduler_step.py +++ b/tests/keras_tests/data_generation_tests/test_scheduler_step.py @@ -15,7 +15,7 @@ import unittest import numpy as np -from keras.src.optimizers import Adam +from keras.optimizers import Adam from model_compression_toolkit.data_generation.keras.optimization_functions.lr_scheduler import ReduceLROnPlateau