Skip to content

Update OpenVINO NPU dynamic external-initializer expectation#29572

Open
GopalakrishnanN wants to merge 3 commits into
mainfrom
GopalakrishnanN/openvino-dynamic-ext-init-npu
Open

Update OpenVINO NPU dynamic external-initializer expectation#29572
GopalakrishnanN wants to merge 3 commits into
mainfrom
GopalakrishnanN/openvino-dynamic-ext-init-npu

Conversation

@GopalakrishnanN

Copy link
Copy Markdown
Contributor

Description

Updates the OpenVINO external-initializer dynamic-shape test to account for NPU behavior.

OVEP_ExtInit_DynamicEmbed_Tests.ModelWithDynamicShapeEmbedsWeights previously expected session construction to throw for every device when a dynamic-shape model with >2GB external weights is loaded from memory. That still holds for CPU/GPU, where dynamic backend initialization happens at session construction and the weights are embedded into the model proto, hitting protobuf's 2GB limit.

For NPU, backend creation for this dynamic-shape case is deferred at session initialization. As a result, the external weights are not embedded into the model proto at this point and session construction succeeds. The test now keeps the existing EXPECT_THROW for CPU/GPU and uses EXPECT_NO_THROW for NPU.

Testing

Installed OpenVINO 2026.2.1 into the repo .venv and built an OpenVINO NPU provider-test binary:

.venv\Scripts\python.exe tools\ci_build\build.py `
  --config Release `
  --build_dir build\Windows_OpenVINO_NPU_2026 `
  --parallel `
  --build `
  --use_openvino NPU `
  --build_shared_lib `
  --cmake_generator "Visual Studio 18 2026" `
  --cmake_extra_defines CMAKE_PREFIX_PATH="C:\Users\gnallasamy\Codes\onnxruntime\.venv\Lib\site-packages\openvino\cmake" `
  --target onnxruntime_provider_test

Build result: onnxruntime_provider_test.exe built successfully with onnxruntime_providers_openvino.dll.

Ran all CPU/GPU/NPU parameters for the updated test:

.\onnxruntime_provider_test.exe --gtest_filter="OVEP_DynamicEmbed_Tests/OVEP_ExtInit_DynamicEmbed_Tests.ModelWithDynamicShapeEmbedsWeights/*"

Result:

[==========] 3 tests from 1 test suite ran.
[  PASSED  ] 3 tests.

Also reran the self-contained NPU smoke test:

.\onnxruntime_provider_test.exe --gtest_filter="OVEP_Tests/OVEP_ExtInit_Tests.ModelFromExtInit/2"

Result:

[  PASSED  ] 1 test.

OpenVINO NPU defers dynamic-shape backend creation at session initialization, so the dynamic external-initializer test should not expect the >2GB embedded-proto failure at session construction for NPU. Keep the existing exception expectation for CPU/GPU, where the dynamic backend is initialized immediately and the protobuf size limit is still hit.
@GopalakrishnanN
GopalakrishnanN force-pushed the GopalakrishnanN/openvino-dynamic-ext-init-npu branch from 5f2802d to effdbd5 Compare July 6, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the OpenVINO EP external-initializer dynamic-shape unit test expectations to reflect that NPU handles dynamic-shape backend creation differently than CPU/GPU during session construction.

Changes:

  • Split the session-construction expectation by device: keep EXPECT_THROW for CPU/GPU and use EXPECT_NO_THROW for NPU.
  • Add an explanatory assertion message describing the NPU-specific behavior.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

Comment thread onnxruntime/test/providers/openvino/openvino_ep_ext_init.cc Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants