From d2da4ff619eac81ec054e3bd2ae6ddde4a108b7d Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Thu, 16 Jan 2025 17:08:07 +0200 Subject: [PATCH 01/16] win precommit --- .github/workflows/call_precommit_windows.yml | 193 +++++++++++++++++++ .github/workflows/nightly.yml | 83 ++++---- .github/workflows/precommit.yml | 42 ++-- 3 files changed, 259 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/call_precommit_windows.yml diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml new file mode 100644 index 00000000000..9c8bb30d651 --- /dev/null +++ b/.github/workflows/call_precommit_windows.yml @@ -0,0 +1,193 @@ +name: call-precommit +permissions: read-all + +on: + workflow_call: + inputs: + python_version: + description: 'Python version' + type: string + required: true + override_requirements: + description: 'Override requirements' + default: '' + type: string + required: false + +jobs: + common: + timeout-minutes: 40 + runs-on: windows-2019 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + cache: pip + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/common/requirements.txt + - name: Print installed modules + run: pip list + - name: Run common precommit test scope + run: make test-common + env: + NUM_WORKERS: 2 + + onnx: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/onnx/requirements.txt + - name: Print installed modules + run: pip list + - name: Run ONNX precommit test scope + run: make test-onnx + env: + NUM_WORKERS: 4 + + openvino: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + cache: pip + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/openvino/requirements.txt + - name: Print installed modules + run: pip list + - name: Run OV precommit test scope + run: make test-openvino + env: + NUM_WORKERS: 4 + + pytorch-cpu: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + cache: pip + - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/torch/requirements.txt + - name: Print installed modules + run: pip list + - name: Run PyTorch precommit test scope + run: | + set +e + export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" + export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" + export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" + make test-torch-cpu + env: + NUM_WORKERS: 4 + + tensorflow: + timeout-minutes: 40 + runs-on: windows-2019-8-core + if: ${{ inputs.python_version != '3.12' }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + cache: pip + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/tensorflow/requirements.txt + - name: Print installed modules + run: pip list + - name: Run TensorFlow precommit test scope + run: make test-tensorflow + env: + NUM_WORKERS: 6 + + pytorch2-cpu: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + cache: pip + - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: | + pip install . -r tests/torch2/requirements.txt + - name: Print installed modules + run: pip list + - name: Run torch2 precommit test scope + run: | + set +e + export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" + export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" + export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" + pytest -ra tests/torch2 -m "not cuda" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7121d84efb3..05270beb318 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,48 +5,55 @@ on: workflow_dispatch: schedule: - cron: '0 0 * * *' + pull_request: jobs: - install: - if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/install.yml + # install: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/install.yml - examples: - if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/examples.yml + # examples: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/examples.yml - md-dead-link-check: - runs-on: ubuntu-22.04 - if: github.repository_owner == 'openvinotoolkit' - timeout-minutes: 10 - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 + # md-dead-link-check: + # runs-on: ubuntu-22.04 + # if: github.repository_owner == 'openvinotoolkit' + # timeout-minutes: 10 + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 - tensorflow: - runs-on: ubuntu-20.04-8-cores - if: github.repository_owner == 'openvinotoolkit' - timeout-minutes: 60 - defaults: - run: - shell: bash - env: - DEBIAN_FRONTEND: noninteractive - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: 3.10.14 - cache: pip - - name: Install NNCF and test requirements - run: pip install -e . -r tests/tensorflow/requirements.txt - - name: Print installed modules - run: pip list - - name: Run TensorFlow precommit - run: pytest tests/tensorflow -m 'nightly' + # tensorflow: + # runs-on: ubuntu-20.04-8-cores + # if: github.repository_owner == 'openvinotoolkit' + # timeout-minutes: 60 + # defaults: + # run: + # shell: bash + # env: + # DEBIAN_FRONTEND: noninteractive + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: 3.10.14 + # cache: pip + # - name: Install NNCF and test requirements + # run: pip install -e . -r tests/tensorflow/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run TensorFlow precommit + # run: pytest tests/tensorflow -m 'nightly' + + # weight-compression: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/conformance_weight_compression.yml - weight-compression: + precommit-windows: if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/conformance_weight_compression.yml + uses: ./.github/workflows/call_precommit_windows.yml + with: + python_version: "3.10" diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index b5d27f01c8a..23cd3a41263 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -1,23 +1,23 @@ -name: precommit -permissions: read-all +# name: precommit +# permissions: read-all -on: - pull_request: - types: - - opened - - reopened - - synchronize - paths-ignore: - - '**/*.md' - - 'docs/**/*' - - 'tests/post_training/*' # post_training tests runs on Jenkins - - 'tests/torch/sota_checkpoints_eval.json' # reference for PT e2e - - 'tests/tensorflow/sota_checkpoints_eval.json' # reference for TF e2e - - 'tests/cross_fw/examples/*' # examples tests runs in separate workflow +# on: +# pull_request: +# types: +# - opened +# - reopened +# - synchronize +# paths-ignore: +# - '**/*.md' +# - 'docs/**/*' +# - 'tests/post_training/*' # post_training tests runs on Jenkins +# - 'tests/torch/sota_checkpoints_eval.json' # reference for PT e2e +# - 'tests/tensorflow/sota_checkpoints_eval.json' # reference for TF e2e +# - 'tests/cross_fw/examples/*' # examples tests runs in separate workflow -jobs: - pytest: - uses: ./.github/workflows/call_precommit.yml - with: - python_version: "3.10.14" - gpu_enabled: true +# jobs: +# pytest: +# uses: ./.github/workflows/call_precommit.yml +# with: +# python_version: "3.10.14" +# gpu_enabled: true From 2a3a2a8e682d71ff86acf59087de63163aff758f Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Thu, 16 Jan 2025 17:23:53 +0200 Subject: [PATCH 02/16] no cache --- .github/workflows/call_precommit_windows.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index 9c8bb30d651..74ad104427c 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -28,7 +28,6 @@ jobs: - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: ${{ inputs.python_version }} - cache: pip - name: Override constraints if: ${{ inputs.override_requirements != '' }} run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" @@ -81,7 +80,6 @@ jobs: - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: ${{ inputs.python_version }} - cache: pip - name: Override constraints if: ${{ inputs.override_requirements != '' }} run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" @@ -110,7 +108,6 @@ jobs: - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: ${{ inputs.python_version }} - cache: pip - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 - name: Override constraints if: ${{ inputs.override_requirements != '' }} @@ -146,7 +143,6 @@ jobs: - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: ${{ inputs.python_version }} - cache: pip - name: Override constraints if: ${{ inputs.override_requirements != '' }} run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" @@ -173,7 +169,6 @@ jobs: - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 with: python-version: ${{ inputs.python_version }} - cache: pip - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 - name: Override constraints if: ${{ inputs.override_requirements != '' }} From 42089c23f25918815d3422c76101fbfe9914877a Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 15:05:35 +0200 Subject: [PATCH 03/16] f --- .../torch2/function_hook/graph/build_graph_mode.py | 6 ++++-- tests/torch/test_pytorch_patch.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nncf/experimental/torch2/function_hook/graph/build_graph_mode.py b/nncf/experimental/torch2/function_hook/graph/build_graph_mode.py index a5659c631b1..cfb26681c03 100644 --- a/nncf/experimental/torch2/function_hook/graph/build_graph_mode.py +++ b/nncf/experimental/torch2/function_hook/graph/build_graph_mode.py @@ -192,9 +192,11 @@ def process_tensor_attributes(self, output: torch.Tensor, op_meta: OpMeta) -> No if output.grad_fn.name() == "TransposeBackward0": fn_name = "transpose" # grad_fn collect arguments as _saved_dim0=18446744073709551614 + # Use static arguments for .mT + # https://pytorch.org/docs/stable/tensors.html#torch.Tensor.mT fn_kwargs = { - "dim0": -(2**64 - output.grad_fn._saved_dim0), # type: ignore[attr-defined] - "dim1": -(2**64 - output.grad_fn._saved_dim1), # type: ignore[attr-defined] + "dim0": -2, + "dim1": -1, } if output.grad_fn.name() == "PermuteBackward0": fn_name = "permute" diff --git a/tests/torch/test_pytorch_patch.py b/tests/torch/test_pytorch_patch.py index 2181ffeaafc..8bcd9ceab34 100644 --- a/tests/torch/test_pytorch_patch.py +++ b/tests/torch/test_pytorch_patch.py @@ -114,7 +114,7 @@ def test_jit_script_exception_preserves_patching(): run_pytest_case_function_in_separate_process(test_jit_script_exception_preserves_patching_isolated) -@pytest.mark.xfail(is_windows(), reason="https://github.com/pytorch/pytorch/issues/122094") +@pytest.mark.skip(is_windows(), reason="https://github.com/pytorch/pytorch/issues/122094") @pytest.mark.parametrize("compile_forward", [False, True]) def test_torch_compile(compile_forward): # Run test case in a separate process to track patching of torch by NNCF From c26df7305e1a9c0fbf57afad99fc571bfda8e248 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 15:18:49 +0200 Subject: [PATCH 04/16] f --- .github/workflows/call_precommit_windows.yml | 2 +- tests/common/utils/test_timer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index 74ad104427c..244b7d5fe4b 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -65,7 +65,7 @@ jobs: - name: Run ONNX precommit test scope run: make test-onnx env: - NUM_WORKERS: 4 + NUM_WORKERS: 1 openvino: timeout-minutes: 40 diff --git a/tests/common/utils/test_timer.py b/tests/common/utils/test_timer.py index ab96ab43e3f..58e1ee9c898 100644 --- a/tests/common/utils/test_timer.py +++ b/tests/common/utils/test_timer.py @@ -17,7 +17,7 @@ def test_timer(nncf_caplog): with timer() as t: - time.sleep(1) + time.sleep(1.2) t() From 5ee716d85c3c92d5e7d25dd30c0f9879e616e91c Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 17:29:06 +0200 Subject: [PATCH 05/16] build models in test --- .../test_classification_models_graph.py | 101 ++++++++---------- tests/onnx/test_nncf_graph_builder.py | 83 +++++++------- tests/onnx/test_weightless_model.py | 7 +- 3 files changed, 85 insertions(+), 106 deletions(-) diff --git a/tests/onnx/quantization/test_classification_models_graph.py b/tests/onnx/quantization/test_classification_models_graph.py index d4b965d527f..16525554e33 100644 --- a/tests/onnx/quantization/test_classification_models_graph.py +++ b/tests/onnx/quantization/test_classification_models_graph.py @@ -22,72 +22,56 @@ from tests.onnx.quantization.common import mock_collect_statistics from tests.onnx.weightless_model import load_model_topology_with_zeros_weights + +def model_builder(model_name): + if model_name == "resnet18": + return models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) + if model_name == "resnet50_cpu_spr": + return models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1) + if model_name == "mobilenet_v2": + return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1) + if model_name == "mobilenet_v3_small": + return models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1) + if model_name == "inception_v3": + return models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1) + if model_name == "googlenet": + return models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1) + if model_name == "vgg16": + return models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1) + if model_name == "shufflenet_v2_x1_0": + return models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1) + if model_name == "squeezenet1_0": + return models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1) + if model_name == "densenet121": + return models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1) + if model_name == "mnasnet0_5": + return models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1) + raise ValueError(f"Unknown model name {model_name}") + + TORCHVISION_TEST_DATA = [ - ( - ModelToTest("resnet18", [1, 3, 224, 224]), - models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]), - models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V1), - {"target_device": TargetDevice.CPU_SPR}, - ), - ( - ModelToTest("mobilenet_v2", [1, 3, 224, 224]), - models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), - models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("inception_v3", [1, 3, 224, 224]), - models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("googlenet", [1, 3, 224, 224]), - models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("vgg16", [1, 3, 224, 224]), - models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), - models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("squeezenet1_0", [1, 3, 224, 224]), - models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("densenet121", [1, 3, 224, 224]), - models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1), - {}, - ), - ( - ModelToTest("mnasnet0_5", [1, 3, 224, 224]), - models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1), - {}, - ), + (ModelToTest("resnet18", [1, 3, 224, 224]), {}), + (ModelToTest("resnet50_cpu_spr", [1, 3, 224, 224]), {"target_device": TargetDevice.CPU_SPR}), + (ModelToTest("mobilenet_v2", [1, 3, 224, 224]), {}), + (ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), {}), + (ModelToTest("inception_v3", [1, 3, 224, 224]), {}), + (ModelToTest("googlenet", [1, 3, 224, 224]), {}), + (ModelToTest("vgg16", [1, 3, 224, 224]), {}), + (ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), {}), + (ModelToTest("squeezenet1_0", [1, 3, 224, 224]), {}), + (ModelToTest("densenet121", [1, 3, 224, 224]), {}), + (ModelToTest("mnasnet0_5", [1, 3, 224, 224]), {}), ] @pytest.mark.parametrize( - ("model_to_test", "model", "quantization_parameters"), + ("model_to_test", "quantization_parameters"), TORCHVISION_TEST_DATA, - ids=[model_to_test[0].model_name for model_to_test in TORCHVISION_TEST_DATA], + ids=[model_to_test.model_name for model_to_test in TORCHVISION_TEST_DATA], ) -def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, model, quantization_parameters): +def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, quantization_parameters): mock_collect_statistics(mocker) + model = model_builder(model_to_test.model_name) onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx") x = torch.randn(model_to_test.input_shape, requires_grad=False) torch.onnx.export(model, x, onnx_model_path, opset_version=13) @@ -105,6 +89,7 @@ def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_t ) def test_min_max_quantization_graph_onnx_model(tmp_path, mocker, model_to_test): mock_collect_statistics(mocker) + onnx_model_path = ONNX_MODEL_DIR / (model_to_test.model_name + ".onnx") original_model = load_model_topology_with_zeros_weights(onnx_model_path) diff --git a/tests/onnx/test_nncf_graph_builder.py b/tests/onnx/test_nncf_graph_builder.py index 7ccf52cb59d..fffa64e9e89 100644 --- a/tests/onnx/test_nncf_graph_builder.py +++ b/tests/onnx/test_nncf_graph_builder.py @@ -41,56 +41,51 @@ def test_compare_nncf_graph_synthetic_models(model_cls_to_test): compare_nx_graph_with_reference(nx_graph, path_to_dot, check_edge_attrs=True) +def model_builder(model_name): + if model_name == "resnet18": + return models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) + if model_name == "mobilenet_v2": + return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1) + if model_name == "mobilenet_v3_small": + return models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1) + if model_name == "inception_v3": + return models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1) + if model_name == "googlenet": + return models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1) + if model_name == "vgg16": + return models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1) + if model_name == "shufflenet_v2_x1_0": + return models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1) + if model_name == "squeezenet1_0": + return models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1) + if model_name == "densenet121": + return models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1) + if model_name == "mnasnet0_5": + return models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1) + raise ValueError(f"Unknown model name {model_name}") + + CLASSIFICATION_MODEL_DEF_AND_OBJ = [ - ( - ModelToTest("resnet18", [1, 3, 224, 224]), - models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("mobilenet_v2", [1, 3, 224, 224]), - models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), - models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("inception_v3", [1, 3, 224, 224]), - models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("googlenet", [1, 3, 224, 224]), - models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("vgg16", [1, 3, 224, 224]), - models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), - models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("squeezenet1_0", [1, 3, 224, 224]), - models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("densenet121", [1, 3, 224, 224]), - models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1), - ), - ( - ModelToTest("mnasnet0_5", [1, 3, 224, 224]), - models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1), - ), + ModelToTest("resnet18", [1, 3, 224, 224]), + ModelToTest("mobilenet_v2", [1, 3, 224, 224]), + ModelToTest("mobilenet_v3_small", [1, 3, 224, 224]), + ModelToTest("inception_v3", [1, 3, 224, 224]), + ModelToTest("googlenet", [1, 3, 224, 224]), + ModelToTest("vgg16", [1, 3, 224, 224]), + ModelToTest("shufflenet_v2_x1_0", [1, 3, 224, 224]), + ModelToTest("squeezenet1_0", [1, 3, 224, 224]), + ModelToTest("densenet121", [1, 3, 224, 224]), + ModelToTest("mnasnet0_5", [1, 3, 224, 224]), ] @pytest.mark.parametrize( - ("model_to_test", "model"), + ("model_to_test"), CLASSIFICATION_MODEL_DEF_AND_OBJ, - ids=[x.model_name for x, _ in CLASSIFICATION_MODEL_DEF_AND_OBJ], + ids=[x.model_name for x in CLASSIFICATION_MODEL_DEF_AND_OBJ], ) -def test_compare_nncf_graph_classification_real_models(tmp_path, model_to_test, model): +def test_compare_nncf_graph_classification_real_models(tmp_path, model_to_test): + model = model_builder(model_to_test.model_name) onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx") x = torch.randn(model_to_test.input_shape, requires_grad=False) torch.onnx.export(model, x, onnx_model_path, opset_version=13) @@ -115,7 +110,7 @@ def test_compare_nncf_graph_classification_real_models(tmp_path, model_to_test, @pytest.mark.parametrize(("model_to_test"), DETECTION_MODELS, ids=[x.model_name for x in DETECTION_MODELS]) -def test_compare_nncf_graph_detection_real_models(tmp_path, model_to_test): +def test_compare_nncf_graph_detection_real_models(model_to_test): onnx_model_dir = TEST_ROOT / "onnx" / "data" / "models" onnx_model_path = onnx_model_dir / (model_to_test.model_name + ".onnx") if not os.path.isdir(onnx_model_dir): diff --git a/tests/onnx/test_weightless_model.py b/tests/onnx/test_weightless_model.py index b1c7eadca4a..8ba8fa8cc67 100644 --- a/tests/onnx/test_weightless_model.py +++ b/tests/onnx/test_weightless_model.py @@ -22,11 +22,10 @@ @pytest.mark.parametrize( ("model_to_test", "model"), - [ - (ModelToTest("resnet18", [1, 3, 224, 224]), models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)), - ], + [ModelToTest("resnet18", [1, 3, 224, 224])], ) -def test_save_weightless_model(tmp_path, model_to_test, model): +def test_save_weightless_model(tmp_path, model_to_test): + model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx") x = torch.randn([1, 3, 224, 224], requires_grad=False) torch.onnx.export(model, x, onnx_model_path) From 0a2c51cfebcc087eb7ca8a9d8c9c6c056df0da2b Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 17:31:35 +0200 Subject: [PATCH 06/16] test --- .github/workflows/call_precommit_windows.yml | 220 +++++++++---------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index 244b7d5fe4b..c2f93eb60ac 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -15,31 +15,31 @@ on: required: false jobs: - common: - timeout-minutes: 40 - runs-on: windows-2019 - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: ${{ inputs.python_version }} - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: pip install . -r tests/common/requirements.txt - - name: Print installed modules - run: pip list - - name: Run common precommit test scope - run: make test-common - env: - NUM_WORKERS: 2 + # common: + # timeout-minutes: 40 + # runs-on: windows-2019 + # defaults: + # run: + # shell: bash + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: ${{ inputs.python_version }} + # - name: Override constraints + # if: ${{ inputs.override_requirements != '' }} + # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + # shell: bash + # - name: Install NNCF and test requirements + # run: pip install . -r tests/common/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run common precommit test scope + # run: make test-common + # env: + # NUM_WORKERS: 2 onnx: timeout-minutes: 40 @@ -64,35 +64,35 @@ jobs: run: pip list - name: Run ONNX precommit test scope run: make test-onnx - env: - NUM_WORKERS: 1 - - openvino: - timeout-minutes: 40 - runs-on: windows-2019-8-core - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: ${{ inputs.python_version }} - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: pip install . -r tests/openvino/requirements.txt - - name: Print installed modules - run: pip list - - name: Run OV precommit test scope - run: make test-openvino env: NUM_WORKERS: 4 + # openvino: + # timeout-minutes: 40 + # runs-on: windows-2019-8-core + # defaults: + # run: + # shell: bash + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: ${{ inputs.python_version }} + # - name: Override constraints + # if: ${{ inputs.override_requirements != '' }} + # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + # shell: bash + # - name: Install NNCF and test requirements + # run: pip install . -r tests/openvino/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run OV precommit test scope + # run: make test-openvino + # env: + # NUM_WORKERS: 4 + pytorch-cpu: timeout-minutes: 40 runs-on: windows-2019-8-core @@ -123,66 +123,66 @@ jobs: export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" - make test-torch-cpu + pytest tests\torch\quantization\test_functions.py -s env: NUM_WORKERS: 4 - tensorflow: - timeout-minutes: 40 - runs-on: windows-2019-8-core - if: ${{ inputs.python_version != '3.12' }} - defaults: - run: - shell: bash - env: - DEBIAN_FRONTEND: noninteractive - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: ${{ inputs.python_version }} - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: pip install . -r tests/tensorflow/requirements.txt - - name: Print installed modules - run: pip list - - name: Run TensorFlow precommit test scope - run: make test-tensorflow - env: - NUM_WORKERS: 6 + # tensorflow: + # timeout-minutes: 40 + # runs-on: windows-2019-8-core + # if: ${{ inputs.python_version != '3.12' }} + # defaults: + # run: + # shell: bash + # env: + # DEBIAN_FRONTEND: noninteractive + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: ${{ inputs.python_version }} + # - name: Override constraints + # if: ${{ inputs.override_requirements != '' }} + # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + # shell: bash + # - name: Install NNCF and test requirements + # run: pip install . -r tests/tensorflow/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run TensorFlow precommit test scope + # run: make test-tensorflow + # env: + # NUM_WORKERS: 6 - pytorch2-cpu: - timeout-minutes: 40 - runs-on: windows-2019-8-core - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: ${{ inputs.python_version }} - - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 - - name: Override constraints - if: ${{ inputs.override_requirements != '' }} - run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - shell: bash - - name: Install NNCF and test requirements - run: | - pip install . -r tests/torch2/requirements.txt - - name: Print installed modules - run: pip list - - name: Run torch2 precommit test scope - run: | - set +e - export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" - export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" - export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" - pytest -ra tests/torch2 -m "not cuda" + # pytorch2-cpu: + # timeout-minutes: 40 + # runs-on: windows-2019-8-core + # defaults: + # run: + # shell: bash + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: ${{ inputs.python_version }} + # - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 + # - name: Override constraints + # if: ${{ inputs.override_requirements != '' }} + # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + # shell: bash + # - name: Install NNCF and test requirements + # run: | + # pip install . -r tests/torch2/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run torch2 precommit test scope + # run: | + # set +e + # export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" + # export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" + # export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" + # pytest -ra tests/torch2 -m "not cuda" From 0f1609a8e941d80abd971b9f0fbb58b35e4b99fc Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 17:44:39 +0200 Subject: [PATCH 07/16] test --- .github/workflows/call_precommit_windows.yml | 2 +- .../quantization/test_classification_models_graph.py | 2 +- tests/onnx/test_weightless_model.py | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index c2f93eb60ac..faa07b10a58 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -123,7 +123,7 @@ jobs: export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" - pytest tests\torch\quantization\test_functions.py -s + pytest tests\\torch\\quantization\\test_functions.py -s env: NUM_WORKERS: 4 diff --git a/tests/onnx/quantization/test_classification_models_graph.py b/tests/onnx/quantization/test_classification_models_graph.py index 16525554e33..12ed1639d68 100644 --- a/tests/onnx/quantization/test_classification_models_graph.py +++ b/tests/onnx/quantization/test_classification_models_graph.py @@ -67,7 +67,7 @@ def model_builder(model_name): @pytest.mark.parametrize( ("model_to_test", "quantization_parameters"), TORCHVISION_TEST_DATA, - ids=[model_to_test.model_name for model_to_test in TORCHVISION_TEST_DATA], + ids=[model_to_test[0].model_name for model_to_test in TORCHVISION_TEST_DATA], ) def test_min_max_quantization_graph_torchvision_models(tmp_path, mocker, model_to_test, quantization_parameters): mock_collect_statistics(mocker) diff --git a/tests/onnx/test_weightless_model.py b/tests/onnx/test_weightless_model.py index 8ba8fa8cc67..f93da6b36aa 100644 --- a/tests/onnx/test_weightless_model.py +++ b/tests/onnx/test_weightless_model.py @@ -12,21 +12,15 @@ from pathlib import Path import onnx -import pytest import torch from torchvision import models -from tests.onnx.quantization.common import ModelToTest from tests.onnx.weightless_model import save_model_without_tensors -@pytest.mark.parametrize( - ("model_to_test", "model"), - [ModelToTest("resnet18", [1, 3, 224, 224])], -) -def test_save_weightless_model(tmp_path, model_to_test): +def test_save_weightless_model(tmp_path): model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) - onnx_model_path = tmp_path / (model_to_test.model_name + ".onnx") + onnx_model_path = tmp_path / "resnet18.onnx" x = torch.randn([1, 3, 224, 224], requires_grad=False) torch.onnx.export(model, x, onnx_model_path) onnx_model = onnx.load_model(onnx_model_path) From cd14452a2f00af1323a0affe8ecca4c6556e05b8 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 17:58:13 +0200 Subject: [PATCH 08/16] f --- .github/workflows/call_precommit_windows.yml | 218 +++++++++---------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index faa07b10a58..74ad104427c 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -15,31 +15,31 @@ on: required: false jobs: - # common: - # timeout-minutes: 40 - # runs-on: windows-2019 - # defaults: - # run: - # shell: bash - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: ${{ inputs.python_version }} - # - name: Override constraints - # if: ${{ inputs.override_requirements != '' }} - # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - # shell: bash - # - name: Install NNCF and test requirements - # run: pip install . -r tests/common/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run common precommit test scope - # run: make test-common - # env: - # NUM_WORKERS: 2 + common: + timeout-minutes: 40 + runs-on: windows-2019 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/common/requirements.txt + - name: Print installed modules + run: pip list + - name: Run common precommit test scope + run: make test-common + env: + NUM_WORKERS: 2 onnx: timeout-minutes: 40 @@ -67,31 +67,31 @@ jobs: env: NUM_WORKERS: 4 - # openvino: - # timeout-minutes: 40 - # runs-on: windows-2019-8-core - # defaults: - # run: - # shell: bash - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: ${{ inputs.python_version }} - # - name: Override constraints - # if: ${{ inputs.override_requirements != '' }} - # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - # shell: bash - # - name: Install NNCF and test requirements - # run: pip install . -r tests/openvino/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run OV precommit test scope - # run: make test-openvino - # env: - # NUM_WORKERS: 4 + openvino: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/openvino/requirements.txt + - name: Print installed modules + run: pip list + - name: Run OV precommit test scope + run: make test-openvino + env: + NUM_WORKERS: 4 pytorch-cpu: timeout-minutes: 40 @@ -123,66 +123,66 @@ jobs: export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" - pytest tests\\torch\\quantization\\test_functions.py -s + make test-torch-cpu env: NUM_WORKERS: 4 - # tensorflow: - # timeout-minutes: 40 - # runs-on: windows-2019-8-core - # if: ${{ inputs.python_version != '3.12' }} - # defaults: - # run: - # shell: bash - # env: - # DEBIAN_FRONTEND: noninteractive - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: ${{ inputs.python_version }} - # - name: Override constraints - # if: ${{ inputs.override_requirements != '' }} - # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - # shell: bash - # - name: Install NNCF and test requirements - # run: pip install . -r tests/tensorflow/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run TensorFlow precommit test scope - # run: make test-tensorflow - # env: - # NUM_WORKERS: 6 + tensorflow: + timeout-minutes: 40 + runs-on: windows-2019-8-core + if: ${{ inputs.python_version != '3.12' }} + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: pip install . -r tests/tensorflow/requirements.txt + - name: Print installed modules + run: pip list + - name: Run TensorFlow precommit test scope + run: make test-tensorflow + env: + NUM_WORKERS: 6 - # pytorch2-cpu: - # timeout-minutes: 40 - # runs-on: windows-2019-8-core - # defaults: - # run: - # shell: bash - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: ${{ inputs.python_version }} - # - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 - # - name: Override constraints - # if: ${{ inputs.override_requirements != '' }} - # run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" - # shell: bash - # - name: Install NNCF and test requirements - # run: | - # pip install . -r tests/torch2/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run torch2 precommit test scope - # run: | - # set +e - # export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" - # export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" - # export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" - # pytest -ra tests/torch2 -m "not cuda" + pytorch2-cpu: + timeout-minutes: 40 + runs-on: windows-2019-8-core + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: ${{ inputs.python_version }} + - uses: ilammy/msvc-dev-cmd@ed94116c4d30d2091601b81f339a2eaa1c2ba0a6 # v1.4.1 + - name: Override constraints + if: ${{ inputs.override_requirements != '' }} + run: python .github/scripts/override_constraints.py "${{ inputs.override_requirements }}" + shell: bash + - name: Install NNCF and test requirements + run: | + pip install . -r tests/torch2/requirements.txt + - name: Print installed modules + run: pip list + - name: Run torch2 precommit test scope + run: | + set +e + export LIB="${LIB};$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")" + export LIB="${LIB};$(python -c "import sys; print(sys.prefix + '/libs')")" + export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" + pytest -ra tests/torch2 -m "not cuda" From 6bb18d80199f1a0a5647a6b949ff59ba1284efa8 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 18:40:32 +0200 Subject: [PATCH 09/16] if --- tests/torch/test_pytorch_patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/torch/test_pytorch_patch.py b/tests/torch/test_pytorch_patch.py index 8bcd9ceab34..f23a10551e1 100644 --- a/tests/torch/test_pytorch_patch.py +++ b/tests/torch/test_pytorch_patch.py @@ -114,7 +114,7 @@ def test_jit_script_exception_preserves_patching(): run_pytest_case_function_in_separate_process(test_jit_script_exception_preserves_patching_isolated) -@pytest.mark.skip(is_windows(), reason="https://github.com/pytorch/pytorch/issues/122094") +@pytest.mark.skipif(is_windows(), reason="https://github.com/pytorch/pytorch/issues/122094") @pytest.mark.parametrize("compile_forward", [False, True]) def test_torch_compile(compile_forward): # Run test case in a separate process to track patching of torch by NNCF From a1124123f8e46bb777cc980e519e5ef226b88c95 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 18:46:42 +0200 Subject: [PATCH 10/16] fin --- .github/workflows/nightly.yml | 79 +++++++++++++++++------------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 05270beb318..7f01e963c4a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,52 +5,51 @@ on: workflow_dispatch: schedule: - cron: '0 0 * * *' - pull_request: jobs: - # install: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/install.yml + install: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/install.yml - # examples: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/examples.yml + examples: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/examples.yml - # md-dead-link-check: - # runs-on: ubuntu-22.04 - # if: github.repository_owner == 'openvinotoolkit' - # timeout-minutes: 10 - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 + md-dead-link-check: + runs-on: ubuntu-22.04 + if: github.repository_owner == 'openvinotoolkit' + timeout-minutes: 10 + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 - # tensorflow: - # runs-on: ubuntu-20.04-8-cores - # if: github.repository_owner == 'openvinotoolkit' - # timeout-minutes: 60 - # defaults: - # run: - # shell: bash - # env: - # DEBIAN_FRONTEND: noninteractive - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: 3.10.14 - # cache: pip - # - name: Install NNCF and test requirements - # run: pip install -e . -r tests/tensorflow/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run TensorFlow precommit - # run: pytest tests/tensorflow -m 'nightly' + tensorflow: + runs-on: ubuntu-20.04-8-cores + if: github.repository_owner == 'openvinotoolkit' + timeout-minutes: 60 + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: 3.10.14 + cache: pip + - name: Install NNCF and test requirements + run: pip install -e . -r tests/tensorflow/requirements.txt + - name: Print installed modules + run: pip list + - name: Run TensorFlow precommit + run: pytest tests/tensorflow -m 'nightly' - # weight-compression: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/conformance_weight_compression.yml + weight-compression: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/conformance_weight_compression.yml precommit-windows: if: github.repository_owner == 'openvinotoolkit' From 7bfc73ff686415d8195132110f745264aa73e3e6 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 19:53:07 +0200 Subject: [PATCH 11/16] pt_n1 --- .github/workflows/call_precommit_windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index 74ad104427c..f5100f80537 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -125,7 +125,7 @@ jobs: export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" make test-torch-cpu env: - NUM_WORKERS: 4 + NUM_WORKERS: 1 tensorflow: timeout-minutes: 40 From 7a4779d971302d37a21180b796225ea4b7725e2c Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 19:58:57 +0200 Subject: [PATCH 12/16] test --- .github/workflows/nightly.yml | 79 ++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7f01e963c4a..05270beb318 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,51 +5,52 @@ on: workflow_dispatch: schedule: - cron: '0 0 * * *' + pull_request: jobs: - install: - if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/install.yml + # install: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/install.yml - examples: - if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/examples.yml + # examples: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/examples.yml - md-dead-link-check: - runs-on: ubuntu-22.04 - if: github.repository_owner == 'openvinotoolkit' - timeout-minutes: 10 - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 + # md-dead-link-check: + # runs-on: ubuntu-22.04 + # if: github.repository_owner == 'openvinotoolkit' + # timeout-minutes: 10 + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 - tensorflow: - runs-on: ubuntu-20.04-8-cores - if: github.repository_owner == 'openvinotoolkit' - timeout-minutes: 60 - defaults: - run: - shell: bash - env: - DEBIAN_FRONTEND: noninteractive - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - lfs: true - - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - with: - python-version: 3.10.14 - cache: pip - - name: Install NNCF and test requirements - run: pip install -e . -r tests/tensorflow/requirements.txt - - name: Print installed modules - run: pip list - - name: Run TensorFlow precommit - run: pytest tests/tensorflow -m 'nightly' + # tensorflow: + # runs-on: ubuntu-20.04-8-cores + # if: github.repository_owner == 'openvinotoolkit' + # timeout-minutes: 60 + # defaults: + # run: + # shell: bash + # env: + # DEBIAN_FRONTEND: noninteractive + # steps: + # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + # with: + # lfs: true + # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + # with: + # python-version: 3.10.14 + # cache: pip + # - name: Install NNCF and test requirements + # run: pip install -e . -r tests/tensorflow/requirements.txt + # - name: Print installed modules + # run: pip list + # - name: Run TensorFlow precommit + # run: pytest tests/tensorflow -m 'nightly' - weight-compression: - if: github.repository_owner == 'openvinotoolkit' - uses: ./.github/workflows/conformance_weight_compression.yml + # weight-compression: + # if: github.repository_owner == 'openvinotoolkit' + # uses: ./.github/workflows/conformance_weight_compression.yml precommit-windows: if: github.repository_owner == 'openvinotoolkit' From ba82182bb3085bb137f7fa1be37c3cb94b46c04c Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Fri, 17 Jan 2025 22:54:09 +0200 Subject: [PATCH 13/16] test --- .github/workflows/call_precommit_windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/call_precommit_windows.yml b/.github/workflows/call_precommit_windows.yml index f5100f80537..2ece937835d 100644 --- a/.github/workflows/call_precommit_windows.yml +++ b/.github/workflows/call_precommit_windows.yml @@ -94,7 +94,7 @@ jobs: NUM_WORKERS: 4 pytorch-cpu: - timeout-minutes: 40 + timeout-minutes: 100 runs-on: windows-2019-8-core defaults: run: @@ -125,7 +125,7 @@ jobs: export INCLUDE="${INCLUDE};$(python -c "import sysconfig; print(sysconfig.get_path('include'))")" make test-torch-cpu env: - NUM_WORKERS: 1 + NUM_WORKERS: 1 # Parallel tests are falls on build extenstion. tensorflow: timeout-minutes: 40 From eac749fc4d69d8287fc275445c30037ffe777dec Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Sat, 18 Jan 2025 00:01:07 +0200 Subject: [PATCH 14/16] f --- .github/workflows/nightly.yml | 78 ++++++++++++++++----------------- .github/workflows/precommit.yml | 42 +++++++++--------- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 05270beb318..38c554bdfd2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,49 +8,49 @@ on: pull_request: jobs: - # install: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/install.yml + install: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/install.yml - # examples: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/examples.yml + examples: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/examples.yml - # md-dead-link-check: - # runs-on: ubuntu-22.04 - # if: github.repository_owner == 'openvinotoolkit' - # timeout-minutes: 10 - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 + md-dead-link-check: + runs-on: ubuntu-22.04 + if: github.repository_owner == 'openvinotoolkit' + timeout-minutes: 10 + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: AlexanderDokuchaev/md-dead-link-check@cc3ed55268899a1a6d5fd7068abbc4591eab1f74 # v0.9 - # tensorflow: - # runs-on: ubuntu-20.04-8-cores - # if: github.repository_owner == 'openvinotoolkit' - # timeout-minutes: 60 - # defaults: - # run: - # shell: bash - # env: - # DEBIAN_FRONTEND: noninteractive - # steps: - # - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - # with: - # lfs: true - # - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - # with: - # python-version: 3.10.14 - # cache: pip - # - name: Install NNCF and test requirements - # run: pip install -e . -r tests/tensorflow/requirements.txt - # - name: Print installed modules - # run: pip list - # - name: Run TensorFlow precommit - # run: pytest tests/tensorflow -m 'nightly' + tensorflow: + runs-on: ubuntu-20.04-8-cores + if: github.repository_owner == 'openvinotoolkit' + timeout-minutes: 60 + defaults: + run: + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + lfs: true + - uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 + with: + python-version: 3.10.14 + cache: pip + - name: Install NNCF and test requirements + run: pip install -e . -r tests/tensorflow/requirements.txt + - name: Print installed modules + run: pip list + - name: Run TensorFlow precommit + run: pytest tests/tensorflow -m 'nightly' - # weight-compression: - # if: github.repository_owner == 'openvinotoolkit' - # uses: ./.github/workflows/conformance_weight_compression.yml + weight-compression: + if: github.repository_owner == 'openvinotoolkit' + uses: ./.github/workflows/conformance_weight_compression.yml precommit-windows: if: github.repository_owner == 'openvinotoolkit' diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index 23cd3a41263..b5d27f01c8a 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -1,23 +1,23 @@ -# name: precommit -# permissions: read-all +name: precommit +permissions: read-all -# on: -# pull_request: -# types: -# - opened -# - reopened -# - synchronize -# paths-ignore: -# - '**/*.md' -# - 'docs/**/*' -# - 'tests/post_training/*' # post_training tests runs on Jenkins -# - 'tests/torch/sota_checkpoints_eval.json' # reference for PT e2e -# - 'tests/tensorflow/sota_checkpoints_eval.json' # reference for TF e2e -# - 'tests/cross_fw/examples/*' # examples tests runs in separate workflow +on: + pull_request: + types: + - opened + - reopened + - synchronize + paths-ignore: + - '**/*.md' + - 'docs/**/*' + - 'tests/post_training/*' # post_training tests runs on Jenkins + - 'tests/torch/sota_checkpoints_eval.json' # reference for PT e2e + - 'tests/tensorflow/sota_checkpoints_eval.json' # reference for TF e2e + - 'tests/cross_fw/examples/*' # examples tests runs in separate workflow -# jobs: -# pytest: -# uses: ./.github/workflows/call_precommit.yml -# with: -# python_version: "3.10.14" -# gpu_enabled: true +jobs: + pytest: + uses: ./.github/workflows/call_precommit.yml + with: + python_version: "3.10.14" + gpu_enabled: true From 26a3b6d0f3521727466852d6b6e6062e339c1b53 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Sat, 18 Jan 2025 00:10:00 +0200 Subject: [PATCH 15/16] f --- .github/workflows/nightly.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 38c554bdfd2..763ca44eef6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,7 +5,6 @@ on: workflow_dispatch: schedule: - cron: '0 0 * * *' - pull_request: jobs: install: From 2face3c623944797fed786352f935c75042a4b21 Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Mon, 20 Jan 2025 16:21:59 +0200 Subject: [PATCH 16/16] comment --- tests/onnx/test_nncf_graph_builder.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/tests/onnx/test_nncf_graph_builder.py b/tests/onnx/test_nncf_graph_builder.py index fffa64e9e89..d81719f73f3 100644 --- a/tests/onnx/test_nncf_graph_builder.py +++ b/tests/onnx/test_nncf_graph_builder.py @@ -14,7 +14,6 @@ import onnx import pytest import torch -from torchvision import models from nncf.onnx.graph.model_transformer import ONNXModelTransformer from nncf.onnx.graph.nncf_graph_builder import GraphConverter @@ -25,6 +24,7 @@ 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.quantization.test_classification_models_graph import model_builder from tests.onnx.weightless_model import load_model_topology_with_zeros_weights REFERENCE_GRAPHS_DIR = ONNX_TEST_ROOT / "data" / "reference_graphs" / "original_nncf_graph" @@ -41,30 +41,6 @@ def test_compare_nncf_graph_synthetic_models(model_cls_to_test): compare_nx_graph_with_reference(nx_graph, path_to_dot, check_edge_attrs=True) -def model_builder(model_name): - if model_name == "resnet18": - return models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) - if model_name == "mobilenet_v2": - return models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1) - if model_name == "mobilenet_v3_small": - return models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1) - if model_name == "inception_v3": - return models.inception_v3(weights=models.Inception_V3_Weights.IMAGENET1K_V1) - if model_name == "googlenet": - return models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1) - if model_name == "vgg16": - return models.vgg16(weights=models.VGG16_Weights.IMAGENET1K_V1) - if model_name == "shufflenet_v2_x1_0": - return models.shufflenet_v2_x1_0(weights=models.ShuffleNet_V2_X1_0_Weights.IMAGENET1K_V1) - if model_name == "squeezenet1_0": - return models.squeezenet1_0(weights=models.SqueezeNet1_0_Weights.IMAGENET1K_V1) - if model_name == "densenet121": - return models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1) - if model_name == "mnasnet0_5": - return models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1) - raise ValueError(f"Unknown model name {model_name}") - - CLASSIFICATION_MODEL_DEF_AND_OBJ = [ ModelToTest("resnet18", [1, 3, 224, 224]), ModelToTest("mobilenet_v2", [1, 3, 224, 224]),