Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[NPU] Added NPU compile tests support to model_hub_tests (#36771)

Anton Sukhobochenkoe8fc45b69b52
diff --git a/.github/workflows/job_npu_tests.yml b/.github/workflows/job_npu_tests.yml
new file mode 100644
index 00000000000..b1dec917ac1
--- /dev/null
+++ b/.github/workflows/job_npu_tests.yml
@@ -0,0 +1,230 @@
+name: NPU tests
+
+on:
+ workflow_call:
+ inputs:
+ runner:
+ description: 'Machine on which the tests would run'
+ type: string
+ required: true
+ affected-components:
+ description: 'Components that are affected by changes in the commit defined by the Smart CI Action'
+ type: string
+ required: false
+ default: '{"TF_FE":{"test":true},"JAX_FE":{"test":true},"PyTorch_FE":{"test":true}}'
+ npu-platforms:
+ description: 'JSON list of NPU platforms to compile for (offline), each runs on its own runner. e.g. ["3720","4000","5010","5020"]'
+ type: string
+ required: false
+ default: '["3720","4000","5010","5020"]'
+ model-scope:
+ description: 'Scope of models for testing (pytest marker)'
+ type: string
+ required: false
+ default: 'precommit'
+
+permissions: read-all
+
+env:
+ PYTHON_VERSION: '3.11'
+ PIP_CACHE_PATH: "C:\\mount\\caches\\pip\\win"
+ # To debug NPU compiler, set OV_NPU_LOG_LEVEL=LOG_INFO or higher
+ # OV_NPU_LOG_LEVEL: 'LOG_INFO'
+
+jobs:
+ NPU_Models_Tests:
+ name: NPU Models tests (${{ matrix.npu-platform }})
+ timeout-minutes: 40
+ strategy:
+ # one runner per NPU platform; keep going even if one platform fails.
+ fail-fast: false
+ matrix:
+ npu-platform: ${{ fromJSON(inputs.npu-platforms) }}
+ defaults:
+ run:
+ shell: pwsh
+ runs-on: ${{ inputs.runner }}
+ env:
+ INSTALL_DIR: "${{ github.workspace }}\\install"
+ INSTALL_TEST_DIR: "${{ github.workspace }}\\install\\tests"
+ INSTALL_WHEELS_DIR: "${{ github.workspace }}\\install\\wheels"
+ TEST_DEVICE: 'NPU'
+ NPU_PLATFORM: ${{ matrix.npu-platform }}
+ MODEL_SCOPE: ${{ inputs.model-scope }}
+ # Force UTF-8 stdio so third-party progress bars (e.g. easyocr's block
+ # glyph) don't crash on the cp1252 Windows console.
+ PYTHONUTF8: '1'
+ steps:
+ - name: Download OpenVINO artifacts (tests)
+ uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
+ with:
+ name: openvino_tests
+ path: ${{ env.INSTALL_DIR }}
+ merge-multiple: true
+
+ - name: Download OpenVINO artifacts (wheels)
+ uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
+ with:
+ name: openvino_wheels
+ path: ${{ env.INSTALL_WHEELS_DIR }}
+ merge-multiple: true
+
+ - name: Extract OpenVINO tests package
+ run: Expand-Archive openvino_tests.zip -DestinationPath . -Verbose
+ working-directory: ${{ env.INSTALL_DIR }}
+
+ - name: Fetch setup_python and install wheels actions
+ uses: ababushk/checkout@dd591a6a2ac25618db4eda86e7e0d938f88cf01b # cherry_pick_retries
+ timeout-minutes: 15
+ with:
+ sparse-checkout: |
+ .github/actions/setup_python/action.yml
+ .github/actions/install_ov_wheels/action.yml
+ sparse-checkout-cone-mode: false
+ path: 'openvino'
+
+ - name: Setup Python ${{ env.PYTHON_VERSION }}
+ uses: ./openvino/.github/actions/setup_python
+ with:
+ version: ${{ env.PYTHON_VERSION }}
+ pip-cache-path: ${{ env.PIP_CACHE_PATH }}
+ set-pip-install-path: 'false'
+ self-hosted-runner: ${{ contains(inputs.runner, 'aks') }}
+ use-pip-proxy: ${{ contains(inputs.runner, 'aks') }}
+
+ - name: Install OpenVINO Python wheels
+ uses: ./openvino/.github/actions/install_ov_wheels
+ with:
+ wheels-dir-path: ${{ env.INSTALL_WHEELS_DIR }}
+ wheels-to-install: 'openvino'
+
+ # --- TensorFlow ---------------------------------------------------------
+ - name: Install TF Models tests requirements
+ if: fromJSON(inputs.affected-components).TF_FE.test
+ run: python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_tensorflow
+
+ - name: Set SSL_CERT_FILE for model downloading
+ run: echo SSL_CERT_FILE=$(python3 -m certifi) >> $env:GITHUB_ENV
+
+ - name: TensorFlow Models Tests - NPU compile-only (convert_model)
+ if: fromJSON(inputs.affected-components).TF_FE.test
+ shell: cmd
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\tensorflow\test_tf_convert_model.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-tf_fe_npu_convert_model_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ - name: TensorFlow Models Tests - NPU compile-only (read_model)
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).TF_FE.test }}
+ shell: cmd
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\tensorflow\test_tf_read_model.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-tf_fe_npu_read_model_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ # --- JAX ----------------------------------------------------------------
+ - name: Install JAX Models tests requirements
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).JAX_FE.test }}
+ run: python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_jax
+
+ - name: JAX/Flax Models Tests - NPU compile-only
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).JAX_FE.test }}
+ shell: cmd
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\jax\test_hf_transformers.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-jax_npu_model_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ # --- PyTorch (runs after TF/JAX within the same leg) --------------------
+ # Group A: torchvision + timm + edsr share compatible deps (installed together).
+ - name: Install PyTorch tests requirements (group A - torchvision/timm/edsr)
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).PyTorch_FE.test }}
+ run: |
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_pytorch `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\torchvision.txt `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\timm.txt `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\edsr.txt
+
+ - name: PyTorch Models Tests - NPU compile-only (group A)
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).PyTorch_FE.test }}
+ shell: cmd
+ env:
+ OP_REPORT_FILE: "${{ env.INSTALL_TEST_DIR }}\\TEST-pt_npu_unsupported_ops_${{ matrix.npu-platform }}.log"
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_torchvision_models.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_timm.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_edsr.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-pt_npu_groupA_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ # Group B: hf_transformers + easyocr + gfpgan + tpsmm share compatible deps.
+ - name: Install PyTorch tests requirements (group B - hf_transformers/easyocr/gfpgan/tpsmm)
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).PyTorch_FE.test }}
+ run: |
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_pytorch `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\hf_transformers.txt `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\easyocr.txt `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\gfpgan.txt `
+ -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\tpsmm.txt
+
+ - name: PyTorch Models Tests - NPU compile-only (group B)
+ if: ${{ !cancelled() && fromJSON(inputs.affected-components).PyTorch_FE.test }}
+ shell: cmd
+ env:
+ OP_REPORT_FILE: "${{ env.INSTALL_TEST_DIR }}\\TEST-pt_npu_unsupported_ops_${{ matrix.npu-platform }}.log"
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_hf_transformers.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_easyocr.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_gfpgan.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_tpsmm.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-pt_npu_groupB_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ # Group C: aliked + detectron2 share compatible deps (installed together).
+ # Disabled, re-enable: E-229647
+ - name: Install PyTorch tests requirements (group C - aliked/detectron2)
+ if: false
+ run: |
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_pytorch
+
+ # Disabled, re-enable: E-229647
+ - name: PyTorch Models Tests - NPU compile only (group C)
+ if: false
+ shell: cmd
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_aliked.py ^
+ ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_detectron2.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-pt_npu_groupC_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ # Group D: llm. Disabled on NPU (if: false) - needs additional changes to enable
+ # on Windows (gptqmodel deps + export_mode path). llm_build_deps must precede llm.txt.
+ # Disabled, re-enable: E-229647
+ - name: Install PyTorch tests requirements (group D - llm)
+ if: false
+ run: |
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\requirements_pytorch
+ python3 -m pip install -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\llm_build_deps.txt
+ python3 -m pip install --no-build-isolation -r ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\envs\llm.txt
+
+ # Disabled, re-enable: E-229647
+ - name: PyTorch Models Tests - NPU compile-only (group D - llm)
+ if: false
+ shell: cmd
+ run: |
+ set PYTHONPATH=${{ env.INSTALL_TEST_DIR }}\model_hub_tests;%PYTHONPATH%
+ python3 -m pytest ${{ env.INSTALL_TEST_DIR }}\model_hub_tests\pytorch\test_llm.py -m "%MODEL_SCOPE%" ^
+ --html=${{ env.INSTALL_TEST_DIR }}\TEST-pt_npu_llm_%NPU_PLATFORM%_%MODEL_SCOPE%.html --self-contained-html -v -s
+
+ - name: Upload Test Results
+ uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ if: ${{ !cancelled() }}
+ with:
+ name: test-results-npu-models-${{ matrix.npu-platform }}-${{ inputs.model-scope }}
+ path: |
+ ${{ env.INSTALL_TEST_DIR }}\TEST*.html
+ ${{ env.INSTALL_TEST_DIR }}\TEST-pt_npu_unsupported_ops_*.log
+ if-no-files-found: 'error'
diff --git a/.github/workflows/windows_vs2022_release.yml b/.github/workflows/windows_vs2022_release.yml
index 53504e5324c..1dcfb830b4b 100644
--- a/.github/workflows/windows_vs2022_release.yml
+++ b/.github/workflows/windows_vs2022_release.yml
@@ -563,6 +563,15 @@ jobs:
affected-components: ${{ needs.smart_ci.outputs.affected_components }}
python-version: '3.11'
+ NPU_Models_Tests:
+ name: NPU Models Tests
+ needs: [ Build, Smart_CI ]
+ uses: ./.github/workflows/job_npu_tests.yml
+ if: ${{ fromJSON(needs.smart_ci.outputs.affected_components).TF_FE.test || fromJSON(needs.smart_ci.outputs.affected_components).JAX_FE.test || fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test }}
+ with:
+ runner: 'aks-win-4-cores-8gb-test'
+ affected-components: ${{ needs.smart_ci.outputs.affected_components }}
+
CXX_Unit_Tests:
name: C++ unit tests
needs: [ Build, Smart_CI ]
@@ -670,7 +679,7 @@ jobs:
Overall_Status:
name: ci/gha_overall_status_windows
- needs: [ Smart_CI, Build, Samples, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests, Openvino_tokenizers, TensorFlow_Layer_Tests, Pytorch_Layer_Tests, JS_API ]
+ needs: [ Smart_CI, Build, Samples, CXX_Unit_Tests, Python_Unit_Tests, CPU_Functional_Tests, Openvino_tokenizers, TensorFlow_Layer_Tests, Pytorch_Layer_Tests, JS_API, NPU_Models_Tests ]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
diff --git a/tests/model_hub_tests/jax/test_hf_transformers.py b/tests/model_hub_tests/jax/test_hf_transformers.py
index e5e9f00f460..6594e08ef84 100644
--- a/tests/model_hub_tests/jax/test_hf_transformers.py
+++ b/tests/model_hub_tests/jax/test_hf_transformers.py
@@ -1,7 +1,6 @@
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
-import openvino as ov
import os
import pytest
import requests
@@ -60,9 +59,9 @@ class TestTransformersModel(TestJaxConvertModel):
for _, value in inputs.items():
new_inputs.append(value)
inputs = new_inputs
- compiled = ov.compile_model(ov_model, ie_device, self.ov_config)
- ov_outputs = compiled(inputs)
- return ov_outputs
+ # NPU compile config + compile-only mode live in the base class and are shared
+ # across all frameworks. For NPU it returns None (compile-only).
+ return super().infer_ov_model(ov_model, inputs, ie_device)
@pytest.mark.parametrize("type,name,mark,reason",
get_models_list(os.path.join(os.path.dirname(__file__), "hf_transformers_models")))
diff --git a/tests/model_hub_tests/models_hub_common/test_convert_model.py b/tests/model_hub_tests/models_hub_common/test_convert_model.py
index 29d60fe3432..374841d8773 100644
--- a/tests/model_hub_tests/models_hub_common/test_convert_model.py
+++ b/tests/model_hub_tests/models_hub_common/test_convert_model.py
@@ -1,6 +1,7 @@
# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import gc
+import os
import numpy as np
# noinspection PyUnresolvedReferences
@@ -59,9 +60,22 @@ class TestConvertModel:
def infer_fw_model(self, model_obj, inputs):
raise "infer_fw_model is not implemented"
+ def get_compile_config(self, ie_device):
+ # NPU: compile-only (offline); compiler-in-plugin is required to compile without a device
+ config = dict(self.ov_config)
+ if 'NPU' in (ie_device or ''):
+ config["NPU_COMPILER_TYPE"] = "PLUGIN"
+ npu_platform = os.environ.get("NPU_PLATFORM")
+ if npu_platform:
+ config["NPU_PLATFORM"] = npu_platform
+ return config
+
def infer_ov_model(self, ov_model, inputs, ie_device):
core = Core()
- compiled = core.compile_model(ov_model, ie_device, self.ov_config)
+ compiled = core.compile_model(ov_model, ie_device, self.get_compile_config(ie_device))
+ # Compile-only for NPU device
+ if 'NPU' in (ie_device or ''):
+ return None
ov_outputs = compiled(inputs)
return ov_outputs
@@ -99,6 +113,7 @@ class TestConvertModel:
def _run(self, model_name, model_link, ie_device):
self.model_name = model_name
+ self.ie_device = ie_device
print("Load the model {} (url: {})".format(model_name, model_link))
fw_model = self.load_model(model_name, model_link)
print("Retrieve inputs info")
@@ -110,6 +125,11 @@ class TestConvertModel:
print("Infer ov::Model")
ov_outputs = self.infer_ov_model(ov_model, inputs, ie_device)
+ # Compile-only mode (e.g. NPU offline)
+ if ov_outputs is None:
+ print("Compile-only run on {}: skipping inference and accuracy comparison".format(ie_device))
+ return
+
# Run original FW inference after OV inference, as original FW inference may change original FW model,
# which results in corruption of shared memory.
print("Infer the original model")
diff --git a/tests/model_hub_tests/models_hub_common/utils.py b/tests/model_hub_tests/models_hub_common/utils.py
index 552825f92cb..86efaab3d2a 100644
--- a/tests/model_hub_tests/models_hub_common/utils.py
+++ b/tests/model_hub_tests/models_hub_common/utils.py
@@ -53,6 +53,15 @@ def get_models_list(file_name: str):
f'Incorrect model info fields {items}. It must contain either 2 or 4 or more than 4 fields.'
return models
+
+def model_list_path(models_dir: str, list_name: str):
+ if 'NPU' in os.environ.get("TEST_DEVICE", ""):
+ npu_list = os.path.join(models_dir, "npu_" + list_name)
+ if os.path.isfile(npu_list):
+ return npu_list
+ return os.path.join(models_dir, list_name)
+
+
def get_skipped_model_links(file_name: str):
return {line_items[1] for line_items in parse_list_file(file_name)}
diff --git a/tests/model_hub_tests/pytorch/test_aliked.py b/tests/model_hub_tests/pytorch/test_aliked.py
index c738a2a726d..26b24a541fb 100644
--- a/tests/model_hub_tests/pytorch/test_aliked.py
+++ b/tests/model_hub_tests/pytorch/test_aliked.py
@@ -15,11 +15,15 @@ import torch
from openvino import convert_model, Model, PartialShape, Type
from openvino.frontend import ConversionExtension
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "aliked-n16rot": "*",
+}
def custom_op_loop(context):
map = context.get_input(0)
@@ -75,6 +79,11 @@ def read_image(path, idx):
class TestAlikedConvertModel(TestTorchConvertModel):
def setup_class(self):
+ # On NPU aliked is out of scope (see NPU_PRECOMMIT_SKIP), so skip the whole class
+ # before the native `sh build.sh` step in setup (which also fails on Windows).
+ if "NPU" in os.environ.get("TEST_DEVICE", ""):
+ pytest.skip("aliked is out of the NPU scope")
+
self.repo_dir = tempfile.TemporaryDirectory()
os.system(
f"git clone https://github.com/mvafin/ALIKED.git {self.repo_dir.name}")
@@ -131,6 +140,7 @@ class TestAlikedConvertModel(TestTorchConvertModel):
@pytest.mark.precommit
@pytest.mark.parametrize("name", get_supported_precommit_models())
def test_convert_model_all_models_default(self, name, ie_device):
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.run(name, None, ie_device)
@pytest.mark.nightly
diff --git a/tests/model_hub_tests/pytorch/test_detectron2.py b/tests/model_hub_tests/pytorch/test_detectron2.py
index 6cdc4b26490..dd063478f8b 100644
--- a/tests/model_hub_tests/pytorch/test_detectron2.py
+++ b/tests/model_hub_tests/pytorch/test_detectron2.py
@@ -9,11 +9,39 @@ import pytest
import torch
from models_hub_common.utils import get_models_list, compare_two_tensors, retry
-from torch_utils import TestTorchConvertModel, process_pytest_marks
-
+from torch_utils import TestTorchConvertModel, process_pytest_marks, skip_npu_precommit
+
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "COCO-Detection/faster_rcnn_R_50_FPN_1x": "*",
+ "COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x": "*",
+ "COCO-Detection/retinanet_R_50_FPN_1x": "*",
+ "COCO-Detection/rpn_R_50_C4_1x": "*",
+ "COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x": "*",
+ "COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x": "*",
+ "COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x": "*",
+ "COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x": "*",
+ "Cityscapes/mask_rcnn_R_50_FPN": "*",
+ "Detectron1-Comparisons/faster_rcnn_R_50_FPN_noaug_1x": "*",
+ "Detectron1-Comparisons/keypoint_rcnn_R_50_FPN_1x": "*",
+ "Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x": "*",
+ "LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x": "*",
+ "LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x": "*",
+ "Misc/cascade_mask_rcnn_R_50_FPN_3x": "*",
+ "Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv": "*",
+ "Misc/mask_rcnn_R_50_FPN_3x_syncbn": "*",
+ "Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn": "*",
+ "PascalVOC-Detection/faster_rcnn_R_50_C4": "*",
+}
class TestDetectron2ConvertModel(TestTorchConvertModel):
def setup_class(self):
+ # On NPU all detectron2 precommit models are out of scope (see NPU_PRECOMMIT_SKIP),
+ # so skip the whole class before the detectron2 build in setup (which also fails on
+ # Windows). Skipping here reports as skipped instead of erroring in setup.
+ if "NPU" in os.environ.get("TEST_DEVICE", ""):
+ pytest.skip("detectron2 is out of the NPU scope")
+
from PIL import Image
import requests
@@ -99,6 +127,7 @@ class TestDetectron2ConvertModel(TestTorchConvertModel):
get_models_list(os.path.join(os.path.dirname(__file__), "detectron2_precommit")))
@pytest.mark.precommit
def test_detectron2_precommit(self, name, type, mark, reason, ie_device):
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
pytest.skip("Detectron2 models are not enabled on ARM")
self.run(name, None, ie_device)
diff --git a/tests/model_hub_tests/pytorch/test_easyocr.py b/tests/model_hub_tests/pytorch/test_easyocr.py
index 1af89fcf5ed..74fd50dab17 100644
--- a/tests/model_hub_tests/pytorch/test_easyocr.py
+++ b/tests/model_hub_tests/pytorch/test_easyocr.py
@@ -6,11 +6,16 @@ import pytest
import torch
from openvino import PartialShape
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+NPU_PRECOMMIT_SKIP = {
+ "detector": "*",
+ "recognizer": "*",
+}
+
class TestEasyOCRConvertModel(TestTorchConvertModel):
def load_model(self, model_name, model_link):
@@ -38,6 +43,7 @@ class TestEasyOCRConvertModel(TestTorchConvertModel):
def test_convert_model(self, name, ie_device):
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
pytest.skip("EasyOCR models are not enabled on ARM")
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.run(name, None, ie_device)
@pytest.mark.precommit
@@ -46,5 +52,6 @@ class TestEasyOCRConvertModel(TestTorchConvertModel):
def test_convert_model_export(self, name, ie_device):
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
pytest.skip("EasyOCR models are not enabled on ARM")
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.mode = "export"
self.run(name, None, ie_device)
diff --git a/tests/model_hub_tests/pytorch/test_edsr.py b/tests/model_hub_tests/pytorch/test_edsr.py
index d6d01c210c6..32d4c37382c 100644
--- a/tests/model_hub_tests/pytorch/test_edsr.py
+++ b/tests/model_hub_tests/pytorch/test_edsr.py
@@ -10,12 +10,17 @@ import torch
from models_hub_common.constants import hf_cache_dir, clean_hf_cache_dir
from models_hub_common.utils import cleanup_dir
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
from PIL import Image
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "edsr": "*",
+}
+
class TestEdsrConvertModel(TestTorchConvertModel):
def load_model(self, model_name, model_link):
@@ -69,6 +74,7 @@ class TestEdsrConvertModel(TestTorchConvertModel):
@pytest.mark.parametrize("name", ["edsr"])
@pytest.mark.precommit
def test_convert_model_precommit(self, name, ie_device):
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.scale = random.randint(2, 4)
self.run(name, None, ie_device)
diff --git a/tests/model_hub_tests/pytorch/test_hf_transformers.py b/tests/model_hub_tests/pytorch/test_hf_transformers.py
index b76875d24aa..47d3610d435 100644
--- a/tests/model_hub_tests/pytorch/test_hf_transformers.py
+++ b/tests/model_hub_tests/pytorch/test_hf_transformers.py
@@ -10,7 +10,7 @@ import torch
from models_hub_common.constants import hf_cache_dir, clean_hf_cache_dir
from models_hub_common.utils import cleanup_dir, get_models_list, retry
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
def flattenize_tuples(list_input):
@@ -34,6 +34,15 @@ def flattenize_outputs(outputs):
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "bert-base-uncased": "*",
+ "google/flan-t5-base": "*",
+ "google/tapas-large-finetuned-wtq": "*",
+ "allenai/led-base-16384": "*",
+ "openai/clip-vit-large-patch14": "*",
+}
+
class TestTransformersModel(TestTorchConvertModel):
def setup_class(self):
@@ -553,6 +562,7 @@ class TestTransformersModel(TestTorchConvertModel):
def test_convert_model_precommit(self, name, type, ie_device):
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
pytest.skip("hf_transformers models are not enabled on ARM")
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.run(model_name=name, model_link=type, ie_device=ie_device)
@pytest.mark.parametrize("name,type", [("bert-base-uncased", "bert"),
@@ -562,6 +572,7 @@ class TestTransformersModel(TestTorchConvertModel):
def test_convert_model_precommit_export(self, name, type, ie_device):
if platform.machine() in ['arm', 'armv7l', 'aarch64', 'arm64', 'ARM64']:
pytest.skip("hf_transformers models are not enabled on ARM")
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.mode = "export"
self.run(model_name=name, model_link=type, ie_device=ie_device)
diff --git a/tests/model_hub_tests/pytorch/test_timm.py b/tests/model_hub_tests/pytorch/test_timm.py
index faac2930a80..d168b683a48 100644
--- a/tests/model_hub_tests/pytorch/test_timm.py
+++ b/tests/model_hub_tests/pytorch/test_timm.py
@@ -10,7 +10,7 @@ import timm
import torch
from models_hub_common.utils import get_models_list, retry
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
def filter_timm(timm_list: list) -> list:
@@ -111,6 +111,13 @@ def filter_timm(timm_list: list) -> list:
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "vit_tiny_patch16_224.augreg_in21k": "*",
+ "poolformerv2_s12.sail_in1k": "*",
+ "volo_d1_224.sail_in1k": "*",
+}
+
class TestTimmConvertModel(TestTorchConvertModel):
@retry(3, exceptions=(OSError,), delay=5)
@@ -157,6 +164,7 @@ class TestTimmConvertModel(TestTorchConvertModel):
@pytest.mark.parametrize("name", get_supported_precommit_models())
@pytest.mark.precommit
def test_convert_model_precommit(self, name, ie_device):
+ skip_npu_precommit(name, ie_device, NPU_PRECOMMIT_SKIP)
self.mode = "trace"
self.run(name, None, ie_device)
diff --git a/tests/model_hub_tests/pytorch/test_torchvision_models.py b/tests/model_hub_tests/pytorch/test_torchvision_models.py
index 75dcfae8b96..784963415ce 100644
--- a/tests/model_hub_tests/pytorch/test_torchvision_models.py
+++ b/tests/model_hub_tests/pytorch/test_torchvision_models.py
@@ -9,7 +9,7 @@ import torch
from torchvision.models import list_models, get_model
from models_hub_common.utils import get_models_list, retry
-from torch_utils import TestTorchConvertModel
+from torch_utils import TestTorchConvertModel, skip_npu_precommit
def get_all_models() -> list:
@@ -20,6 +20,12 @@ def get_all_models() -> list:
# To make tests reproducible we seed the random generator
torch.manual_seed(0)
+# Precommit models out of the NPU scope, per platform ("*" = all platforms).
+NPU_PRECOMMIT_SKIP = {
+ "raft_small": "*",
+ "swin_v2_s": {"4000", "5010", "5020"},
+}
+
class TestTorchHubConvertModel(TestTorchConvertModel):
@retry(3, exceptions=(OSError,), delay=1)
@@ -100,6 +106,7 @@ class TestTorchHubConvertModel(TestTorchConvertModel):
@pytest.mark.parametrize("model_name", get_supported_precommit_models())
@pytest.mark.precommit
def test_convert_model_precommit(self, model_name, ie_device):
+ skip_npu_precommit(model_name, ie_device, NPU_PRECOMMIT_SKIP)
self.mode = "trace"
self.run(model_name, None, ie_device)
diff --git a/tests/model_hub_tests/pytorch/torch_utils.py b/tests/model_hub_tests/pytorch/torch_utils.py
index 5aadcd414b5..e1c74a6c794 100644
--- a/tests/model_hub_tests/pytorch/torch_utils.py
+++ b/tests/model_hub_tests/pytorch/torch_utils.py
@@ -6,7 +6,7 @@ import pytest
import torch
from models_hub_common.test_convert_model import TestConvertModel
from models_hub_common.utils import get_models_list
-from openvino import convert_model
+from openvino import convert_model, PartialShape
def flattenize_tuples(list_input):
@@ -44,6 +44,23 @@ def extract_unsupported_ops_from_exception(e: str) -> list:
return []
+def skip_npu_precommit(model_name, ie_device, skip_map):
+ """Skip a precommit model that is out of the NPU scope on the current NPU_PLATFORM.
+
+ `skip_map` maps a model name to the platforms where it must be skipped: either
+ the string "*" (all platforms) or an iterable of platform ids (e.g. {"3720"}).
+ The active platform is read from the NPU_PLATFORM environment variable.
+ """
+ if "NPU" not in (ie_device or ""):
+ return
+ platforms = skip_map.get(model_name)
+ if not platforms:
+ return
+ current = os.environ.get("NPU_PLATFORM", "")
+ if platforms == "*" or current in platforms:
+ pytest.skip(f"{model_name}: out of NPU scope on platform {current or 'unknown'}")
+
+
class TestTorchConvertModel(TestConvertModel):
cached_model = None
@@ -63,10 +80,19 @@ class TestTorchConvertModel(TestConvertModel):
else:
return flattenize_structure(inputs)
+ def npu_static_input(self):
+ # NPU requires static shapes: use example input dims
+ example = self.example
+ tensors = list(example.values()) if isinstance(example, dict) else flattenize_tuples(example)
+ return [PartialShape(list(t.shape)) for t in tensors]
+
def convert_model_impl(self, model_obj):
+ is_npu = 'NPU' in (getattr(self, "ie_device", "") or '')
if hasattr(self, "mode") and self.mode == "export":
export_kwargs = {}
- if getattr(self, "dynamo_input", None):
+ if is_npu:
+ export_kwargs["input"] = self.npu_static_input()
+ elif getattr(self, "dynamo_input", None):
export_kwargs["input"] = self.dynamo_input
ov_model = convert_model(model_obj,
example_input=self.example,
@@ -75,9 +101,13 @@ class TestTorchConvertModel(TestConvertModel):
**export_kwargs,
)
else:
+ convert_kwargs = {}
+ if is_npu:
+ convert_kwargs["input"] = self.npu_static_input()
ov_model = convert_model(model_obj,
example_input=self.example,
- verbose=True
+ verbose=True,
+ **convert_kwargs,
)
return ov_model
diff --git a/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_convert_model b/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_convert_model
new file mode 100644
index 00000000000..54a6f6850b9
--- /dev/null
+++ b/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_convert_model
@@ -0,0 +1,21 @@
+mmt/data_cc,https://www.kaggle.com/models/deepmind/mmt/frameworks/tensorFlow1/variations/data-cc/versions/1,skip,CPU plug-in doesn't support Squeeze operation with dynamic rank Operation name object_classification_layer/Squeeze
+vision/embedder/fungi_V2,https://tfhub.dev/svampeatlas/vision/embedder/fungi_V2/1?tf-hub-format=compressed,skip,Model is not available
+imagenet/resnet_v2_50/feature_vector,https://www.kaggle.com/models/google/resnet-v2/frameworks/tensorFlow2/variations/50-feature-vector/versions/2
+imagenet/mobilenet_v2_100_224/feature_vector,https://www.kaggle.com/models/google/mobilenet-v2/frameworks/tensorFlow2/variations/100-224-feature-vector/versions/2
+efficientnet/lite0/classification,https://www.kaggle.com/models/tensorflow/efficientnet/frameworks/tensorFlow1/variations/lite0-classification/versions/2
+imagenet/efficientnet_v2_imagenet1k_b0/feature_vector,https://www.kaggle.com/models/google/efficientnet-v2/frameworks/tensorFlow2/variations/imagenet1k-b0-feature-vector/versions/2
+imagenet/mobilenet_v1_100_224/classification,https://www.kaggle.com/models/google/mobilenet-v1/frameworks/tensorFlow2/variations/100-224-classification/versions/2
+magenta/arbitrary-image-stylization-v1-256,https://www.kaggle.com/models/google/arbitrary-image-stylization-v1/frameworks/tensorFlow1/variations/256/versions/2,skip,skipped on all NPU platforms (compilation fails on 5020)
+object_detection/mobile_object_localizer_v1,https://www.kaggle.com/models/google/mobile-object-localizer-v1/frameworks/tensorFlow1/variations/object-detection-mobile-object-localizer-v1/versions/1,xfail,128695 - inference results mismatch
+# models with TensorListConcatV2 op
+efficientdet/lite0/detection,https://www.kaggle.com/models/tensorflow/efficientdet/frameworks/tensorFlow2/variations/lite0-detection/versions/1,skip,fails on all NPU platforms
+# secure notebook models
+unet/industrial/class_1,https://tfhub.dev/nvidia/unet/industrial/class_1/1?tf-hub-format=compressed,skip,Model is not available
+esrgan-tf2,https://www.kaggle.com/models/kaggle/esrgan-tf2/frameworks/tensorFlow2/variations/esrgan-tf2/versions/1
+# TF1 models in .pb format
+i3d-rgb,https://storage.openvinotoolkit.org/repositories/open_model_zoo/public/2022.1/i3d-rgb-tf/rgb.frozen.pb,skip,fails on all NPU platforms
+# Model with SentencePiece tokenizer, use openvino-tokenizers package
+universal-sentence-encoder-multilingual,https://www.kaggle.com/models/google/universal-sentence-encoder/frameworks/tensorFlow2/variations/multilingual/versions/2,skip,ticket 179327
+# Hugging Face Models
+facebook/convnext-tiny-224,hf_transformers
+ResNet50,tf_keras_applications
diff --git a/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_read_model b/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_read_model
new file mode 100644
index 00000000000..802df715b8c
--- /dev/null
+++ b/tests/model_hub_tests/tensorflow/model_lists/npu_precommit_read_model
@@ -0,0 +1,9 @@
+# model with HashTable and string tensors on inputs
+mil-nce/s3d,https://www.kaggle.com/models/deepmind/mil-nce/frameworks/tensorFlow1/variations/s3d/versions/1,skip,skipped on all NPU platforms (HashTable and string input tensors are not supported)
+# models from precommit_convert_model
+universal-sentence-encoder-multilingual,https://www.kaggle.com/models/google/universal-sentence-encoder/frameworks/tensorFlow2/variations/multilingual/versions/2,skip,ticket 179327
+imagenet/resnet_v2_50/feature_vector,https://www.kaggle.com/models/google/resnet-v2/frameworks/tensorFlow2/variations/50-feature-vector/versions/2
+# LookupTableImportV2 is terminating node and is needed for conversion
+openimages_v4/ssd/mobilenet_v2,https://www.kaggle.com/models/google/mobilenet-v2/frameworks/tensorFlow1/variations/openimages-v4-ssd-mobilenet-v2/versions/1,skip,skipped on all NPU platforms (LookupTableImportV2 / hash table not supported)
+# models with TensorListConcatV2 op and element_shape containing multiple undefined dimensions
+efficientdet/lite0/detection,https://www.kaggle.com/models/tensorflow/efficientdet/frameworks/tensorFlow2/variations/lite0-detection/versions/1,skip,skipped on all NPU platforms (compiler crash 0xC0000005; TensorListConcatV2 with multiple undefined dims)
\ No newline at end of file
diff --git a/tests/model_hub_tests/tensorflow/test_tf_convert_model.py b/tests/model_hub_tests/tensorflow/test_tf_convert_model.py
index 487e5db2ee5..9e9ef24cbac 100644
--- a/tests/model_hub_tests/tensorflow/test_tf_convert_model.py
+++ b/tests/model_hub_tests/tensorflow/test_tf_convert_model.py
@@ -15,8 +15,8 @@ import tensorflow_hub as hub
#import tensorflow_text # do not delete, needed for text models. Commended due to ticket 179327
from huggingface_hub import snapshot_download
from models_hub_common.test_convert_model import TestConvertModel
-from models_hub_common.utils import get_models_list
-from openvino import Core
+from models_hub_common.utils import get_models_list, model_list_path
+from openvino import convert_model
from utils import load_graph, get_input_signature, get_output_signature, unpack_tf_result, \
repack_ov_result_to_tf_format, get_output_signature_from_keras_layer, retrieve_inputs_info_for_signature, \
@@ -90,6 +90,7 @@ class TestTFHubConvertModel(TestConvertModel):
# some Keras models have input_spec and inputs attributes instead of input_signature
inputs_info = retrieve_inputs_info_from_input_spec(model_obj.input_spec, model_obj.inputs)
self.output_signature = get_output_signature_from_keras_layer(model_obj)
+ self.inputs_info = inputs_info
return inputs_info
else:
assert len(model_obj.structured_input_signature) > 1, "incorrect model or test issue"
@@ -97,12 +98,22 @@ class TestTFHubConvertModel(TestConvertModel):
inputs_info = retrieve_inputs_info_for_signature(input_signature)
self.output_signature = get_output_signature_from_keras_layer(model_obj)
+ self.inputs_info = inputs_info
return inputs_info
+ def convert_model(self, model_obj):
+ # NPU has no dynamic shapes: bake the concrete input dims (from get_inputs_info) into Parameters
+ if 'NPU' in (self.ie_device or '') and getattr(self, 'inputs_info', None):
+ input_arg = [(name, shape) for name, shape, _ in self.inputs_info]
+ print("Converting with static input shapes for {}: {}".format(self.ie_device, input_arg))
+ return convert_model(model_obj, input=input_arg)
+ return convert_model(model_obj)
+
def infer_ov_model(self, ov_model, inputs, ie_device):
- core = Core()
- compiled = core.compile_model(ov_model, ie_device)
- ov_outputs = compiled(inputs)
+ ov_outputs = super().infer_ov_model(ov_model, inputs, ie_device)
+ # For NPU ov_outputs returns None (compile-only)
+ if ov_outputs is None:
+ return None
# TF FE loses output structure in case when original model has output dictionary, where values are tuples.
# OV generates in this case a list of tensors with inner tensor names.
@@ -155,8 +166,8 @@ class TestTFHubConvertModel(TestConvertModel):
gc.collect()
@pytest.mark.parametrize("model_name,model_link,mark,reason",
- get_models_list(os.path.join(os.path.dirname(__file__),
- "model_lists", "precommit_convert_model")))
+ get_models_list(model_list_path(os.path.join(os.path.dirname(__file__),
+ "model_lists"), "precommit_convert_model")))
@pytest.mark.precommit
def test_convert_model_precommit(self, model_name, model_link, mark, reason, ie_device):
assert mark is None or mark == 'skip' or mark == 'xfail', \
diff --git a/tests/model_hub_tests/tensorflow/test_tf_read_model.py b/tests/model_hub_tests/tensorflow/test_tf_read_model.py
index 0bca7ffb327..2784d52ad5f 100644
--- a/tests/model_hub_tests/tensorflow/test_tf_read_model.py
+++ b/tests/model_hub_tests/tensorflow/test_tf_read_model.py
@@ -12,17 +12,18 @@ import tensorflow_hub as hub
# noinspection PyUnresolvedReferences
#import tensorflow_text # do not delete, needed for text models. Commented due to ticket 179327
from models_hub_common.test_convert_model import TestConvertModel
-from models_hub_common.utils import get_models_list
+from models_hub_common.utils import get_models_list, model_list_path
from openvino import Core, PartialShape
from utils import unpack_tf_result, retrieve_inputs_info_for_signature
class TestTFReadModel(TestConvertModel):
- def _reshape_if_required(self, ov_model, inputs):
+ def _reshape_if_required(self, ov_model, inputs, ie_device=None):
# check if any input of dynamic rank
# if yes, set a static rank
if isinstance(inputs, dict):
+ is_npu = 'NPU' in (ie_device or '')
needs_reshape = False
new_shapes_dict = {}
for model_input in ov_model.inputs:
@@ -32,7 +33,8 @@ class TestTFReadModel(TestConvertModel):
assert input_name in inputs, 'Inputs data does not contain {}'.format(input_name)
input_shape = list(inputs[input_name].shape)
new_shapes_dict[input_name] = PartialShape(input_shape)
- if model_input.get_partial_shape().rank.is_dynamic:
+ partial_shape = model_input.get_partial_shape()
+ if partial_shape.rank.is_dynamic or (is_npu and partial_shape.is_dynamic):
needs_reshape = True
if needs_reshape:
ov_model.reshape(new_shapes_dict)
@@ -82,8 +84,11 @@ class TestTFReadModel(TestConvertModel):
def infer_ov_model(self, model_path, inputs, ie_device):
core = Core()
ov_model = core.read_model(model_path)
- self._reshape_if_required(ov_model, inputs)
- compiled = core.compile_model(ov_model, ie_device)
+ self._reshape_if_required(ov_model, inputs, ie_device)
+ compiled = core.compile_model(ov_model, ie_device, self.get_compile_config(ie_device))
+ # Compile-only for NPU device (base _run short-circuits on None)
+ if 'NPU' in (ie_device or ''):
+ return None
ov_outputs = compiled(inputs)
return ov_outputs
@@ -130,8 +135,8 @@ class TestTFReadModel(TestConvertModel):
gc.collect()
@pytest.mark.parametrize("model_name,model_link,mark,reason",
- get_models_list(os.path.join(os.path.dirname(__file__),
- "model_lists", "precommit_read_model")))
+ get_models_list(model_list_path(os.path.join(os.path.dirname(__file__),
+ "model_lists"), "precommit_read_model")))
@pytest.mark.precommit
def test_read_model_precommit(self, model_name, model_link, mark, reason, ie_device):
assert mark is None or mark == 'skip' or mark == 'xfail', \