OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPU] Merge NPU tests headers into .cpp files (#37336)
Alexandru Enache4be3f2570827
diff --git a/src/plugins/intel_npu/tests/functional/CMakeLists.txt b/src/plugins/intel_npu/tests/functional/CMakeLists.txtindex 27e896eef1f..a0ec90f6881 100644--- a/src/plugins/intel_npu/tests/functional/CMakeLists.txt+++ b/src/plugins/intel_npu/tests/functional/CMakeLists.txt@@ -33,10 +33,6 @@ ov_add_test_target(EXCLUDED_SOURCE_PATHS${EXCLUDED_FUNC_TESTS_DIR}INCLUDES- # OpenVINO headers need to be added before the NPU headers- # Otherwise, the compiler may mistake OpenVINO headers for the NPU headers- "${OpenVINO_SOURCE_DIR}/src/tests/functional/base_func_tests/include"- "${OpenVINO_SOURCE_DIR}/src/tests/functional/plugin/shared/include"${CMAKE_CURRENT_SOURCE_DIR}${OPTIONAL_FUNC_TESTS_INCLUDES}"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances"diff --git a/src/plugins/intel_npu/tests/functional/README.md b/src/plugins/intel_npu/tests/functional/README.mdindex 5cc1805699a..e190aa82a0c 100644--- a/src/plugins/intel_npu/tests/functional/README.md+++ b/src/plugins/intel_npu/tests/functional/README.md@@ -80,19 +80,14 @@ OpenVINO test instantiations using NPU Plugin's own arguments.### File naming-Test files do not need the `_test` suffix, their location is self explanatory. The only exception is when the test header shares the same name as a production header.+Test files do not need the `_test` suffix, their location is self explanatory.### File layout-Tests that use `INSTANTIATE_TEST_SUITE_P` (parameterised tests) are split across two files:+Functional tests are defined in a single `*.cpp` file.-| File | Namespace | Contents |-|------|----------|-----------|-| `*.hpp` | `ov::test::behavior` | class declarations, method/function definitions, test definitions, aliases |-| `*.cpp` | anonymous namespace | `INSTANTIATE_TEST_SUITE_P` calls, and the arguments passed to them |+For parameterized tests, keep class declarations/definitions and `INSTANTIATE_TEST_SUITE_P` calls in the same `*.cpp` file.-The `.hpp` file must be placed in the same directory as its `.cpp` file.+Do not introduce paired `*.hpp` files for new functional tests unless the header is shared by multiple translation units as a utility/header-only helper.-Tests that use only `TEST_F` or `TEST` (no instantiation step) live entirely in a single `.cpp` file, no paired `.hpp` is needed.--Tests from `shared_tests_instances` also do not need to use `.hpp` files.+Tests from `shared_tests_instances` also do not need paired `*.hpp` files.diff --git a/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.cppindex 65720ceab3c..6489bf95323 100644--- a/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.cpp@@ -2,11 +2,1361 @@// SPDX-License-Identifier: Apache-2.0//-#include "batched_run.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class BatchedTensorsRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;+ ov::Output<const ov::Node> input;+ ov::Output<const ov::Node> output;+ std::string m_cache_dir;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (const auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration) = this->GetParam();+ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555+ }++ std::string generateCacheDirName(const std::string& test_name) {+ using namespace std::chrono;+ // Generate unique file names based on test name, thread id and timestamp+ // This allows execution of tests in parallel (stress mode)+ auto hash = std::to_string(std::hash<std::string>()(test_name));+ std::stringstream ss;+ auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());+ ss << hash << "_"+ << "_" << ts.count();+ return ss.str();+ }++ void TearDown() override {+ if (!m_cache_dir.empty()) {+ core->set_property({ov::cache_dir()});+ core.reset();+ ov::test::utils::PluginCache::get().reset();+ ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");+ ov::test::utils::removeDir(m_cache_dir);+ }++ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }++ std::shared_ptr<Model> create_n_inputs(size_t n,+ element::Type type,+ const PartialShape& shape,+ const ov::Layout& layout) {+ ResultVector res;+ ParameterVector params;++ for (size_t i = 0; i < n; i++) {+ auto index_str = std::to_string(i);+ auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);+ data1->set_friendly_name("input" + index_str);+ data1->get_output_tensor(0).set_names({"tensor_input" + index_str});+ data1->set_layout(layout);+ auto constant = opset8::Constant::create(type, {1}, {1});+ auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);+ op1->set_friendly_name("Add" + index_str);+ auto res1 = std::make_shared<ov::op::v0::Result>(op1);+ res1->set_friendly_name("Result" + index_str);+ res1->get_output_tensor(0).set_names({"tensor_output" + index_str});+ params.push_back(data1);+ res.push_back(res1);+ }++ return std::make_shared<Model>(res, params);+ }+};++// To avoid error: no previous declaration+void executeMutlipleTensorsBatchInfer(ov::InferRequest req,+ size_t batch_value,+ const Shape& non_batched_shape,+ ov::RemoteContext& context);+void executeContiguousTensorBatchInfer(ov::InferRequest req,+ size_t batch_value,+ const Shape& non_batched_shape,+ ov::RemoteContext& context);++TEST_P(BatchedTensorsRunTests, SetInputRemoteTensorsMultipleInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t i = 0; i < batch; ++i) {+ // non contiguous memory+ auto tensor = context.create_host_tensor(ov::element::f32, one_shape);+ tensors.push_back(std::move(tensor));+ }+ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+}++TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;++ std::vector<float> buffer(one_shape_size * 2 * 2, 0);++ auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);+ auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(std::move(tensor0));+ tensors.push_back(std::move(tensor1));+ tensors.push_back(std::move(tensor2));+ tensors.push_back(std::move(tensor3));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+}++TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferWithExportImport) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ // Compile model+ auto execNet = core->compile_model(model, target_device, configuration);++ // Export model+ std::stringstream modelStream;+ execNet.export_model(modelStream);++ // Import model+ auto importedExecNet = core->import_model(modelStream, target_device, configuration);++ auto context = core->get_default_context(target_device);++ // Create InferRequest from imported model+ ov::InferRequest req;+ req = importedExecNet.create_infer_request();+ std::vector<ov::Tensor> tensors;++ std::vector<float> buffer(one_shape_size * 2 * 2, 0);++ auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);+ auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(std::move(tensor0));+ tensors.push_back(std::move(tensor1));+ tensors.push_back(std::move(tensor2));+ tensors.push_back(std::move(tensor3));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+}++TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferMCL) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{batch, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();++ size_t buffer_size = one_shape_size * batch * 2;+ float* buffer = static_cast<float*>(::operator new(buffer_size * sizeof(float), std::align_val_t(4096)));+ std::memset(buffer, 0, buffer_size * sizeof(float));++ {+ std::vector<ov::Tensor> tensors;++ auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);+ auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(std::move(tensor0));+ tensors.push_back(std::move(tensor1));+ tensors.push_back(std::move(tensor2));+ tensors.push_back(std::move(tensor3));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+ }++ {+ std::vector<ov::Tensor> tensors;++ auto tensor0 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor1 = ov::Tensor(element::f32, one_shape, &buffer[(2 * 2) * one_shape_size]);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(3 * 2) * one_shape_size]);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(std::move(tensor0));+ tensors.push_back(std::move(tensor1));+ tensors.push_back(std::move(tensor2));+ tensors.push_back(std::move(tensor3));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 200);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 201) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+ }++ ::operator delete(buffer, std::align_val_t(4096));+}++TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimes) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{batch, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ ov::InferRequest req = execNet.create_infer_request();++ float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));++ std::vector<ov::Tensor> tensors;+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));++ req.set_tensors("tensor_input0", tensors);++ for (size_t i = 0; i < 10; i++) {+ for (size_t j = 0; j < one_shape_size; ++j) {+ buffer0[j] = static_cast<float>(i);+ buffer1[j] = static_cast<float>(i);+ buffer2[j] = static_cast<float>(i);+ buffer3[j] = static_cast<float>(i);+ }++ req.infer();++ auto output_tensor = req.get_tensor("tensor_output0");+ auto* output_data = output_tensor.data<float>();+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(output_data[j], static_cast<float>(i) + 1.0f)+ << "Run " << i << ": Expected=" << static_cast<float>(i) + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }+ }++ ::operator delete(buffer0, std::align_val_t(4096));+ ::operator delete(buffer1, std::align_val_t(4096));+ ::operator delete(buffer2, std::align_val_t(4096));+ ::operator delete(buffer3, std::align_val_t(4096));+}++TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawAlignedMemoryWithSetTensorAndTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{4, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto batch_size = ov::shape_size(batch_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ ov::InferRequest req = execNet.create_infer_request();++ float* bigger_buffer = static_cast<float*>(::operator new(batch_size * sizeof(float), std::align_val_t(4096)));+ for (size_t j = 0; j < batch_size; ++j) {+ bigger_buffer[j] = 1.0f;+ }++ ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer);+ req.set_tensor("tensor_input0", bigger_tensor);+ req.infer();++ ::operator delete(bigger_buffer, std::align_val_t(4096));++ auto output_tensor = req.get_tensor("tensor_output0");+ auto* output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));++ std::vector<ov::Tensor> tensors;+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));+ req.set_tensors("tensor_input0", tensors);++ for (size_t j = 0; j < one_shape_size; ++j) {+ buffer0[j] = 5.0f;+ buffer1[j] = 5.0f;+ buffer2[j] = 5.0f;+ buffer3[j] = 5.0f;+ }++ req.infer();++ output_tensor = req.get_tensor("tensor_output0");+ output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ ::operator delete(buffer0, std::align_val_t(4096));+ ::operator delete(buffer1, std::align_val_t(4096));+ ::operator delete(buffer2, std::align_val_t(4096));+ ::operator delete(buffer3, std::align_val_t(4096));+}++TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawAlignedMemoryWithSetTensorsAndTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{4, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto batch_size = ov::shape_size(batch_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ ov::InferRequest req = execNet.create_infer_request();++ float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));++ std::vector<ov::Tensor> tensors;+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));+ req.set_tensors("tensor_input0", tensors);++ for (size_t j = 0; j < one_shape_size; ++j) {+ buffer0[j] = 5.0f;+ buffer1[j] = 5.0f;+ buffer2[j] = 5.0f;+ buffer3[j] = 5.0f;+ }++ req.infer();++ auto output_tensor = req.get_tensor("tensor_output0");+ auto* output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ ::operator delete(buffer0, std::align_val_t(4096));+ ::operator delete(buffer1, std::align_val_t(4096));+ ::operator delete(buffer2, std::align_val_t(4096));+ ::operator delete(buffer3, std::align_val_t(4096));++ float* bigger_buffer = static_cast<float*>(::operator new(batch_size * sizeof(float), std::align_val_t(4096)));+ for (size_t j = 0; j < batch_size; ++j) {+ bigger_buffer[j] = 1.0f;+ }++ ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer);+ req.set_tensor("tensor_input0", bigger_tensor);+ req.infer();++ ::operator delete(bigger_buffer, std::align_val_t(4096));++ output_tensor = req.get_tensor("tensor_output0");+ output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;+ }+}++TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawUnalignedMemoryWithSetTensorAndTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{4, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto batch_size = ov::shape_size(batch_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ ov::InferRequest req = execNet.create_infer_request();++ float* bigger_buffer =+ static_cast<float*>(::operator new(batch_size * sizeof(float) + 16 * sizeof(float), std::align_val_t(4096)));+ for (size_t j = 0; j < batch_size + 16; ++j) {+ bigger_buffer[j] = 1.0f;+ }++ ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer + 16);+ req.set_tensor("tensor_input0", bigger_tensor);+ req.infer();++ ::operator delete(bigger_buffer, std::align_val_t(4096));++ auto output_tensor = req.get_tensor("tensor_output0");+ auto* output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));++ std::vector<ov::Tensor> tensors;+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));+ req.set_tensors("tensor_input0", tensors);++ for (size_t j = 0; j < one_shape_size; ++j) {+ buffer0[j] = 5.0f;+ buffer1[j] = 5.0f;+ buffer2[j] = 5.0f;+ buffer3[j] = 5.0f;+ }++ req.infer();++ output_tensor = req.get_tensor("tensor_output0");+ output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ ::operator delete(buffer0, std::align_val_t(4096));+ ::operator delete(buffer1, std::align_val_t(4096));+ ::operator delete(buffer2, std::align_val_t(4096));+ ::operator delete(buffer3, std::align_val_t(4096));+}++TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawUnalignedMemoryWithSetTensorsAndTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto one_shape = Shape{1, 16, 16, 16};+ auto batch_shape = Shape{4, 16, 16, 16};+ auto one_shape_size = ov::shape_size(one_shape);+ auto batch_size = ov::shape_size(batch_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ ov::InferRequest req = execNet.create_infer_request();++ float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));+ float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));++ std::vector<ov::Tensor> tensors;+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));+ tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));+ req.set_tensors("tensor_input0", tensors);++ for (size_t j = 0; j < one_shape_size; ++j) {+ buffer0[j] = 5.0f;+ buffer1[j] = 5.0f;+ buffer2[j] = 5.0f;+ buffer3[j] = 5.0f;+ }++ req.infer();++ auto output_tensor = req.get_tensor("tensor_output0");+ auto* output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;+ }++ ::operator delete(buffer0, std::align_val_t(4096));+ ::operator delete(buffer1, std::align_val_t(4096));+ ::operator delete(buffer2, std::align_val_t(4096));+ ::operator delete(buffer3, std::align_val_t(4096));++ float* bigger_buffer =+ static_cast<float*>(::operator new(batch_size * sizeof(float) + 16 * sizeof(float), std::align_val_t(4096)));+ for (size_t j = 0; j < batch_size + 16; ++j) {+ bigger_buffer[j] = 1.0f;+ }++ ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer + 16);+ req.set_tensor("tensor_input0", bigger_tensor);+ req.infer();++ ::operator delete(bigger_buffer, std::align_val_t(4096));++ output_tensor = req.get_tensor("tensor_output0");+ output_data = output_tensor.data<float>();+ for (size_t j = 0; j < batch_size; ++j) {+ ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;+ }+}++TEST_P(BatchedTensorsRunTests, SetInputDifferentRemoteTensorsMultipleInferMCL) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();++ std::vector<float> buffer(one_shape_size * 2 * 2, 0);++ {+ std::vector<ov::Tensor> tensors;++ auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);+ auto tensor1 = context.create_l0_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = context.create_l0_host_tensor(ov::element::f32, one_shape);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(tensor0);+ tensors.push_back(tensor1);+ tensors.push_back(tensor2);+ tensors.push_back(tensor3);++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ {+ auto* f = tensor0.data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* data = tensor1.get();+ float* f = static_cast<float*>(data);+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* data = tensor2.get();+ float* f = static_cast<float*>(data);+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* f = tensor3.data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }++ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+ }++ {+ std::vector<ov::Tensor> tensors;++ auto tensor0 = context.create_l0_host_tensor(ov::element::f32, one_shape);+ auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);+ auto tensor3 = context.create_l0_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(tensor0);+ tensors.push_back(tensor1);+ tensors.push_back(tensor2);+ tensors.push_back(tensor3);++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ {+ auto* data = tensor0.get();+ float* f = static_cast<float*>(data);+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* f = tensor1.data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* f = tensor2.data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ {+ auto* data = tensor3.get();+ float* f = static_cast<float*>(data);+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }++ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+ }+}++using DynamicBatchedTensorsRunTests = BatchedTensorsRunTests;++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsMultipleInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t i = 0; i < batch; ++i) {+ // non contiguous memory+ auto tensor = context.create_host_tensor(ov::element::f32, one_shape);+ tensors.push_back(std::move(tensor));+ }+ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 1; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20 * (i + 1));+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t i = 0; i < batch; i++) {+ for (size_t j = 0; j < one_shape_size; ++j) {+ auto expected = testNum + 20 * (i + 1) + 1;+ ASSERT_EQ(actual[i * one_shape_size + j], expected)+ << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index "+ << j << ", batch: " << i;+ }+ }+ }+}++void executeMutlipleTensorsBatchInfer(ov::InferRequest req,+ size_t batch_value,+ const Shape& non_batched_shape,+ ov::RemoteContext& context) {+ auto non_batched_shape_size = ov::shape_size(non_batched_shape);+ std::vector<ov::Tensor> tensors0, tensors1;+ tensors0.reserve(batch_value);+ tensors1.reserve(batch_value);+ ASSERT_TRUE(batch_value != 0);+ for (size_t i = 0; i < batch_value; ++i) {+ // non contiguous memory+ auto tensor0 = context.create_host_tensor(ov::element::f32, non_batched_shape);+ auto tensor1 = context.create_host_tensor(ov::element::f32, non_batched_shape);+ tensors0.push_back(std::move(tensor0));+ tensors1.push_back(std::move(tensor1));+ }++ req.set_tensors("tensor_input0", tensors0);+ req.set_tensors("tensor_input1", tensors1);++ auto actual_tensor = req.get_tensor("tensor_output0");+ ASSERT_EQ(actual_tensor.get_byte_size(), tensors0.back().get_byte_size() * tensors0.size())+ << "\"tensor_output0\" must have the same size as \"tensor_input0\" for batch_value value:" << batch_value;+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 1; testNum++) {+ for (size_t i = 0; i < batch_value; ++i) {+ auto* f = tensors0[i].data<float>();+ for (size_t j = 0; j < non_batched_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20 * (i + 1));+ }+ }+ req.infer();+ for (size_t i = 0; i < batch_value; i++) {+ for (size_t j = 0; j < non_batched_shape_size; ++j) {+ auto expected = testNum + 20 * (i + 1) + 1;+ ASSERT_EQ(actual[i * non_batched_shape_size + j], expected)+ << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index "+ << j << ", batch: " << i;+ }+ }+ }+}++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchInflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; ++tensor_batch) {+ executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchDeflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {+ executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicUnboundedBatchInflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; ++tensor_batch) {+ executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicUnboundedBatchDeflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {+ executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorSingleInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ size_t tensor_batch = 3;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto tensor_shape = Shape{tensor_batch, 2, 2, 2};+ auto tensor_shape_size = ov::shape_size(tensor_shape);+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest++ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;+ // contiguous memory+ auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);+ tensors.push_back(std::move(tensor));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 5; testNum++) {+ auto* f = tensors[0].data<float>();+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;+ ASSERT_EQ(actual[j], expected)+ << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j+ << ", batch: " << j / one_shape_size;+ }+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorSingleInferWithExportImport) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ size_t tensor_batch = 3;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto tensor_shape = Shape{tensor_batch, 2, 2, 2};+ auto tensor_shape_size = ov::shape_size(tensor_shape);+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);++ // Compile model+ auto execNet = core->compile_model(model, target_device, configuration);++ // Export model+ std::stringstream modelStream;+ execNet.export_model(modelStream);++ // Import model+ auto importedExecNet = core->import_model(modelStream, target_device, configuration);++ auto context = core->get_default_context(target_device);++ // Create InferRequest from imported model+ ov::InferRequest req;+ req = importedExecNet.create_infer_request();+ std::vector<ov::Tensor> tensors;++ // contiguous memory+ auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);+ tensors.push_back(std::move(tensor));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();++ for (auto testNum = 0; testNum < 5; testNum++) {+ auto* f = tensors[0].data<float>();+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;+ ASSERT_EQ(actual[j], expected)+ << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j+ << ", batch: " << j / one_shape_size;+ }+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleUnboundedBatchedTensorSingleInferWithExportImport) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ size_t tensor_batch = 3;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto tensor_shape = Shape{tensor_batch, 2, 2, 2};+ auto tensor_shape_size = ov::shape_size(tensor_shape);+ auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);++ // Compile model+ auto execNet = core->compile_model(model, target_device, configuration);++ // Export model+ std::stringstream modelStream;+ execNet.export_model(modelStream);++ // Import model+ auto importedExecNet = core->import_model(modelStream, target_device, configuration);++ auto context = core->get_default_context(target_device);++ // Create InferRequest from imported model+ ov::InferRequest req;+ req = importedExecNet.create_infer_request();+ std::vector<ov::Tensor> tensors;++ // contiguous memory+ auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);+ tensors.push_back(std::move(tensor));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();++ for (auto testNum = 0; testNum < 5; testNum++) {+ auto* f = tensors[0].data<float>();+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;+ ASSERT_EQ(actual[j], expected)+ << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j+ << ", batch: " << j / one_shape_size;+ }+ }+}++void executeContiguousTensorBatchInfer(ov::InferRequest req,+ size_t batch_value,+ const Shape& non_batched_shape,+ ov::RemoteContext& context) {+ auto non_batched_shape_size = ov::shape_size(non_batched_shape);+ auto tensor_shape = non_batched_shape;+ tensor_shape[0] = batch_value;+ auto tensor_shape_size = ov::shape_size(tensor_shape);+ auto tensorIn0 = context.create_host_tensor(ov::element::f32, tensor_shape);+ auto tensorIn1 = context.create_host_tensor(ov::element::f32, tensor_shape);++ std::vector<ov::Tensor> tensors0, tensors1;+ tensors0.push_back(std::move(tensorIn0));+ tensors1.push_back(std::move(tensorIn1));++ req.set_tensors("tensor_input0", tensors0);+ req.set_tensors("tensor_input1", tensors1);+ auto actual_tensor = req.get_tensor("tensor_output0");+ ASSERT_EQ(actual_tensor.get_byte_size(), tensors0.back().get_byte_size())+ << "\"tensor_output0\" must have the same size as \"tensor_input0\" for batch_value value:" << batch_value;++ auto* actual = actual_tensor.data<float>();+ auto* f = tensors0.back().data<float>();+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ f[j] = static_cast<float>(batch_value + 20 * (j / non_batched_shape_size + 1));+ }+ req.infer();+ // check that we got valid inference results on each lines of N+ for (size_t j = 0; j < tensor_shape_size; ++j) {+ auto expected = batch_value + 20 * (j / non_batched_shape_size + 1) + 1;+ ASSERT_EQ(actual[j], expected) << "Infer " << batch_value << ": Expected=" << expected+ << ", actual=" << actual[j] << " for index " << j+ << ", batch: " << j / non_batched_shape_size;+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchInflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);++ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; tensor_batch++) {+ // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]+ // and check that the output tensor kept modified accordingly+ executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchInflationWithExportImport) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);++ // Compile model+ auto execNet = core->compile_model(model, target_device, configuration);++ // Export model+ std::stringstream modelStream;+ execNet.export_model(modelStream);++ // Import model+ auto importedExecNet = core->import_model(modelStream, target_device, configuration);++ auto context = core->get_default_context(target_device);++ // Create InferRequest from imported model+ ov::InferRequest req;+ req = importedExecNet.create_infer_request();++ for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; tensor_batch++) {+ // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]+ // and check that the output tensor kept modified accordingly+ executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchDeflation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ size_t model_batch_bottom_bound = 1;+ size_t model_batch_upper_bound = 10;+ auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");++ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);++ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {+ // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]+ // and check that the output tensor kept modified accordingly+ executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);+ }+}++TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputDifferentTensorsMultipleInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ size_t batch = 4;+ auto one_shape = Shape{1, 2, 2, 2};+ auto batch_shape = Shape{batch, 2, 2, 2};+ auto one_shape_size = ov::shape_size(one_shape);+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");+ const std::string tensor_name_0 = "tensor_input0";+ const std::string tensor_name_1 = "tensor_input1";+ std::map<std::string, ov::PartialShape> shapes;+ shapes[tensor_name_0] = modelShape;+ shapes[tensor_name_1] = modelShape;+ model->reshape(shapes);+ auto execNet = core->compile_model(model, target_device, configuration);+ auto context = core->get_default_context(target_device);+ // Create InferRequest+ ov::InferRequest req;+ req = execNet.create_infer_request();+ std::vector<ov::Tensor> tensors;++ std::vector<float> buffer(one_shape_size * 2 * 2, 0);++ auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);+ auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);+ auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);+ auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);++ tensors.push_back(std::move(tensor0));+ tensors.push_back(std::move(tensor1));+ tensors.push_back(std::move(tensor2));+ tensors.push_back(std::move(tensor3));++ req.set_tensors("tensor_input0", tensors);++ auto actual_tensor = req.get_tensor("tensor_output0");+ auto* actual = actual_tensor.data<float>();+ for (auto testNum = 0; testNum < 1; testNum++) {+ for (size_t i = 0; i < batch; ++i) {+ auto* f = tensors[i].data<float>();+ for (size_t j = 0; j < one_shape_size; ++j) {+ f[j] = static_cast<float>(testNum + 20);+ }+ }+ req.infer(); // Adds '1' to each element+ for (size_t j = 0; j < one_shape_size * batch; ++j) {+ ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21+ << ", actual=" << actual[j] << " for index " << j;+ }+ }+}++using BatchedTensorsRunFailureTests = BatchedTensorsRunTests;++TEST_P(BatchedTensorsRunFailureTests, FailedToDetectBatch) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto shape = Shape{4, 2, 2};+ auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, shape, "");++ EXPECT_THROW(auto execNet = core->compile_model(model, target_device, configuration);, std::exception);+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.hppdeleted file mode 100644index f1660a62ab8..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/batched_tensors_tests/batched_run.hpp+++ /dev/null@@ -1,1360 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/node_vector.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class BatchedTensorsRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;- ov::Output<const ov::Node> input;- ov::Output<const ov::Node> output;- std::string m_cache_dir;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (const auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration) = this->GetParam();- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555- }-- std::string generateCacheDirName(const std::string& test_name) {- using namespace std::chrono;- // Generate unique file names based on test name, thread id and timestamp- // This allows execution of tests in parallel (stress mode)- auto hash = std::to_string(std::hash<std::string>()(test_name));- std::stringstream ss;- auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());- ss << hash << "_"- << "_" << ts.count();- return ss.str();- }-- void TearDown() override {- if (!m_cache_dir.empty()) {- core->set_property({ov::cache_dir()});- core.reset();- ov::test::utils::PluginCache::get().reset();- ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");- ov::test::utils::removeDir(m_cache_dir);- }-- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-- std::shared_ptr<Model> create_n_inputs(size_t n,- element::Type type,- const PartialShape& shape,- const ov::Layout& layout) {- ResultVector res;- ParameterVector params;-- for (size_t i = 0; i < n; i++) {- auto index_str = std::to_string(i);- auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);- data1->set_friendly_name("input" + index_str);- data1->get_output_tensor(0).set_names({"tensor_input" + index_str});- data1->set_layout(layout);- auto constant = opset8::Constant::create(type, {1}, {1});- auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);- op1->set_friendly_name("Add" + index_str);- auto res1 = std::make_shared<ov::op::v0::Result>(op1);- res1->set_friendly_name("Result" + index_str);- res1->get_output_tensor(0).set_names({"tensor_output" + index_str});- params.push_back(data1);- res.push_back(res1);- }-- return std::make_shared<Model>(res, params);- }-};--// To avoid error: no previous declaration-void executeMutlipleTensorsBatchInfer(ov::InferRequest req,- size_t batch_value,- const Shape& non_batched_shape,- ov::RemoteContext& context);-void executeContiguousTensorBatchInfer(ov::InferRequest req,- size_t batch_value,- const Shape& non_batched_shape,- ov::RemoteContext& context);--TEST_P(BatchedTensorsRunTests, SetInputRemoteTensorsMultipleInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t i = 0; i < batch; ++i) {- // non contiguous memory- auto tensor = context.create_host_tensor(ov::element::f32, one_shape);- tensors.push_back(std::move(tensor));- }- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }-}--TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;-- std::vector<float> buffer(one_shape_size * 2 * 2, 0);-- auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);- auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(std::move(tensor0));- tensors.push_back(std::move(tensor1));- tensors.push_back(std::move(tensor2));- tensors.push_back(std::move(tensor3));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }-}--TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferWithExportImport) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- // Compile model- auto execNet = core->compile_model(model, target_device, configuration);-- // Export model- std::stringstream modelStream;- execNet.export_model(modelStream);-- // Import model- auto importedExecNet = core->import_model(modelStream, target_device, configuration);-- auto context = core->get_default_context(target_device);-- // Create InferRequest from imported model- ov::InferRequest req;- req = importedExecNet.create_infer_request();- std::vector<ov::Tensor> tensors;-- std::vector<float> buffer(one_shape_size * 2 * 2, 0);-- auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);- auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(std::move(tensor0));- tensors.push_back(std::move(tensor1));- tensors.push_back(std::move(tensor2));- tensors.push_back(std::move(tensor3));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }-}--TEST_P(BatchedTensorsRunTests, SetInputDifferentTensorsMultipleInferMCL) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{batch, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();-- size_t buffer_size = one_shape_size * batch * 2;- float* buffer = static_cast<float*>(::operator new(buffer_size * sizeof(float), std::align_val_t(4096)));- std::memset(buffer, 0, buffer_size * sizeof(float));-- {- std::vector<ov::Tensor> tensors;-- auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);- auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(std::move(tensor0));- tensors.push_back(std::move(tensor1));- tensors.push_back(std::move(tensor2));- tensors.push_back(std::move(tensor3));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }- }-- {- std::vector<ov::Tensor> tensors;-- auto tensor0 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor1 = ov::Tensor(element::f32, one_shape, &buffer[(2 * 2) * one_shape_size]);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(3 * 2) * one_shape_size]);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(std::move(tensor0));- tensors.push_back(std::move(tensor1));- tensors.push_back(std::move(tensor2));- tensors.push_back(std::move(tensor3));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 200);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 201) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }- }-- ::operator delete(buffer, std::align_val_t(4096));-}--TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimes) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{batch, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- ov::InferRequest req = execNet.create_infer_request();-- float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));-- std::vector<ov::Tensor> tensors;- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));-- req.set_tensors("tensor_input0", tensors);-- for (size_t i = 0; i < 10; i++) {- for (size_t j = 0; j < one_shape_size; ++j) {- buffer0[j] = static_cast<float>(i);- buffer1[j] = static_cast<float>(i);- buffer2[j] = static_cast<float>(i);- buffer3[j] = static_cast<float>(i);- }-- req.infer();-- auto output_tensor = req.get_tensor("tensor_output0");- auto* output_data = output_tensor.data<float>();- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(output_data[j], static_cast<float>(i) + 1.0f)- << "Run " << i << ": Expected=" << static_cast<float>(i) + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }- }-- ::operator delete(buffer0, std::align_val_t(4096));- ::operator delete(buffer1, std::align_val_t(4096));- ::operator delete(buffer2, std::align_val_t(4096));- ::operator delete(buffer3, std::align_val_t(4096));-}--TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawAlignedMemoryWithSetTensorAndTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{4, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto batch_size = ov::shape_size(batch_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- ov::InferRequest req = execNet.create_infer_request();-- float* bigger_buffer = static_cast<float*>(::operator new(batch_size * sizeof(float), std::align_val_t(4096)));- for (size_t j = 0; j < batch_size; ++j) {- bigger_buffer[j] = 1.0f;- }-- ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer);- req.set_tensor("tensor_input0", bigger_tensor);- req.infer();-- ::operator delete(bigger_buffer, std::align_val_t(4096));-- auto output_tensor = req.get_tensor("tensor_output0");- auto* output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;- }-- float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));-- std::vector<ov::Tensor> tensors;- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));- req.set_tensors("tensor_input0", tensors);-- for (size_t j = 0; j < one_shape_size; ++j) {- buffer0[j] = 5.0f;- buffer1[j] = 5.0f;- buffer2[j] = 5.0f;- buffer3[j] = 5.0f;- }-- req.infer();-- output_tensor = req.get_tensor("tensor_output0");- output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;- }-- ::operator delete(buffer0, std::align_val_t(4096));- ::operator delete(buffer1, std::align_val_t(4096));- ::operator delete(buffer2, std::align_val_t(4096));- ::operator delete(buffer3, std::align_val_t(4096));-}--TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawAlignedMemoryWithSetTensorsAndTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{4, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto batch_size = ov::shape_size(batch_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- ov::InferRequest req = execNet.create_infer_request();-- float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));-- std::vector<ov::Tensor> tensors;- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));- req.set_tensors("tensor_input0", tensors);-- for (size_t j = 0; j < one_shape_size; ++j) {- buffer0[j] = 5.0f;- buffer1[j] = 5.0f;- buffer2[j] = 5.0f;- buffer3[j] = 5.0f;- }-- req.infer();-- auto output_tensor = req.get_tensor("tensor_output0");- auto* output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;- }-- ::operator delete(buffer0, std::align_val_t(4096));- ::operator delete(buffer1, std::align_val_t(4096));- ::operator delete(buffer2, std::align_val_t(4096));- ::operator delete(buffer3, std::align_val_t(4096));-- float* bigger_buffer = static_cast<float*>(::operator new(batch_size * sizeof(float), std::align_val_t(4096)));- for (size_t j = 0; j < batch_size; ++j) {- bigger_buffer[j] = 1.0f;- }-- ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer);- req.set_tensor("tensor_input0", bigger_tensor);- req.infer();-- ::operator delete(bigger_buffer, std::align_val_t(4096));-- output_tensor = req.get_tensor("tensor_output0");- output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;- }-}--TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawUnalignedMemoryWithSetTensorAndTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{4, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto batch_size = ov::shape_size(batch_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- ov::InferRequest req = execNet.create_infer_request();-- float* bigger_buffer =- static_cast<float*>(::operator new(batch_size * sizeof(float) + 16 * sizeof(float), std::align_val_t(4096)));- for (size_t j = 0; j < batch_size + 16; ++j) {- bigger_buffer[j] = 1.0f;- }-- ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer + 16);- req.set_tensor("tensor_input0", bigger_tensor);- req.infer();-- ::operator delete(bigger_buffer, std::align_val_t(4096));-- auto output_tensor = req.get_tensor("tensor_output0");- auto* output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;- }-- float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));-- std::vector<ov::Tensor> tensors;- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));- req.set_tensors("tensor_input0", tensors);-- for (size_t j = 0; j < one_shape_size; ++j) {- buffer0[j] = 5.0f;- buffer1[j] = 5.0f;- buffer2[j] = 5.0f;- buffer3[j] = 5.0f;- }-- req.infer();-- output_tensor = req.get_tensor("tensor_output0");- output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;- }-- ::operator delete(buffer0, std::align_val_t(4096));- ::operator delete(buffer1, std::align_val_t(4096));- ::operator delete(buffer2, std::align_val_t(4096));- ::operator delete(buffer3, std::align_val_t(4096));-}--TEST_P(BatchedTensorsRunTests, checkResultsAfterRunningWithRawUnalignedMemoryWithSetTensorsAndTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto one_shape = Shape{1, 16, 16, 16};- auto batch_shape = Shape{4, 16, 16, 16};- auto one_shape_size = ov::shape_size(one_shape);- auto batch_size = ov::shape_size(batch_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- ov::InferRequest req = execNet.create_infer_request();-- float* buffer0 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer1 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer2 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));- float* buffer3 = static_cast<float*>(::operator new(one_shape_size * sizeof(float), std::align_val_t(4096)));-- std::vector<ov::Tensor> tensors;- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer0));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer1));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer2));- tensors.push_back(ov::Tensor(element::f32, one_shape, buffer3));- req.set_tensors("tensor_input0", tensors);-- for (size_t j = 0; j < one_shape_size; ++j) {- buffer0[j] = 5.0f;- buffer1[j] = 5.0f;- buffer2[j] = 5.0f;- buffer3[j] = 5.0f;- }-- req.infer();-- auto output_tensor = req.get_tensor("tensor_output0");- auto* output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 6.0f) << "Expected=" << 6.0f << ", actual=" << output_data[j] << " for index " << j;- }-- ::operator delete(buffer0, std::align_val_t(4096));- ::operator delete(buffer1, std::align_val_t(4096));- ::operator delete(buffer2, std::align_val_t(4096));- ::operator delete(buffer3, std::align_val_t(4096));-- float* bigger_buffer =- static_cast<float*>(::operator new(batch_size * sizeof(float) + 16 * sizeof(float), std::align_val_t(4096)));- for (size_t j = 0; j < batch_size + 16; ++j) {- bigger_buffer[j] = 1.0f;- }-- ov::Tensor bigger_tensor(element::f32, batch_shape, bigger_buffer + 16);- req.set_tensor("tensor_input0", bigger_tensor);- req.infer();-- ::operator delete(bigger_buffer, std::align_val_t(4096));-- output_tensor = req.get_tensor("tensor_output0");- output_data = output_tensor.data<float>();- for (size_t j = 0; j < batch_size; ++j) {- ASSERT_EQ(output_data[j], 2.0f) << "Expected=" << 2.0f << ", actual=" << output_data[j] << " for index " << j;- }-}--TEST_P(BatchedTensorsRunTests, SetInputDifferentRemoteTensorsMultipleInferMCL) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();-- std::vector<float> buffer(one_shape_size * 2 * 2, 0);-- {- std::vector<ov::Tensor> tensors;-- auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);- auto tensor1 = context.create_l0_host_tensor(ov::element::f32, one_shape);- auto tensor2 = context.create_l0_host_tensor(ov::element::f32, one_shape);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(tensor0);- tensors.push_back(tensor1);- tensors.push_back(tensor2);- tensors.push_back(tensor3);-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- {- auto* f = tensor0.data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* data = tensor1.get();- float* f = static_cast<float*>(data);- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* data = tensor2.get();- float* f = static_cast<float*>(data);- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* f = tensor3.data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }-- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }- }-- {- std::vector<ov::Tensor> tensors;-- auto tensor0 = context.create_l0_host_tensor(ov::element::f32, one_shape);- auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);- auto tensor3 = context.create_l0_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(tensor0);- tensors.push_back(tensor1);- tensors.push_back(tensor2);- tensors.push_back(tensor3);-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- {- auto* data = tensor0.get();- float* f = static_cast<float*>(data);- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* f = tensor1.data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* f = tensor2.data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- {- auto* data = tensor3.get();- float* f = static_cast<float*>(data);- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }-- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }- }-}--using DynamicBatchedTensorsRunTests = BatchedTensorsRunTests;--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsMultipleInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t i = 0; i < batch; ++i) {- // non contiguous memory- auto tensor = context.create_host_tensor(ov::element::f32, one_shape);- tensors.push_back(std::move(tensor));- }- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 1; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20 * (i + 1));- }- }- req.infer(); // Adds '1' to each element- for (size_t i = 0; i < batch; i++) {- for (size_t j = 0; j < one_shape_size; ++j) {- auto expected = testNum + 20 * (i + 1) + 1;- ASSERT_EQ(actual[i * one_shape_size + j], expected)- << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index "- << j << ", batch: " << i;- }- }- }-}--void executeMutlipleTensorsBatchInfer(ov::InferRequest req,- size_t batch_value,- const Shape& non_batched_shape,- ov::RemoteContext& context) {- auto non_batched_shape_size = ov::shape_size(non_batched_shape);- std::vector<ov::Tensor> tensors0, tensors1;- tensors0.reserve(batch_value);- tensors1.reserve(batch_value);- ASSERT_TRUE(batch_value != 0);- for (size_t i = 0; i < batch_value; ++i) {- // non contiguous memory- auto tensor0 = context.create_host_tensor(ov::element::f32, non_batched_shape);- auto tensor1 = context.create_host_tensor(ov::element::f32, non_batched_shape);- tensors0.push_back(std::move(tensor0));- tensors1.push_back(std::move(tensor1));- }-- req.set_tensors("tensor_input0", tensors0);- req.set_tensors("tensor_input1", tensors1);-- auto actual_tensor = req.get_tensor("tensor_output0");- ASSERT_EQ(actual_tensor.get_byte_size(), tensors0.back().get_byte_size() * tensors0.size())- << "\"tensor_output0\" must have the same size as \"tensor_input0\" for batch_value value:" << batch_value;- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 1; testNum++) {- for (size_t i = 0; i < batch_value; ++i) {- auto* f = tensors0[i].data<float>();- for (size_t j = 0; j < non_batched_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20 * (i + 1));- }- }- req.infer();- for (size_t i = 0; i < batch_value; i++) {- for (size_t j = 0; j < non_batched_shape_size; ++j) {- auto expected = testNum + 20 * (i + 1) + 1;- ASSERT_EQ(actual[i * non_batched_shape_size + j], expected)- << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index "- << j << ", batch: " << i;- }- }- }-}--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchInflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; ++tensor_batch) {- executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicBatchDeflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {- executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicUnboundedBatchInflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; ++tensor_batch) {- executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputRemoteTensorsDynamicUnboundedBatchDeflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {- executeMutlipleTensorsBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorSingleInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- size_t tensor_batch = 3;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto tensor_shape = Shape{tensor_batch, 2, 2, 2};- auto tensor_shape_size = ov::shape_size(tensor_shape);- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest-- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;- // contiguous memory- auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);- tensors.push_back(std::move(tensor));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 5; testNum++) {- auto* f = tensors[0].data<float>();- for (size_t j = 0; j < tensor_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < tensor_shape_size; ++j) {- auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;- ASSERT_EQ(actual[j], expected)- << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j- << ", batch: " << j / one_shape_size;- }- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorSingleInferWithExportImport) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- size_t tensor_batch = 3;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto tensor_shape = Shape{tensor_batch, 2, 2, 2};- auto tensor_shape_size = ov::shape_size(tensor_shape);- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);-- // Compile model- auto execNet = core->compile_model(model, target_device, configuration);-- // Export model- std::stringstream modelStream;- execNet.export_model(modelStream);-- // Import model- auto importedExecNet = core->import_model(modelStream, target_device, configuration);-- auto context = core->get_default_context(target_device);-- // Create InferRequest from imported model- ov::InferRequest req;- req = importedExecNet.create_infer_request();- std::vector<ov::Tensor> tensors;-- // contiguous memory- auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);- tensors.push_back(std::move(tensor));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();-- for (auto testNum = 0; testNum < 5; testNum++) {- auto* f = tensors[0].data<float>();- for (size_t j = 0; j < tensor_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < tensor_shape_size; ++j) {- auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;- ASSERT_EQ(actual[j], expected)- << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j- << ", batch: " << j / one_shape_size;- }- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleUnboundedBatchedTensorSingleInferWithExportImport) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- size_t tensor_batch = 3;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto tensor_shape = Shape{tensor_batch, 2, 2, 2};- auto tensor_shape_size = ov::shape_size(tensor_shape);- auto modelShape = PartialShape{ov::Dimension(-1), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);-- // Compile model- auto execNet = core->compile_model(model, target_device, configuration);-- // Export model- std::stringstream modelStream;- execNet.export_model(modelStream);-- // Import model- auto importedExecNet = core->import_model(modelStream, target_device, configuration);-- auto context = core->get_default_context(target_device);-- // Create InferRequest from imported model- ov::InferRequest req;- req = importedExecNet.create_infer_request();- std::vector<ov::Tensor> tensors;-- // contiguous memory- auto tensor = context.create_host_tensor(ov::element::f32, tensor_shape);- tensors.push_back(std::move(tensor));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();-- for (auto testNum = 0; testNum < 5; testNum++) {- auto* f = tensors[0].data<float>();- for (size_t j = 0; j < tensor_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20 * (j / one_shape_size + 1));- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < tensor_shape_size; ++j) {- auto expected = testNum + 20 * (j / one_shape_size + 1) + 1;- ASSERT_EQ(actual[j], expected)- << "Infer " << testNum << ": Expected=" << expected << ", actual=" << actual[j] << " for index " << j- << ", batch: " << j / one_shape_size;- }- }-}--void executeContiguousTensorBatchInfer(ov::InferRequest req,- size_t batch_value,- const Shape& non_batched_shape,- ov::RemoteContext& context) {- auto non_batched_shape_size = ov::shape_size(non_batched_shape);- auto tensor_shape = non_batched_shape;- tensor_shape[0] = batch_value;- auto tensor_shape_size = ov::shape_size(tensor_shape);- auto tensorIn0 = context.create_host_tensor(ov::element::f32, tensor_shape);- auto tensorIn1 = context.create_host_tensor(ov::element::f32, tensor_shape);-- std::vector<ov::Tensor> tensors0, tensors1;- tensors0.push_back(std::move(tensorIn0));- tensors1.push_back(std::move(tensorIn1));-- req.set_tensors("tensor_input0", tensors0);- req.set_tensors("tensor_input1", tensors1);- auto actual_tensor = req.get_tensor("tensor_output0");- ASSERT_EQ(actual_tensor.get_byte_size(), tensors0.back().get_byte_size())- << "\"tensor_output0\" must have the same size as \"tensor_input0\" for batch_value value:" << batch_value;-- auto* actual = actual_tensor.data<float>();- auto* f = tensors0.back().data<float>();- for (size_t j = 0; j < tensor_shape_size; ++j) {- f[j] = static_cast<float>(batch_value + 20 * (j / non_batched_shape_size + 1));- }- req.infer();- // check that we got valid inference results on each lines of N- for (size_t j = 0; j < tensor_shape_size; ++j) {- auto expected = batch_value + 20 * (j / non_batched_shape_size + 1) + 1;- ASSERT_EQ(actual[j], expected) << "Infer " << batch_value << ": Expected=" << expected- << ", actual=" << actual[j] << " for index " << j- << ", batch: " << j / non_batched_shape_size;- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchInflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);-- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; tensor_batch++) {- // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]- // and check that the output tensor kept modified accordingly- executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchInflationWithExportImport) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);-- // Compile model- auto execNet = core->compile_model(model, target_device, configuration);-- // Export model- std::stringstream modelStream;- execNet.export_model(modelStream);-- // Import model- auto importedExecNet = core->import_model(modelStream, target_device, configuration);-- auto context = core->get_default_context(target_device);-- // Create InferRequest from imported model- ov::InferRequest req;- req = importedExecNet.create_infer_request();-- for (size_t tensor_batch = model_batch_bottom_bound; tensor_batch <= model_batch_upper_bound; tensor_batch++) {- // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]- // and check that the output tensor kept modified accordingly- executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, SetInputRemoteSingleBatchedTensorDynamicBatchDeflation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- size_t model_batch_bottom_bound = 1;- size_t model_batch_upper_bound = 10;- auto modelShape = PartialShape{ov::Dimension(model_batch_bottom_bound, model_batch_upper_bound), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");-- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);-- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- for (size_t tensor_batch = model_batch_upper_bound; tensor_batch >= model_batch_bottom_bound; tensor_batch--) {- // dynamically change N of contiguous memory tensor in [model_batch_bottom_bound..model_batch_upper_bound]- // and check that the output tensor kept modified accordingly- executeContiguousTensorBatchInfer(req, tensor_batch, one_shape, context);- }-}--TEST_P(DynamicBatchedTensorsRunTests, DynamicSetInputDifferentTensorsMultipleInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- size_t batch = 4;- auto one_shape = Shape{1, 2, 2, 2};- auto batch_shape = Shape{batch, 2, 2, 2};- auto one_shape_size = ov::shape_size(one_shape);- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(2, element::f32, batch_shape, "N...");- const std::string tensor_name_0 = "tensor_input0";- const std::string tensor_name_1 = "tensor_input1";- std::map<std::string, ov::PartialShape> shapes;- shapes[tensor_name_0] = modelShape;- shapes[tensor_name_1] = modelShape;- model->reshape(shapes);- auto execNet = core->compile_model(model, target_device, configuration);- auto context = core->get_default_context(target_device);- // Create InferRequest- ov::InferRequest req;- req = execNet.create_infer_request();- std::vector<ov::Tensor> tensors;-- std::vector<float> buffer(one_shape_size * 2 * 2, 0);-- auto tensor0 = ov::Tensor(element::f32, one_shape, &buffer[(0 * 2) * one_shape_size]);- auto tensor1 = context.create_host_tensor(ov::element::f32, one_shape);- auto tensor2 = ov::Tensor(element::f32, one_shape, &buffer[(1 * 2) * one_shape_size]);- auto tensor3 = context.create_host_tensor(ov::element::f32, one_shape);-- tensors.push_back(std::move(tensor0));- tensors.push_back(std::move(tensor1));- tensors.push_back(std::move(tensor2));- tensors.push_back(std::move(tensor3));-- req.set_tensors("tensor_input0", tensors);-- auto actual_tensor = req.get_tensor("tensor_output0");- auto* actual = actual_tensor.data<float>();- for (auto testNum = 0; testNum < 1; testNum++) {- for (size_t i = 0; i < batch; ++i) {- auto* f = tensors[i].data<float>();- for (size_t j = 0; j < one_shape_size; ++j) {- f[j] = static_cast<float>(testNum + 20);- }- }- req.infer(); // Adds '1' to each element- for (size_t j = 0; j < one_shape_size * batch; ++j) {- ASSERT_EQ(actual[j], testNum + 21) << "Infer " << testNum << ": Expected=" << testNum + 21- << ", actual=" << actual[j] << " for index " << j;- }- }-}--using BatchedTensorsRunFailureTests = BatchedTensorsRunTests;--TEST_P(BatchedTensorsRunFailureTests, FailedToDetectBatch) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto shape = Shape{4, 2, 2};- auto model = BatchedTensorsRunTests::create_n_inputs(1, element::f32, shape, "");-- EXPECT_THROW(auto execNet = core->compile_model(model, target_device, configuration);, std::exception);-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.cppindex 531a25de9d8..3e3dfac7a6b 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.cpp@@ -2,14 +2,154 @@// SPDX-License-Identifier: Apache-2.0//-#include "blob_compatibility.hpp"-#include <gtest/gtest.h>-#include <map>#include <string>+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace {++const char* const BLOB_PREFIX = "blob_compat_";+const char* const OV_VERSION_PREFIX = "ov";+const char* const DRIVER_PREFIX = "driver";+const char* const BLOB_SUFFIX = ".blob";+const char* const BIN_SUFFIX = ".bin";++enum class E_DUMMY_MODELS { DUMMY_MODEL, DUMMY_MODEL_STATEFUL, DUMMY_MODEL_DYNAMIC_SHAPES };++const std::map<E_DUMMY_MODELS, std::string> DUMMY_MODELS{+ {E_DUMMY_MODELS::DUMMY_MODEL, "dummy_model"},+ {E_DUMMY_MODELS::DUMMY_MODEL_STATEFUL, "dummy_model_stateful"},+ {E_DUMMY_MODELS::DUMMY_MODEL_DYNAMIC_SHAPES, "dummy_model_dynamic_shapes"}};++enum class E_PLATFORMS { MTL, LNL };++const std::map<E_PLATFORMS, std::string> PLATFORMS{{E_PLATFORMS::MTL, "MTL"}, {E_PLATFORMS::LNL, "LNL"}};+const std::map<std::string, E_PLATFORMS> PARSED_PLATFORMS{{"3720", E_PLATFORMS::MTL}, {"4000", E_PLATFORMS::LNL}};++enum class E_OV_VERSIONS { OV_2025_4_0 };++const std::map<E_OV_VERSIONS, std::string> OV_VERSIONS{{E_OV_VERSIONS::OV_2025_4_0, "2025_4_0"}};++enum class E_DRIVERS { DRIVER_1688, DRIVER_4511 };++const std::map<E_DRIVERS, std::string> DRIVERS{{E_DRIVERS::DRIVER_1688, "1688"}, {E_DRIVERS::DRIVER_4511, "2020509"}};++} // namespace++namespace ov {+namespace test {+namespace behavior {++using BlobCompatibilityParams = std::tuple</* target_device = */ std::string,+ /* model_name = */ std::string,+ /* platform = */ std::string,+ /* ov_release = */ std::string,+ /* driver = */ std::string,+ /* config = */ ov::AnyMap>;++class OVBlobCompatibilityNPU : public OVCompiledNetworkTestBase,+ public testing::WithParamInterface<BlobCompatibilityParams> {+public:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ std::string model_name, platform, ov_release, driver;+ std::tie(target_device, model_name, platform, ov_release, driver, config) = this->GetParam();+ const auto& blobName = BLOB_PREFIX + model_name + "_" + platform + "_" + OV_VERSION_PREFIX + "_" + ov_release ++ "_" + DRIVER_PREFIX + "_" + driver + BLOB_SUFFIX;+ blobPath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH + blobName;+ weightsPath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH + BLOB_PREFIX ++ model_name + BIN_SUFFIX;+ APIBaseTest::SetUp();+ }++ static std::string getTestCaseName(const testing::TestParamInfo<BlobCompatibilityParams>& obj) {+ std::string target_device, model_name, platform, ov_release, driver;+ ov::AnyMap config;+ std::tie(target_device, model_name, platform, ov_release, driver, config) = obj.param;+ std::ostringstream result;+ result << "targetDevice=" << target_device << "_blobName=\"" << BLOB_PREFIX << model_name << "_" << platform+ << "_" << OV_VERSION_PREFIX << "_" << ov_release << "_" << DRIVER_PREFIX << "_" << driver << BLOB_SUFFIX+ << "\"" << "_";++ if (!config.empty()) {+ for (auto& configItem : config) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++protected:+ ov::Core core;+ std::string blobPath;+ std::string weightsPath;+ ov::AnyMap config;+};++using compatibility_OVBlobCompatibilityNPU_PV_Driver_No_Throw = OVBlobCompatibilityNPU;+using OVBlobCompatibilityNPU_Metadata_No_Throw = OVBlobCompatibilityNPU;++#define NO_APPEND_EXPORT(ASSERT_TYPE, ...)+#define APPEND_EXPORT(ASSERT_TYPE) \+ std::shared_ptr<ov::Model> nullModel(nullptr); \+ ov::CompiledModel compiledModel; \+ config.emplace(ov::hint::compiled_blob(ov::read_tensor_data(blobPath))); \+ ASSERT_TYPE(compiledModel = core.compile_model(nullModel, target_device, config)); \+ config.erase(ov::hint::compiled_blob.name()); \+ std::ostringstream outBlobStream; \+ ASSERT_TYPE(compiledModel.export_model(outBlobStream)); \+ EXPECT_TRUE(outBlobStream.tellp() > 0);++#define APPEND_EXPORT_HELPER_(arg1, arg2, arg3, ...) arg3+#define APPEND_EXPORT_HELPER(...) APPEND_EXPORT_HELPER_(__VA_ARGS__, NO_APPEND_EXPORT, APPEND_EXPORT)(__VA_ARGS__)++#define DEFAULT_TEST_BODY(ASSERT_TYPE, ...) \+ std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); \+ config.emplace(ov::weights_path(weightsPath)); \+ ASSERT_TYPE(core.import_model(blobStream, target_device, config), ##__VA_ARGS__); \+ APPEND_EXPORT_HELPER(ASSERT_TYPE, ##__VA_ARGS__)++TEST_P(OVBlobCompatibilityNPU, CanImportAllPrecompiledBlobsForAllOVVersionsAndDrivers) {+ DEFAULT_TEST_BODY(OV_ASSERT_NO_THROW);+}++TEST_P(compatibility_OVBlobCompatibilityNPU_PV_Driver_No_Throw, CanImportExpectedModelsForPVDriverAndAllOVVersions) {+ size_t mtlPlatformPos = std::string::npos;+ const char slashDelimiter = '/';+ const char backSlashDelimiter = '\\';+ size_t lastSlashDelim = blobPath.find_last_of(slashDelimiter);+ size_t lastBackSlashDelim = blobPath.find_last_of(backSlashDelimiter);+ if (lastSlashDelim != std::string::npos && lastBackSlashDelim != std::string::npos) {+ mtlPlatformPos = blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), std::max(lastSlashDelim, lastBackSlashDelim));+ } else {+ mtlPlatformPos = blobPath.find(slashDelimiter) != std::string::npos+ ? blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), blobPath.rfind(slashDelimiter))+ : blobPath.find(backSlashDelimiter) != std::string::npos+ ? blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), blobPath.rfind(backSlashDelimiter))+ : blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL));+ }+ if (mtlPlatformPos == std::string::npos) {+ GTEST_SKIP() << "PV driver blob tests designed for NPU3720";+ }+ DEFAULT_TEST_BODY(OV_ASSERT_NO_THROW);+}++#undef NO_APPEND_EXPORT+#undef APPEND_EXPORT+#undef APPEND_EXPORT_HELPER_+#undef APPEND_EXPORT_HELPER+#undef DEFAULT_TEST_BODY++} // namespace behavior++} // namespace test++} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.hppdeleted file mode 100644index 6755059b7ec..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/blob_compatibility.hpp+++ /dev/null@@ -1,151 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace {--const char* const BLOB_PREFIX = "blob_compat_";-const char* const OV_VERSION_PREFIX = "ov";-const char* const DRIVER_PREFIX = "driver";-const char* const BLOB_SUFFIX = ".blob";-const char* const BIN_SUFFIX = ".bin";--enum class E_DUMMY_MODELS { DUMMY_MODEL, DUMMY_MODEL_STATEFUL, DUMMY_MODEL_DYNAMIC_SHAPES };--const std::map<E_DUMMY_MODELS, std::string> DUMMY_MODELS{- {E_DUMMY_MODELS::DUMMY_MODEL, "dummy_model"},- {E_DUMMY_MODELS::DUMMY_MODEL_STATEFUL, "dummy_model_stateful"},- {E_DUMMY_MODELS::DUMMY_MODEL_DYNAMIC_SHAPES, "dummy_model_dynamic_shapes"}};--enum class E_PLATFORMS { MTL, LNL };--const std::map<E_PLATFORMS, std::string> PLATFORMS{{E_PLATFORMS::MTL, "MTL"}, {E_PLATFORMS::LNL, "LNL"}};-const std::map<std::string, E_PLATFORMS> PARSED_PLATFORMS{{"3720", E_PLATFORMS::MTL}, {"4000", E_PLATFORMS::LNL}};--enum class E_OV_VERSIONS { OV_2025_4_0 };--const std::map<E_OV_VERSIONS, std::string> OV_VERSIONS{{E_OV_VERSIONS::OV_2025_4_0, "2025_4_0"}};--enum class E_DRIVERS { DRIVER_1688, DRIVER_4511 };--const std::map<E_DRIVERS, std::string> DRIVERS{{E_DRIVERS::DRIVER_1688, "1688"}, {E_DRIVERS::DRIVER_4511, "2020509"}};--} // namespace--namespace ov {-namespace test {-namespace behavior {--using BlobCompatibilityParams = std::tuple</* target_device = */ std::string,- /* model_name = */ std::string,- /* platform = */ std::string,- /* ov_release = */ std::string,- /* driver = */ std::string,- /* config = */ ov::AnyMap>;--class OVBlobCompatibilityNPU : public OVCompiledNetworkTestBase,- public testing::WithParamInterface<BlobCompatibilityParams> {-public:- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- std::string model_name, platform, ov_release, driver;- std::tie(target_device, model_name, platform, ov_release, driver, config) = this->GetParam();- const auto& blobName = BLOB_PREFIX + model_name + "_" + platform + "_" + OV_VERSION_PREFIX + "_" + ov_release +- "_" + DRIVER_PREFIX + "_" + driver + BLOB_SUFFIX;- blobPath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH + blobName;- weightsPath = ov::test::utils::NpuTestEnvConfig::getInstance().OV_NPU_TESTS_BLOBS_PATH + BLOB_PREFIX +- model_name + BIN_SUFFIX;- APIBaseTest::SetUp();- }-- static std::string getTestCaseName(const testing::TestParamInfo<BlobCompatibilityParams>& obj) {- std::string target_device, model_name, platform, ov_release, driver;- ov::AnyMap config;- std::tie(target_device, model_name, platform, ov_release, driver, config) = obj.param;- std::ostringstream result;- result << "targetDevice=" << target_device << "_blobName=\"" << BLOB_PREFIX << model_name << "_" << platform- << "_" << OV_VERSION_PREFIX << "_" << ov_release << "_" << DRIVER_PREFIX << "_" << driver << BLOB_SUFFIX- << "\"" << "_";-- if (!config.empty()) {- for (auto& configItem : config) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }--protected:- ov::Core core;- std::string blobPath;- std::string weightsPath;- ov::AnyMap config;-};--using compatibility_OVBlobCompatibilityNPU_PV_Driver_No_Throw = OVBlobCompatibilityNPU;-using OVBlobCompatibilityNPU_Metadata_No_Throw = OVBlobCompatibilityNPU;--#define NO_APPEND_EXPORT(ASSERT_TYPE, ...)-#define APPEND_EXPORT(ASSERT_TYPE) \- std::shared_ptr<ov::Model> nullModel(nullptr); \- ov::CompiledModel compiledModel; \- config.emplace(ov::hint::compiled_blob(ov::read_tensor_data(blobPath))); \- ASSERT_TYPE(compiledModel = core.compile_model(nullModel, target_device, config)); \- config.erase(ov::hint::compiled_blob.name()); \- std::ostringstream outBlobStream; \- ASSERT_TYPE(compiledModel.export_model(outBlobStream)); \- EXPECT_TRUE(outBlobStream.tellp() > 0);--#define APPEND_EXPORT_HELPER_(arg1, arg2, arg3, ...) arg3-#define APPEND_EXPORT_HELPER(...) APPEND_EXPORT_HELPER_(__VA_ARGS__, NO_APPEND_EXPORT, APPEND_EXPORT)(__VA_ARGS__)--#define DEFAULT_TEST_BODY(ASSERT_TYPE, ...) \- std::ifstream blobStream(blobPath, std::ios::binary | std::ios::in); \- config.emplace(ov::weights_path(weightsPath)); \- ASSERT_TYPE(core.import_model(blobStream, target_device, config), ##__VA_ARGS__); \- APPEND_EXPORT_HELPER(ASSERT_TYPE, ##__VA_ARGS__)--TEST_P(OVBlobCompatibilityNPU, CanImportAllPrecompiledBlobsForAllOVVersionsAndDrivers) {- DEFAULT_TEST_BODY(OV_ASSERT_NO_THROW);-}--TEST_P(compatibility_OVBlobCompatibilityNPU_PV_Driver_No_Throw, CanImportExpectedModelsForPVDriverAndAllOVVersions) {- size_t mtlPlatformPos = std::string::npos;- const char slashDelimiter = '/';- const char backSlashDelimiter = '\\';- size_t lastSlashDelim = blobPath.find_last_of(slashDelimiter);- size_t lastBackSlashDelim = blobPath.find_last_of(backSlashDelimiter);- if (lastSlashDelim != std::string::npos && lastBackSlashDelim != std::string::npos) {- mtlPlatformPos = blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), std::max(lastSlashDelim, lastBackSlashDelim));- } else {- mtlPlatformPos = blobPath.find(slashDelimiter) != std::string::npos- ? blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), blobPath.rfind(slashDelimiter))- : blobPath.find(backSlashDelimiter) != std::string::npos- ? blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL), blobPath.rfind(backSlashDelimiter))- : blobPath.find(PLATFORMS.at(E_PLATFORMS::MTL));- }- if (mtlPlatformPos == std::string::npos) {- GTEST_SKIP() << "PV driver blob tests designed for NPU3720";- }- DEFAULT_TEST_BODY(OV_ASSERT_NO_THROW);-}--#undef NO_APPEND_EXPORT-#undef APPEND_EXPORT-#undef APPEND_EXPORT_HELPER_-#undef APPEND_EXPORT_HELPER-#undef DEFAULT_TEST_BODY--} // namespace behavior--} // namespace test--} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cppindex 58ba7971eee..c28affaab6a 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.cpp@@ -2,9 +2,401 @@// SPDX-License-Identifier: Apache-2.0//-#include "compatibility_string.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <mutex>+#include <openvino/runtime/intel_npu/properties.hpp>+#include "behavior/compiled_model/properties.hpp"#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "openvino/pass/serialize.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov::test::behavior {++// Tests specific for RUNTIME_REQUIREMENTS and COMPATIBILITY_CHECK properties+class ClassCompatibilityStringTestNPU : public OVCompiledModelPropertiesBase,+ public ::testing::WithParamInterface<std::string> {+protected:+ std::string deviceName;+ ov::Core core;++private:+ std::optional<utils::LoggerLevelGuard> _logGuard;++public:+ void SetUp() override {+ _logGuard.emplace(::intel_npu::Logger::global().level());+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ OVCompiledModelPropertiesBase::SetUp();+ deviceName = GetParam();+ }++ void TearDown() override {+ _logGuard.reset();+ OVCompiledModelPropertiesBase::TearDown();+ }+ static std::string getTestCaseName(testing::TestParamInfo<std::string> obj) {+ auto targetDevice = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ std::ostringstream result;+ static uint8_t testCounter = 0;+ result << "_testCounter="+ << std::to_string(testCounter++) + "_"; // used to avoid same names for different tests+ result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";+ result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);+ return result.str();+ }+};++using ClassCompatibilityStringTestSuite = ClassCompatibilityStringTestNPU;++TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckIsSupported) {+ std::vector<ov::PropertyName> properties;++ // Forcing CIP as the current compiler type+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));++ {+ OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());+ }++ // Forcing CID as the current compiler type+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER));++ // Test that COMPATIBILITY_CHECK is still present in supported properties when CID is used as the current compiler+ // type Even if CID does not support the option, the property should be marked as supported since the plugin will+ // fallback to CIP+ {+ OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);+ ASSERT_TRUE(it != properties.cend());+ }+}++TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckInvalidArgument) {+ // Forcing CIP as the current compiler type+ ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check));+ ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);++ // Provide an argument without runtime_requirements+ OV_ASSERT_NO_THROW(result =+ core.get_property(deviceName, ov::compatibility_check, ov::log::level(ov::log::Level::ERR)));+ ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);++ // An incorrect runtime_requirements argument should return UNSUPPORTED+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName,+ ov::compatibility_check,+ std::make_pair(ov::runtime_requirements.name(), "invalid_string")));+ ASSERT_TRUE(result == ov::CompatibilityCheck::UNSUPPORTED);+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsSupported) {+ // Forcing CIP as the current compiler type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;++ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));++ std::vector<ov::PropertyName> properties;+ // Test that RUNTIME_REQUIREMENTS is supported for a model compiled with CIP+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());+ OV_ASSERT_NO_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements));++ OV_ASSERT_NO_THROW(compiledModel =+ core.compile_model(model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::bypass_umd_caching(true)}));+ // Test that RUNTIME_REQUIREMENTS is supported for CID when the L0 graph extension version >= 1.16,+ // and unsupported for earlier driver versions. CIP always supports it.+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);+ if (driverHandlesCompatibilityCheck) {+ ASSERT_TRUE(it != properties.cend());+ } else {+ ASSERT_TRUE(it == properties.cend());+ }+ // #E224500 workaround until driver fix+ compiledModel = {};+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsValueIsReadableWhenSupported) {+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;++ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));++ std::vector<ov::PropertyName> properties;+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());++ std::string requirements;+ OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));+ ASSERT_FALSE(requirements.empty());++ OV_ASSERT_NO_THROW(compiledModel =+ core.compile_model(model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::bypass_umd_caching(true)}));++ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);+ if (driverHandlesCompatibilityCheck) {+ OV_ASSERT_NO_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements));+ } else {+ OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements),+ ov::Exception,+ testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));+ }+ // #E224500 workaround until driver fix+ compiledModel = {};+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsNotSupportedForWS) {+ // Preparing the model for the test+ std::stringstream model_xml, model_bin;+ {+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime information+ // of constant nodes+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::pass::Serialize serializer(model_xml, model_bin);+ serializer.run_on_model(model);+ }+ auto model_bin_str = model_bin.str();+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());+ auto model = core.read_model(model_xml.str(), model_weights);++ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU))),+ ov::enable_weightless(true)}));++ std::vector<ov::PropertyName> properties;+ // Test that RUNTIME_REQUIREMENTS is not supported for a weightless model+ OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements),+ ov::Exception,+ testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));++ // Test that RUNTIME_REQUIREMENTS is not in the list of supported properties either+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it == properties.cend());+}++TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImport) {+ // Forcing CIP as the current compiler type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));+ std::string reference_requirements;+ OV_ASSERT_NO_THROW(reference_requirements = compiledModel.get_property(ov::runtime_requirements));++ std::stringstream compiled_blob;+ OV_ASSERT_NO_THROW(compiledModel.export_model(compiled_blob));++ OV_ASSERT_NO_THROW(compiledModel = {});+ OV_ASSERT_NO_THROW(compiledModel = core.import_model(compiled_blob, deviceName));++ std::vector<ov::PropertyName> properties;+ // Test that RUNTIME_REQUIREMENTS is supported for an imported model as well+ OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));+ auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);+ ASSERT_TRUE(it != properties.cend());+ std::string imported_requirements;+ OV_ASSERT_NO_THROW(imported_requirements = compiledModel.get_property(ov::runtime_requirements));++ // The equality must be guaranteed for a given openvino version+ // If the blob was exported with a different OV version, requirements might differ+ ASSERT_EQ(reference_requirements, imported_requirements);+}++TEST_P(ClassCompatibilityStringTestSuite, CompatibilityStringGenerateAndCheck) {+ // Forcing CIP as the current compiler type+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(+ model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));++ std::string requirements;+ OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));+ ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName,+ ov::compatibility_check,+ std::make_pair(ov::runtime_requirements.name(), requirements)));+ ASSERT_TRUE(result == ov::CompatibilityCheck::SUPPORTED);+}++using CompatibilityCheckFallbackTestSuite = ClassCompatibilityStringTestNPU;++TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckIsReadOnly) {+ std::string logs;+ std::mutex logs_mutex;+ ov::AnyMap compatibilityCheckProperty = {{ov::compatibility_check.name(), ov::Any(ov::AnyMap{})}};++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ core.get_property(deviceName, ov::intel_npu::compiler_type); // initialize plugin with runtime property++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));++ // Determine at runtime whether the driver version is sufficient to handle the+ // compatibility check without falling back to PluginCompilerAdapter.+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);++ auto original_level = core.get_property(deviceName, ov::log::level);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_EXPECT_THROW_HAS_SUBSTRING(core.set_property(deviceName, compatibilityCheckProperty),+ ov::Exception,+ "READ-ONLY");+ }+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ if (driverHandlesCompatibilityCheck) {+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ } else {+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ }+}++TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckUsesPluginCompilerFallbackForOlderDriver) {+ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));++ // Determine at runtime whether the driver version is sufficient to handle the+ // compatibility check without falling back to PluginCompilerAdapter.+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);++ auto original_level = core.get_property(deviceName, ov::log::level);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW((void)core.get_property(deviceName, ov::compatibility_check));+ }+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ if (driverHandlesCompatibilityCheck) {+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ } else {+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ }+}++TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckSupportedPropertiesLoadsPluginCompiler) {+ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));++ // Determine at runtime whether the driver version is sufficient to handle the+ // compatibility check without falling back to PluginCompilerAdapter.+ const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);++ auto original_level = core.get_property(deviceName, ov::log::level);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ auto supported_props = core.get_property(deviceName, ov::supported_properties);+ auto it = std::find(supported_props.begin(), supported_props.end(), ov::compatibility_check.name());+ ASSERT_NE(it, supported_props.end());+ }+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));++ if (driverHandlesCompatibilityCheck) {+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ } else {+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ }+}++TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckAcceptsEmptyString) {+ // Empty descriptor means that there are no runtime requirements+ // No E2E test reaches this branch because compilation never produces an empty descriptor+ ov::CompatibilityCheck result = ov::CompatibilityCheck::SUPPORTED;+ OV_ASSERT_NO_THROW(result = core.get_property(deviceName,+ ov::compatibility_check,+ std::make_pair(ov::runtime_requirements.name(), "")));+ ASSERT_EQ(result, ov::CompatibilityCheck::NOT_APPLICABLE);+}++} // namespace ov::test::behaviorusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hppdeleted file mode 100644index f87c84b7a99..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/compatibility_string.hpp+++ /dev/null@@ -1,402 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <memory>-#include <mutex>-#include <openvino/runtime/intel_npu/properties.hpp>--#include "behavior/compiled_model/properties.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "openvino/pass/serialize.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov::test::behavior {--// Tests specific for RUNTIME_REQUIREMENTS and COMPATIBILITY_CHECK properties-class ClassCompatibilityStringTestNPU : public OVCompiledModelPropertiesBase,- public ::testing::WithParamInterface<std::string> {-protected:- std::string deviceName;- ov::Core core;--private:- std::optional<utils::LoggerLevelGuard> _logGuard;--public:- void SetUp() override {- _logGuard.emplace(::intel_npu::Logger::global().level());- SKIP_IF_CURRENT_TEST_IS_DISABLED();- OVCompiledModelPropertiesBase::SetUp();- deviceName = GetParam();- }-- void TearDown() override {- _logGuard.reset();- OVCompiledModelPropertiesBase::TearDown();- }- static std::string getTestCaseName(testing::TestParamInfo<std::string> obj) {- auto targetDevice = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- std::ostringstream result;- static uint8_t testCounter = 0;- result << "_testCounter="- << std::to_string(testCounter++) + "_"; // used to avoid same names for different tests- result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";- result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);- return result.str();- }-};--using ClassCompatibilityStringTestSuite = ClassCompatibilityStringTestNPU;--TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckIsSupported) {- std::vector<ov::PropertyName> properties;-- // Forcing CIP as the current compiler type- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));-- {- OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);- ASSERT_TRUE(it != properties.cend());- ASSERT_FALSE(it->is_mutable());- }-- // Forcing CID as the current compiler type- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER));-- // Test that COMPATIBILITY_CHECK is still present in supported properties when CID is used as the current compiler- // type Even if CID does not support the option, the property should be marked as supported since the plugin will- // fallback to CIP- {- OV_ASSERT_NO_THROW(properties = core.get_property(deviceName, ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::compatibility_check);- ASSERT_TRUE(it != properties.cend());- }-}--TEST_P(ClassCompatibilityStringTestSuite, CompatibilityCheckInvalidArgument) {- // Forcing CIP as the current compiler type- ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;- OV_ASSERT_NO_THROW(result = core.get_property(deviceName, ov::compatibility_check));- ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);-- // Provide an argument without runtime_requirements- OV_ASSERT_NO_THROW(result =- core.get_property(deviceName, ov::compatibility_check, ov::log::level(ov::log::Level::ERR)));- ASSERT_TRUE(result == ov::CompatibilityCheck::NOT_APPLICABLE);-- // An incorrect runtime_requirements argument should return UNSUPPORTED- OV_ASSERT_NO_THROW(result = core.get_property(deviceName,- ov::compatibility_check,- std::make_pair(ov::runtime_requirements.name(), "invalid_string")));- ASSERT_TRUE(result == ov::CompatibilityCheck::UNSUPPORTED);-}--TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsSupported) {- // Forcing CIP as the current compiler type- auto model = ov::test::utils::make_conv_pool_relu();- ov::CompiledModel compiledModel;-- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(- model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- ov::intel_npu::platform(ov::intel_npu::Platform::standardize(- ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));-- std::vector<ov::PropertyName> properties;- // Test that RUNTIME_REQUIREMENTS is supported for a model compiled with CIP- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- ASSERT_TRUE(it != properties.cend());- ASSERT_FALSE(it->is_mutable());- OV_ASSERT_NO_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements));-- OV_ASSERT_NO_THROW(compiledModel =- core.compile_model(model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::bypass_umd_caching(true)}));- // Test that RUNTIME_REQUIREMENTS is supported for CID when the L0 graph extension version >= 1.16,- // and unsupported for earlier driver versions. CIP always supports it.- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);- if (driverHandlesCompatibilityCheck) {- ASSERT_TRUE(it != properties.cend());- } else {- ASSERT_TRUE(it == properties.cend());- }- // #E224500 workaround until driver fix- compiledModel = {};-}--TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsValueIsReadableWhenSupported) {- auto model = ov::test::utils::make_conv_pool_relu();- ov::CompiledModel compiledModel;-- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(- model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- ov::intel_npu::platform(ov::intel_npu::Platform::standardize(- ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));-- std::vector<ov::PropertyName> properties;- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- ASSERT_TRUE(it != properties.cend());-- std::string requirements;- OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));- ASSERT_FALSE(requirements.empty());-- OV_ASSERT_NO_THROW(compiledModel =- core.compile_model(model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::bypass_umd_caching(true)}));-- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);- if (driverHandlesCompatibilityCheck) {- OV_ASSERT_NO_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements));- } else {- OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements),- ov::Exception,- testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));- }- // #E224500 workaround until driver fix- compiledModel = {};-}--TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsIsNotSupportedForWS) {- // Preparing the model for the test- std::stringstream model_xml, model_bin;- {- // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime information- // of constant nodes- auto model = ov::test::utils::make_conv_pool_relu();- ov::pass::Serialize serializer(model_xml, model_bin);- serializer.run_on_model(model);- }- auto model_bin_str = model_bin.str();- ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});- std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());- auto model = core.read_model(model_xml.str(), model_weights);-- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(- model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- ov::intel_npu::platform(ov::intel_npu::Platform::standardize(- ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU))),- ov::enable_weightless(true)}));-- std::vector<ov::PropertyName> properties;- // Test that RUNTIME_REQUIREMENTS is not supported for a weightless model- OV_EXPECT_THROW(auto requirements = compiledModel.get_property(ov::runtime_requirements),- ov::Exception,- testing::HasSubstr("Unsupported configuration key: RUNTIME_REQUIREMENTS"));-- // Test that RUNTIME_REQUIREMENTS is not in the list of supported properties either- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- ASSERT_TRUE(it == properties.cend());-}--TEST_P(ClassCompatibilityStringTestSuite, RuntimeRequirementsExportImport) {- // Forcing CIP as the current compiler type- auto model = ov::test::utils::make_conv_pool_relu();- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(- model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- ov::intel_npu::platform(ov::intel_npu::Platform::standardize(- ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));- std::string reference_requirements;- OV_ASSERT_NO_THROW(reference_requirements = compiledModel.get_property(ov::runtime_requirements));-- std::stringstream compiled_blob;- OV_ASSERT_NO_THROW(compiledModel.export_model(compiled_blob));-- OV_ASSERT_NO_THROW(compiledModel = {});- OV_ASSERT_NO_THROW(compiledModel = core.import_model(compiled_blob, deviceName));-- std::vector<ov::PropertyName> properties;- // Test that RUNTIME_REQUIREMENTS is supported for an imported model as well- OV_ASSERT_NO_THROW(properties = compiledModel.get_property(ov::supported_properties));- auto it = find(properties.cbegin(), properties.cend(), ov::runtime_requirements);- ASSERT_TRUE(it != properties.cend());- std::string imported_requirements;- OV_ASSERT_NO_THROW(imported_requirements = compiledModel.get_property(ov::runtime_requirements));-- // The equality must be guaranteed for a given openvino version- // If the blob was exported with a different OV version, requirements might differ- ASSERT_EQ(reference_requirements, imported_requirements);-}--TEST_P(ClassCompatibilityStringTestSuite, CompatibilityStringGenerateAndCheck) {- // Forcing CIP as the current compiler type- auto model = ov::test::utils::make_conv_pool_relu();- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(- model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),- ov::intel_npu::platform(ov::intel_npu::Platform::standardize(- ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}));-- std::string requirements;- OV_ASSERT_NO_THROW(requirements = compiledModel.get_property(ov::runtime_requirements));- ov::CompatibilityCheck result = ov::CompatibilityCheck::NOT_APPLICABLE;- OV_ASSERT_NO_THROW(result = core.get_property(deviceName,- ov::compatibility_check,- std::make_pair(ov::runtime_requirements.name(), requirements)));- ASSERT_TRUE(result == ov::CompatibilityCheck::SUPPORTED);-}--using CompatibilityCheckFallbackTestSuite = ClassCompatibilityStringTestNPU;--TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckIsReadOnly) {- std::string logs;- std::mutex logs_mutex;- ov::AnyMap compatibilityCheckProperty = {{ov::compatibility_check.name(), ov::Any(ov::AnyMap{})}};-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- core.get_property(deviceName, ov::intel_npu::compiler_type); // initialize plugin with runtime property-- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));-- // Determine at runtime whether the driver version is sufficient to handle the- // compatibility check without falling back to PluginCompilerAdapter.- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);-- auto original_level = core.get_property(deviceName, ov::log::level);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_EXPECT_THROW_HAS_SUBSTRING(core.set_property(deviceName, compatibilityCheckProperty),- ov::Exception,- "READ-ONLY");- }- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- if (driverHandlesCompatibilityCheck) {- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- } else {- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- }-}--TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckUsesPluginCompilerFallbackForOlderDriver) {- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));-- // Determine at runtime whether the driver version is sufficient to handle the- // compatibility check without falling back to PluginCompilerAdapter.- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);-- auto original_level = core.get_property(deviceName, ov::log::level);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW((void)core.get_property(deviceName, ov::compatibility_check));- }- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- if (driverHandlesCompatibilityCheck) {- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- } else {- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- }-}--TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckSupportedPropertiesLoadsPluginCompiler) {- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));-- // Determine at runtime whether the driver version is sufficient to handle the- // compatibility check without falling back to PluginCompilerAdapter.- const auto initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);-- auto original_level = core.get_property(deviceName, ov::log::level);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(ov::log::Level::INFO)));- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- auto supported_props = core.get_property(deviceName, ov::supported_properties);- auto it = std::find(supported_props.begin(), supported_props.end(), ov::compatibility_check.name());- ASSERT_NE(it, supported_props.end());- }- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::log::level(original_level)));-- if (driverHandlesCompatibilityCheck) {- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- } else {- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- }-}--TEST_P(CompatibilityCheckFallbackTestSuite, CompatibilityCheckAcceptsEmptyString) {- // Empty descriptor means that there are no runtime requirements- // No E2E test reaches this branch because compilation never produces an empty descriptor- ov::CompatibilityCheck result = ov::CompatibilityCheck::SUPPORTED;- OV_ASSERT_NO_THROW(result = core.get_property(deviceName,- ov::compatibility_check,- std::make_pair(ov::runtime_requirements.name(), "")));- ASSERT_EQ(result, ov::CompatibilityCheck::NOT_APPLICABLE);-}--} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cppindex 3be9382431a..f16f7ebed12 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp@@ -2,13 +2,258 @@// SPDX-License-Identifier: Apache-2.0//-#include "import_export.hpp"-#include <gtest/gtest.h>+#include <behavior/compiled_model/import_export.hpp>#include <openvino/runtime/intel_npu/properties.hpp>+#include <sstream>+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "openvino/util/codec_xor.hpp"++namespace ov {++namespace test {++namespace behavior {++using OVCompiledGraphImportExportTestNPU = OVCompiledGraphImportExportTest;++TEST_P(OVCompiledGraphImportExportTestNPU, CanImportModelWithApplicationHeaderAndTensorAPI) {+ ov::Core core;+ const std::string_view headerView("<dummy_application_header>");+ const std::string_view suffixView("<dummy_application_suffix>");+ std::stringstream sstream;++ sstream.write(headerView.data(), headerView.size());+ {+ auto model = ov::test::utils::make_conv_pool_relu();+ core.compile_model(model, target_device, configuration).export_model(sstream);+ }++ // header tests, application correctly manages offsets+ {+ auto strSO = std::make_shared<std::string>(sstream.str());+ auto tensor = ov::Tensor(ov::element::u8,+ ov::Shape{strSO->size() - headerView.size()},+ strSO->data() + headerView.size());+ auto impl = ov::get_tensor_impl(tensor);+ impl._so = strSO;+ tensor = ov::make_tensor(impl);+ sstream.seekg(headerView.size(), std::ios::beg); // skip header++ OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration));+ OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(tensor, target_device, configuration));+ }++ // suffix tests, application correctly manages ov::Tensor offsets or disables metadata checking+ {+ sstream.write(suffixView.data(), suffixView.size());+ auto strSO = std::make_shared<std::string>(sstream.str());+ auto tensor = ov::Tensor(ov::element::u8,+ ov::Shape{strSO->size() - headerView.size() - suffixView.size()},+ strSO->data() + headerView.size());+ auto impl = ov::get_tensor_impl(tensor);+ impl._so = strSO;+ tensor = ov::make_tensor(impl);+ sstream.seekg(headerView.size(), std::ios::beg);++ configuration.emplace(ov::intel_npu::disable_version_check(true));+ OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration));+ configuration.erase(ov::intel_npu::disable_version_check.name());+ OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(tensor, target_device, configuration));+ sstream.seekg(headerView.size(), std::ios::beg);+ OV_EXPECT_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration),+ ov::Exception,+ testing::HasSubstr("metadata")); // OVNPU suffix cannot be parsed from metadata+ }+}++TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfRawBlobIfMultipleOfPageSize) {+ ov::Core core;+ std::stringstream sstream;++ auto rawBlobConfig = configuration;+ rawBlobConfig.emplace(ov::intel_npu::export_raw_blob(true));++ auto model = ov::test::utils::make_conv_pool_relu();+ core.compile_model(model, target_device, rawBlobConfig).export_model(sstream);++ std::size_t size = sstream.str().size();++ ASSERT_TRUE(size != 0) << "Size of the blob should be different from 0";+ ASSERT_TRUE(size % 4096 == 0) << "Size of the blob should be multiple of 4096";+}++TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfExportedModelIfMultipleOfPageSize) {+ ov::Core core;+ std::stringstream sstream;++ auto model = ov::test::utils::make_conv_pool_relu();+ core.compile_model(model, target_device, configuration).export_model(sstream);++ uint64_t size_of_blob;+ std::size_t size = sstream.str().size();++ sstream.seekg(size - std::streampos(5) /*MAGIC_BYTES*/ - sizeof(size_of_blob), std::ios::cur);+ sstream.read(reinterpret_cast<char*>(&size_of_blob), sizeof(size_of_blob));++ ASSERT_TRUE(size_of_blob != 0) << "Size of the blob shall be different from 0";+ ASSERT_TRUE(size_of_blob % 4096 == 0) << "Size of the blob shall be multiple of 4096";+}++TEST_P(OVCompiledGraphImportExportTestNPU, SameBlobAfterImportExport) {+ ov::Core core;+ std::stringstream blob_stream, test_blob_stream_1, test_blob_stream_2;++ auto model = ov::test::utils::make_conv_pool_relu();+ core.compile_model(model, target_device, configuration).export_model(blob_stream);+ configuration.insert(ov::intel_npu::defer_weights_load(true));++ core.import_model(blob_stream, target_device, configuration).export_model(test_blob_stream_1);+ ASSERT_EQ(blob_stream.str(), test_blob_stream_1.str());++ auto blob_str = blob_stream.str();+ ov::Tensor blob_tensor(ov::element::u8, ov::Shape{blob_str.size()}, blob_str.c_str());+ core.import_model(blob_tensor, target_device, configuration).export_model(test_blob_stream_2);+ ASSERT_EQ(blob_stream.str(), test_blob_stream_2.str());+}++TEST_P(OVCompiledGraphImportExportTestNPU, ImportingEncryptedBlobThrows) {+ // Encryption callbacks require L0 graph ext version >= 1.17+ NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);++ ov::Core core;+ std::stringstream encrypted_blob_stream;++ auto model = ov::test::utils::make_conv_pool_relu();+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));+ core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream);+ auto encrypted_blob_str = encrypted_blob_stream.str();+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());+ configuration.erase(ov::cache_encryption_callbacks.name());++ OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),+ ov::Exception,+ ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));++ OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),+ ov::Exception,+ ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));++ encrypted_blob_stream.seekg(0, std::ios::beg);++ // Parsing corrupted blob on MTL will throw Access Violation 0xC0000005 SEH exceptions+ if (ov::intel_npu::Platform::standardize(ov::test::utils::getTestPlatform()) != ov::intel_npu::Platform::NPU3720) {+ configuration.insert(ov::intel_npu::import_raw_blob(true));+ OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),+ ov::Exception,+ ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));++ OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),+ ov::Exception,+ ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));+ }+}++TEST_P(OVCompiledGraphImportExportTestNPU, SameUnencryptedBlobAfterDecryption) {+ ov::Core core;+ std::stringstream unencrypted_blob_stream, encrypted_blob_stream, decrypted_blob_stream;++ auto model = ov::test::utils::make_conv_pool_relu();+ core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);+ configuration.insert(+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor}));+ configuration.insert(ov::intel_npu::defer_weights_load(true));+ core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);+ configuration.erase(ov::cache_encryption_callbacks.name());+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));++ core.import_model(encrypted_blob_stream, target_device, configuration).export_model(decrypted_blob_stream);+ ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());++ decrypted_blob_stream.str(std::string());+ auto encrypted_blob_str = encrypted_blob_stream.str();+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());+ core.import_model(encrypted_blob_tensor, target_device, configuration).export_model(decrypted_blob_stream);+ ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());+}++TEST_P(OVCompiledGraphImportExportTestNPU, SameEncryptedBlobViaExportAndManualFunctionCall) {+ ov::Core core;+ std::stringstream unencrypted_blob_stream, encrypted_blob_stream;++ auto model = ov::test::utils::make_conv_pool_relu();+ // metadata is not encrypted, exclude it from blob+ configuration.insert(ov::intel_npu::import_raw_blob(true));+ configuration.insert(ov::intel_npu::export_raw_blob(true));++ configuration.insert(ov::intel_npu::defer_weights_load(true));++ core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));+ core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);++ std::string manual_encrypted_blob_str = ov::util::codec_xor(unencrypted_blob_stream.str());+ std::string encrypted_blob_str = encrypted_blob_stream.str();++ ASSERT_EQ(manual_encrypted_blob_str, encrypted_blob_str);+}++TEST_P(OVCompiledGraphImportExportTestNPU, DifferentSizesOfEncryptedVsDecryptedBlobWorks) {+ // Encryption callbacks require L0 graph ext version >= 1.17+ NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);++ ov::Core core;+ std::stringstream encrypted_blob_stream;++ std::stringstream model_xml, model_bin;+ {+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime information+ // of constant nodes+ auto model = ov::test::utils::make_conv_pool_relu();+ ov::pass::Serialize serializer(model_xml, model_bin);+ serializer.run_on_model(model);+ }+ auto model_bin_str = model_bin.str();+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());+ auto model = core.read_model(model_xml.str(), model_weights);++ configuration.insert(ov::cache_encryption_callbacks(+ ov::EncryptionCallbacks{[](const std::string& unencrypted_blob) {+ std::string copy_blob = unencrypted_blob;+ copy_blob += "<application_flag_to_mark_encryption>";+ return ov::util::codec_xor(copy_blob);+ },+ [](const std::string& encrypted_blob) {+ std::string decrypted_blob = ov::util::codec_xor(encrypted_blob);+ decrypted_blob += "<application_flag_to_mark_decryption>";+ return decrypted_blob;+ }}));++ auto supported_properties = core.get_property(target_device, ov::supported_properties);+ if (std::find(supported_properties.begin(), supported_properties.end(), ov::enable_weightless.name()) !=+ supported_properties.end()) {+ configuration.insert(ov::enable_weightless(true));+ }+ OV_ASSERT_NO_THROW(core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream));++ auto encrypted_blob_str = encrypted_blob_stream.str();+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());+ OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_stream, target_device, configuration));+ OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration));+}++} // namespace behavior++} // namespace test++} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hppdeleted file mode 100644index 47bbe294e55..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp+++ /dev/null@@ -1,255 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <behavior/compiled_model/import_export.hpp>-#include <sstream>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "openvino/util/codec_xor.hpp"--namespace ov {--namespace test {--namespace behavior {--using OVCompiledGraphImportExportTestNPU = OVCompiledGraphImportExportTest;--TEST_P(OVCompiledGraphImportExportTestNPU, CanImportModelWithApplicationHeaderAndTensorAPI) {- ov::Core core;- const std::string_view headerView("<dummy_application_header>");- const std::string_view suffixView("<dummy_application_suffix>");- std::stringstream sstream;-- sstream.write(headerView.data(), headerView.size());- {- auto model = ov::test::utils::make_conv_pool_relu();- core.compile_model(model, target_device, configuration).export_model(sstream);- }-- // header tests, application correctly manages offsets- {- auto strSO = std::make_shared<std::string>(sstream.str());- auto tensor = ov::Tensor(ov::element::u8,- ov::Shape{strSO->size() - headerView.size()},- strSO->data() + headerView.size());- auto impl = ov::get_tensor_impl(tensor);- impl._so = strSO;- tensor = ov::make_tensor(impl);- sstream.seekg(headerView.size(), std::ios::beg); // skip header-- OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration));- OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(tensor, target_device, configuration));- }-- // suffix tests, application correctly manages ov::Tensor offsets or disables metadata checking- {- sstream.write(suffixView.data(), suffixView.size());- auto strSO = std::make_shared<std::string>(sstream.str());- auto tensor = ov::Tensor(ov::element::u8,- ov::Shape{strSO->size() - headerView.size() - suffixView.size()},- strSO->data() + headerView.size());- auto impl = ov::get_tensor_impl(tensor);- impl._so = strSO;- tensor = ov::make_tensor(impl);- sstream.seekg(headerView.size(), std::ios::beg);-- configuration.emplace(ov::intel_npu::disable_version_check(true));- OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration));- configuration.erase(ov::intel_npu::disable_version_check.name());- OV_ASSERT_NO_THROW(auto compiledModel = core.import_model(tensor, target_device, configuration));- sstream.seekg(headerView.size(), std::ios::beg);- OV_EXPECT_THROW(auto compiledModel = core.import_model(sstream, target_device, configuration),- ov::Exception,- testing::HasSubstr("metadata")); // OVNPU suffix cannot be parsed from metadata- }-}--TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfRawBlobIfMultipleOfPageSize) {- ov::Core core;- std::stringstream sstream;-- auto rawBlobConfig = configuration;- rawBlobConfig.emplace(ov::intel_npu::export_raw_blob(true));-- auto model = ov::test::utils::make_conv_pool_relu();- core.compile_model(model, target_device, rawBlobConfig).export_model(sstream);-- std::size_t size = sstream.str().size();-- ASSERT_TRUE(size != 0) << "Size of the blob should be different from 0";- ASSERT_TRUE(size % 4096 == 0) << "Size of the blob should be multiple of 4096";-}--TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfExportedModelIfMultipleOfPageSize) {- ov::Core core;- std::stringstream sstream;-- auto model = ov::test::utils::make_conv_pool_relu();- core.compile_model(model, target_device, configuration).export_model(sstream);-- uint64_t size_of_blob;- std::size_t size = sstream.str().size();-- sstream.seekg(size - std::streampos(5) /*MAGIC_BYTES*/ - sizeof(size_of_blob), std::ios::cur);- sstream.read(reinterpret_cast<char*>(&size_of_blob), sizeof(size_of_blob));-- ASSERT_TRUE(size_of_blob != 0) << "Size of the blob shall be different from 0";- ASSERT_TRUE(size_of_blob % 4096 == 0) << "Size of the blob shall be multiple of 4096";-}--TEST_P(OVCompiledGraphImportExportTestNPU, SameBlobAfterImportExport) {- ov::Core core;- std::stringstream blob_stream, test_blob_stream_1, test_blob_stream_2;-- auto model = ov::test::utils::make_conv_pool_relu();- core.compile_model(model, target_device, configuration).export_model(blob_stream);- configuration.insert(ov::intel_npu::defer_weights_load(true));-- core.import_model(blob_stream, target_device, configuration).export_model(test_blob_stream_1);- ASSERT_EQ(blob_stream.str(), test_blob_stream_1.str());-- auto blob_str = blob_stream.str();- ov::Tensor blob_tensor(ov::element::u8, ov::Shape{blob_str.size()}, blob_str.c_str());- core.import_model(blob_tensor, target_device, configuration).export_model(test_blob_stream_2);- ASSERT_EQ(blob_stream.str(), test_blob_stream_2.str());-}--TEST_P(OVCompiledGraphImportExportTestNPU, ImportingEncryptedBlobThrows) {- // Encryption callbacks require L0 graph ext version >= 1.17- NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);-- ov::Core core;- std::stringstream encrypted_blob_stream;-- auto model = ov::test::utils::make_conv_pool_relu();- configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));- core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream);- auto encrypted_blob_str = encrypted_blob_stream.str();- ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());- configuration.erase(ov::cache_encryption_callbacks.name());-- OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),- ov::Exception,- ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));-- OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),- ov::Exception,- ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));-- encrypted_blob_stream.seekg(0, std::ios::beg);-- // Parsing corrupted blob on MTL will throw Access Violation 0xC0000005 SEH exceptions- if (ov::intel_npu::Platform::standardize(ov::test::utils::getTestPlatform()) != ov::intel_npu::Platform::NPU3720) {- configuration.insert(ov::intel_npu::import_raw_blob(true));- OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),- ov::Exception,- ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));-- OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),- ov::Exception,- ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));- }-}--TEST_P(OVCompiledGraphImportExportTestNPU, SameUnencryptedBlobAfterDecryption) {- ov::Core core;- std::stringstream unencrypted_blob_stream, encrypted_blob_stream, decrypted_blob_stream;-- auto model = ov::test::utils::make_conv_pool_relu();- core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);- configuration.insert(- ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor}));- configuration.insert(ov::intel_npu::defer_weights_load(true));- core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);- configuration.erase(ov::cache_encryption_callbacks.name());- configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));-- core.import_model(encrypted_blob_stream, target_device, configuration).export_model(decrypted_blob_stream);- ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());-- decrypted_blob_stream.str(std::string());- auto encrypted_blob_str = encrypted_blob_stream.str();- ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());- core.import_model(encrypted_blob_tensor, target_device, configuration).export_model(decrypted_blob_stream);- ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());-}--TEST_P(OVCompiledGraphImportExportTestNPU, SameEncryptedBlobViaExportAndManualFunctionCall) {- ov::Core core;- std::stringstream unencrypted_blob_stream, encrypted_blob_stream;-- auto model = ov::test::utils::make_conv_pool_relu();- // metadata is not encrypted, exclude it from blob- configuration.insert(ov::intel_npu::import_raw_blob(true));- configuration.insert(ov::intel_npu::export_raw_blob(true));-- configuration.insert(ov::intel_npu::defer_weights_load(true));-- core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);- configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));- core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);-- std::string manual_encrypted_blob_str = ov::util::codec_xor(unencrypted_blob_stream.str());- std::string encrypted_blob_str = encrypted_blob_stream.str();-- ASSERT_EQ(manual_encrypted_blob_str, encrypted_blob_str);-}--TEST_P(OVCompiledGraphImportExportTestNPU, DifferentSizesOfEncryptedVsDecryptedBlobWorks) {- // Encryption callbacks require L0 graph ext version >= 1.17- NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);-- ov::Core core;- std::stringstream encrypted_blob_stream;-- std::stringstream model_xml, model_bin;- {- // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime information- // of constant nodes- auto model = ov::test::utils::make_conv_pool_relu();- ov::pass::Serialize serializer(model_xml, model_bin);- serializer.run_on_model(model);- }- auto model_bin_str = model_bin.str();- ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});- std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());- auto model = core.read_model(model_xml.str(), model_weights);-- configuration.insert(ov::cache_encryption_callbacks(- ov::EncryptionCallbacks{[](const std::string& unencrypted_blob) {- std::string copy_blob = unencrypted_blob;- copy_blob += "<application_flag_to_mark_encryption>";- return ov::util::codec_xor(copy_blob);- },- [](const std::string& encrypted_blob) {- std::string decrypted_blob = ov::util::codec_xor(encrypted_blob);- decrypted_blob += "<application_flag_to_mark_decryption>";- return decrypted_blob;- }}));-- auto supported_properties = core.get_property(target_device, ov::supported_properties);- if (std::find(supported_properties.begin(), supported_properties.end(), ov::enable_weightless.name()) !=- supported_properties.end()) {- configuration.insert(ov::enable_weightless(true));- }- OV_ASSERT_NO_THROW(core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream));-- auto encrypted_blob_str = encrypted_blob_stream.str();- ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());- OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_stream, target_device, configuration));- OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration));-}--} // namespace behavior--} // namespace test--} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cppindex 9137a48c5c5..4f67bcb2676 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp@@ -2,11 +2,222 @@// SPDX-License-Identifier: Apache-2.0//-#include "model_cache.hpp"-#include <gtest/gtest.h>+#include <memory>++#include <behavior/compiled_model/model_cache.hpp>#include "common/utils.hpp"+#include "common_test_utils/test_assertions.hpp"+#include "functional_test_utils/skip_tests_config.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "openvino/core/model_util.hpp"+#include "openvino/core/rt_info/weightless_caching_attributes.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/parameter.hpp"+#include "openvino/op/reshape.hpp"+#include "openvino/openvino.hpp"++namespace {++std::shared_ptr<ov::Model> createTestModel(const bool addWeightlessCacheAttribute = true,+ const bool alternativeWeights = false) {+ constexpr auto precision = ov::element::f32;++ const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;+ auto weights = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{5}, std::vector<float>{weightsValue});+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1});+ auto add = std::make_shared<ov::op::v1::Add>(input, weights);++ weights->set_friendly_name("weights");+ input->set_friendly_name("input");+ add->set_friendly_name("add");++ if (addWeightlessCacheAttribute) {+ weights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights->get_byte_size(), 0, weights->get_element_type());+ }++ auto model = std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{input}, "Simple with weights");+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});+ return model;+}++// This is a special model that has weightless constants that are guaranteed+// to be skipped by weights schedule. This tests cases where compiler+// produces "blob with weights" when "weightless blob" is requested: in+// theory, this may happen, and must not cause any errors.+std::shared_ptr<ov::Model> createTestModelWeightlessWithDummyConstants() {+ constexpr auto precision = ov::element::f32;++ const auto reshapeWeights =+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 2, 3});++ const auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{6});+ const auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 2, 3});+ const auto reshapedInput1 = std::make_shared<ov::op::v1::Reshape>(input1, reshapeWeights, /*special_zero=*/false);+ auto add = std::make_shared<ov::op::v1::Add>(reshapedInput1, input2);++ reshapeWeights->set_friendly_name("weights");+ input1->set_friendly_name("input1");+ input2->set_friendly_name("input2");+ reshapedInput1->set_friendly_name("reshapedInput1");+ add->set_friendly_name("add");++ // Note: Reshape weights with weightless cache attribute satisfy the+ // basic requirement to create weights schedule. However, since this is+ // a static reshape, these weights would "disappear" during compilation,+ // causing the compiler to put nothing into the weights schedule.+ reshapeWeights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(reshapeWeights->get_byte_size(), 0, reshapeWeights->get_element_type());++ auto model = std::make_shared<ov::Model>(ov::OutputVector{add},+ ov::ParameterVector{input1, input2},+ "Dummy weightless model");+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});+ return model;+}++/**+ * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.+ */+std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {+ ov::ParameterVector parameter_vector;+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(data);+ auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});+ auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);++ for (int i = 0; i < 10; i++) {+ auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(intermediate_input);+ add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});+ add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());+ add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);+ add = std::make_shared<ov::op::v1::Add>(add, add_constant);+ }++ return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);+}++// This is a special test model with multiple constants using the same weights buffer.+std::shared_ptr<ov::Model> createTestModelWeightlessWithDuplicateConstants() {+ const std::vector<float> sharedData{1.0f, 2.0f, 3.0f, 4.0f};+ constexpr auto precision = ov::element::f32;++ auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 1, 4});+ auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 4, 1});++ auto weights1 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 1, 4}, sharedData);+ auto multiply1 = std::make_shared<ov::op::v1::Multiply>(input1, weights1);++ auto weights2 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 4, 1}, sharedData);+ auto multiply2 = std::make_shared<ov::op::v1::Multiply>(input2, weights2);++ auto reshapeWeights =+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 4, 1});+ auto reshape = std::make_shared<ov::op::v1::Reshape>(multiply1, reshapeWeights, false);++ auto add = std::make_shared<ov::op::v1::Add>(reshape, multiply2);++ input1->set_friendly_name("input1");+ input2->set_friendly_name("input2");+ weights1->set_friendly_name("weights");+ multiply1->set_friendly_name("multiply1");+ weights2->set_friendly_name("weights_new_shape");+ multiply2->set_friendly_name("multiply2");+ reshapeWeights->set_friendly_name("reshapeWeights");+ reshape->set_friendly_name("reshape");+ add->set_friendly_name("add");++ // Note: if this offset is changed, compiled_model->export_model() =>+ // core->import_model() would fail as the weightless bin offset is+ // "reset" through this boundary; right now this is by design+ constexpr size_t theOnlyFunctioningBinOffset = 0;+ weights1->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights1->get_byte_size(),+ theOnlyFunctioningBinOffset,+ weights1->get_element_type());+ weights2->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights2->get_byte_size(),+ theOnlyFunctioningBinOffset,+ weights2->get_element_type());++ auto model = std::make_shared<ov::Model>(ov::OutputVector{add},+ ov::ParameterVector{input1, input2},+ "duplicate_weights_model");+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});+ return model;+}++} // namespace++namespace ov {++namespace test {++namespace behavior {++class OVWeightlessCacheAccuracyNPU : public WeightlessCacheAccuracy {+protected:+ void SetUp() override {+ WeightlessCacheAccuracy::SetUp();++ // Encryption not requested or secure compilation support is available+ // > Nothing to skip, continue with the test+ if (!m_do_encryption || !ov::test::utils::isGraphExtVersionLowerThan(1u, 17u)) {+ return;+ }++ // Encryption requested and secure compilation support is not available for DRIVER path+ // > Search compiler type in test config; for empty test config, check device default compiler+ // > Skip test for DRIVER compiler+ const auto& params = GetParam();+ const auto& config = std::get<4>(params);++ const auto it = config.find(ov::intel_npu::compiler_type.name());+ const bool testUsesDriverCompiler =+ (it != config.end()) ? (it->second.as<ov::intel_npu::CompilerType>() == ov::intel_npu::CompilerType::DRIVER)+ : ov::test::utils::isDefaultDriverCompiler(m_target_device);++ if (testUsesDriverCompiler) {+ GTEST_SKIP() << "Secure compilation is not supported by the current DRIVER compiler.";+ }+ }+};++TEST_P(OVWeightlessCacheAccuracyNPU, SimpleTestModel) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OV_ASSERT_NO_THROW(m_model = createTestModel());+ OV_ASSERT_NO_THROW(run());+}++TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDummyConstants) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDummyConstants());+ OV_ASSERT_NO_THROW(run());+}++TEST_P(OVWeightlessCacheAccuracyNPU, TestModelLightInitSchedule) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OV_ASSERT_NO_THROW(m_model = createTestModelLightInitSchedule());+ OV_ASSERT_NO_THROW(run());+}++TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDuplicateConstants) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDuplicateConstants());+ OV_ASSERT_NO_THROW(run());+}++} // namespace behavior++} // namespace test++} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hppdeleted file mode 100644index c0c71529cae..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hpp+++ /dev/null@@ -1,220 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <behavior/compiled_model/model_cache.hpp>-#include <memory>--#include "common/utils.hpp"-#include "common_test_utils/test_assertions.hpp"-#include "functional_test_utils/skip_tests_config.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "openvino/core/model_util.hpp"-#include "openvino/core/rt_info/weightless_caching_attributes.hpp"-#include "openvino/op/add.hpp"-#include "openvino/op/constant.hpp"-#include "openvino/op/multiply.hpp"-#include "openvino/op/parameter.hpp"-#include "openvino/op/reshape.hpp"-#include "openvino/openvino.hpp"--namespace {--std::shared_ptr<ov::Model> createTestModel(const bool addWeightlessCacheAttribute = true,- const bool alternativeWeights = false) {- constexpr auto precision = ov::element::f32;-- const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;- auto weights = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{5}, std::vector<float>{weightsValue});- auto input = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1});- auto add = std::make_shared<ov::op::v1::Add>(input, weights);-- weights->set_friendly_name("weights");- input->set_friendly_name("input");- add->set_friendly_name("add");-- if (addWeightlessCacheAttribute) {- weights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights->get_byte_size(), 0, weights->get_element_type());- }-- auto model = std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{input}, "Simple with weights");- ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});- return model;-}--// This is a special model that has weightless constants that are guaranteed-// to be skipped by weights schedule. This tests cases where compiler-// produces "blob with weights" when "weightless blob" is requested: in-// theory, this may happen, and must not cause any errors.-std::shared_ptr<ov::Model> createTestModelWeightlessWithDummyConstants() {- constexpr auto precision = ov::element::f32;-- const auto reshapeWeights =- std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 2, 3});-- const auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{6});- const auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 2, 3});- const auto reshapedInput1 = std::make_shared<ov::op::v1::Reshape>(input1, reshapeWeights, /*special_zero=*/false);- auto add = std::make_shared<ov::op::v1::Add>(reshapedInput1, input2);-- reshapeWeights->set_friendly_name("weights");- input1->set_friendly_name("input1");- input2->set_friendly_name("input2");- reshapedInput1->set_friendly_name("reshapedInput1");- add->set_friendly_name("add");-- // Note: Reshape weights with weightless cache attribute satisfy the- // basic requirement to create weights schedule. However, since this is- // a static reshape, these weights would "disappear" during compilation,- // causing the compiler to put nothing into the weights schedule.- reshapeWeights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(reshapeWeights->get_byte_size(), 0, reshapeWeights->get_element_type());-- auto model = std::make_shared<ov::Model>(ov::OutputVector{add},- ov::ParameterVector{input1, input2},- "Dummy weightless model");- ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});- return model;-}--/**- * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.- */-std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {- ov::ParameterVector parameter_vector;- auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});- parameter_vector.push_back(data);- auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});- auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);-- for (int i = 0; i < 10; i++) {- auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});- parameter_vector.push_back(intermediate_input);- add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});- add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());- add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);- add = std::make_shared<ov::op::v1::Add>(add, add_constant);- }-- return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);-}--// This is a special test model with multiple constants using the same weights buffer.-std::shared_ptr<ov::Model> createTestModelWeightlessWithDuplicateConstants() {- const std::vector<float> sharedData{1.0f, 2.0f, 3.0f, 4.0f};- constexpr auto precision = ov::element::f32;-- auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 1, 4});- auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 4, 1});-- auto weights1 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 1, 4}, sharedData);- auto multiply1 = std::make_shared<ov::op::v1::Multiply>(input1, weights1);-- auto weights2 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 4, 1}, sharedData);- auto multiply2 = std::make_shared<ov::op::v1::Multiply>(input2, weights2);-- auto reshapeWeights =- std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 4, 1});- auto reshape = std::make_shared<ov::op::v1::Reshape>(multiply1, reshapeWeights, false);-- auto add = std::make_shared<ov::op::v1::Add>(reshape, multiply2);-- input1->set_friendly_name("input1");- input2->set_friendly_name("input2");- weights1->set_friendly_name("weights");- multiply1->set_friendly_name("multiply1");- weights2->set_friendly_name("weights_new_shape");- multiply2->set_friendly_name("multiply2");- reshapeWeights->set_friendly_name("reshapeWeights");- reshape->set_friendly_name("reshape");- add->set_friendly_name("add");-- // Note: if this offset is changed, compiled_model->export_model() =>- // core->import_model() would fail as the weightless bin offset is- // "reset" through this boundary; right now this is by design- constexpr size_t theOnlyFunctioningBinOffset = 0;- weights1->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights1->get_byte_size(),- theOnlyFunctioningBinOffset,- weights1->get_element_type());- weights2->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights2->get_byte_size(),- theOnlyFunctioningBinOffset,- weights2->get_element_type());-- auto model = std::make_shared<ov::Model>(ov::OutputVector{add},- ov::ParameterVector{input1, input2},- "duplicate_weights_model");- ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});- return model;-}--} // namespace--namespace ov {--namespace test {--namespace behavior {--class OVWeightlessCacheAccuracyNPU : public WeightlessCacheAccuracy {-protected:- void SetUp() override {- WeightlessCacheAccuracy::SetUp();-- // Encryption not requested or secure compilation support is available- // > Nothing to skip, continue with the test- if (!m_do_encryption || !ov::test::utils::isGraphExtVersionLowerThan(1u, 17u)) {- return;- }-- // Encryption requested and secure compilation support is not available for DRIVER path- // > Search compiler type in test config; for empty test config, check device default compiler- // > Skip test for DRIVER compiler- const auto& params = GetParam();- const auto& config = std::get<4>(params);-- const auto it = config.find(ov::intel_npu::compiler_type.name());- const bool testUsesDriverCompiler =- (it != config.end()) ? (it->second.as<ov::intel_npu::CompilerType>() == ov::intel_npu::CompilerType::DRIVER)- : ov::test::utils::isDefaultDriverCompiler(m_target_device);-- if (testUsesDriverCompiler) {- GTEST_SKIP() << "Secure compilation is not supported by the current DRIVER compiler.";- }- }-};--TEST_P(OVWeightlessCacheAccuracyNPU, SimpleTestModel) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OV_ASSERT_NO_THROW(m_model = createTestModel());- OV_ASSERT_NO_THROW(run());-}--TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDummyConstants) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDummyConstants());- OV_ASSERT_NO_THROW(run());-}--TEST_P(OVWeightlessCacheAccuracyNPU, TestModelLightInitSchedule) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OV_ASSERT_NO_THROW(m_model = createTestModelLightInitSchedule());- OV_ASSERT_NO_THROW(run());-}--TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDuplicateConstants) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDuplicateConstants());- OV_ASSERT_NO_THROW(run());-}--} // namespace behavior--} // namespace test--} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cppindex ee4c44885b5..e3ddbfa95d6 100644--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp@@ -2,19 +2,910 @@// SPDX-License-Identifier: Apache-2.0//-#include "property.hpp"-+#include <memory>#include <openvino/runtime/intel_npu/properties.hpp>#include <openvino/util/codec_xor.hpp>#include <vector>+#include "behavior/compiled_model/properties.hpp"#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "openvino/core/log.hpp"+#include "zero_backend.hpp"using namespace ov::test::behavior;namespace {+bool has_non_negative_numeric_suffix(const std::string& value) {+ const auto dot_pos = value.find('.');+ if (dot_pos == std::string::npos || dot_pos + 1 >= value.size()) {+ return false;+ }++ const auto suffix = value.substr(dot_pos + 1);+ return std::all_of(suffix.begin(), suffix.end(), [](const char ch) {+ return ch >= '0' && ch <= '9';+ });+}++// ExecutableNetwork Properties tests+class ClassExecutableNetworkGetPropertiesTestNPU+ : public OVCompiledModelPropertiesBase,+ public ::testing::WithParamInterface<std::tuple<std::string, std::pair<std::string, ov::Any>>> {+protected:+ std::string deviceName;+ std::string configKey;+ ov::Any configValue;+ ov::Core ie;++private:+ std::optional<ov::test::utils::LoggerLevelGuard> _logGuard;++public:+ void SetUp() override {+ _logGuard.emplace(::intel_npu::Logger::global().level());+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ OVCompiledModelPropertiesBase::SetUp();++ deviceName = std::get<0>(GetParam());+ std::tie(configKey, configValue) = std::get<1>(GetParam());++ model = ov::test::utils::make_conv_pool_relu();+ }++ void TearDown() override {+ _logGuard.reset();+ OVCompiledModelPropertiesBase::TearDown();+ }+ static std::string getTestCaseName(+ testing::TestParamInfo<std::tuple<std::string, std::pair<std::string, ov::Any>>> obj) {+ std::string targetDevice;+ std::pair<std::string, ov::Any> configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ std::ostringstream result;+ static uint8_t testCounter = 0;+ result << "_testCounter=" << std::to_string(testCounter++)+ << "_"; // used to avoid same names for different tests+ result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";+ result << "config=(" << configuration.first << "=" << configuration.second.as<std::string>() << ")";+ result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ return result.str();+ }+};++// Plugin Properties tests+class ClassPluginPropertiesTestNPU+ : public OVCompiledModelPropertiesBase,+ public ::testing::WithParamInterface<std::tuple<std::string, std::pair<std::string, ov::Any>>> {+protected:+ std::string deviceName;+ std::string configKey;+ ov::Any configValue;+ ov::Core ie;++public:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ OVCompiledModelPropertiesBase::SetUp();+ deviceName = std::get<0>(GetParam());+ std::tie(configKey, configValue) = std::get<1>(GetParam());+ }+ static std::string getTestCaseName(+ testing::TestParamInfo<std::tuple<std::string, std::pair<std::string, ov::Any>>> obj) {+ std::string targetDevice;+ std::pair<std::string, ov::Any> configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ std::ostringstream result;+ static uint8_t testCounter = 0;+ result << "_testCounter="+ << std::to_string(testCounter++) + "_"; // used to avoid same names for different tests+ result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";+ result << "config=(" << configuration.first << "=" << configuration.second.as<std::string>() << ")";+ result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);+ return result.str();+ }+};++using ClassPluginPropertiesTestSuite0NPU = ClassPluginPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite0NPU, CanSetGetPublicMutableProperty) {+ std::vector<ov::PropertyName> properties;++ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));++ auto it = find(properties.cbegin(), properties.cend(), configKey);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_TRUE(it->is_mutable());++ OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));++ ov::Any retrieved_value;+ OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));++ ASSERT_EQ(retrieved_value.as<std::string>(), configValue.as<std::string>());+}++using ClassExecutableNetworkTestSuite1NPU = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(ClassExecutableNetworkTestSuite1NPU, PropertyIsSupportedAndImmutableAndGet) {+ std::vector<ov::PropertyName> properties;++ ov::CompiledModel exeNetwork = ie.compile_model(model, deviceName);+ OV_ASSERT_NO_THROW(properties = exeNetwork.get_property(ov::supported_properties));++ auto it = find(properties.cbegin(), properties.cend(), configKey);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());++ OV_ASSERT_NO_THROW(exeNetwork.get_property(configKey));+}++using ClassExecutableNetworkTestSuite2NPU = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(ClassExecutableNetworkTestSuite2NPU, PropertyIsSupportedAndImmutableAndCanNotSet) {+ std::vector<ov::PropertyName> properties;++ ov::CompiledModel exeNetwork = ie.compile_model(model, deviceName);+ OV_ASSERT_NO_THROW(properties = exeNetwork.get_property(ov::supported_properties));++ auto it = find(properties.cbegin(), properties.cend(), configKey);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());++ ASSERT_THROW(exeNetwork.set_property({{configKey, configValue}}), ov::Exception);+}++using ClassPluginPropertiesTestSuite1NPU = ClassPluginPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite1NPU, CanSetGetInternalMutableProperty) {+ OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));++ ov::Any retrieved_value;+ OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));++ ASSERT_EQ(retrieved_value.as<std::string>(), configValue.as<std::string>());+}++using ClassPluginPropertiesTestSuite2NPU = ClassPluginPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite2NPU, CanNotSetImmutableProperty) {+ std::vector<ov::PropertyName> properties;++ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));++ auto it = find(properties.cbegin(), properties.cend(), configKey);+ ASSERT_TRUE(it != properties.cend());+ ASSERT_FALSE(it->is_mutable());++ ov::Any orig_value;+ OV_ASSERT_NO_THROW(orig_value = ie.get_property(deviceName, configKey));++ ASSERT_THROW(ie.set_property(deviceName, {{configKey, configValue}}), ov::Exception);++ ov::Any after_value;+ OV_ASSERT_NO_THROW(after_value = ie.get_property(deviceName, configKey));++ ASSERT_EQ(orig_value.as<std::string>(), after_value.as<std::string>());+}++using ClassPluginPropertiesTestSuite3NPU = ClassPluginPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite3NPU, CanGetPropertyWithOptionsNotAffectingCore) {+ std::vector<ov::PropertyName> properties;++ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));++ auto it = find(properties.cbegin(), properties.cend(), configKey);+ ASSERT_TRUE(it != properties.cend());++ ov::Any retrieved_value;+ OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));++ ov::Any retrieved_value_with_options;+ OV_ASSERT_NO_THROW(retrieved_value_with_options = ie.get_property(+ deviceName,+ configKey,+ {{ov::hint::performance_mode.name(), ov::Any(ov::hint::PerformanceMode::THROUGHPUT)}}));++ ov::Any retrieved_value2;+ OV_ASSERT_NO_THROW(retrieved_value2 = ie.get_property(deviceName, configKey));++ ASSERT_EQ(retrieved_value.as<std::string>(), retrieved_value2.as<std::string>());+}++using ClassPluginPropertiesTestSuite4NPU = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite4NPU, CanNotSetGetInexistentProperty) {+ // ie.set_property won't call plugin Engine::SetConfig due to empty string-ov::Plugin map from core_impl+ // workaround to overcome this is to call first ie.get_property which calls get_plugin() from core_impl and+ // populates plugin map+ std::vector<ov::PropertyName> properties;+ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));++ ASSERT_THROW(ie.set_property(deviceName, {{configKey, configValue}}), ov::Exception);++ ASSERT_THROW(auto property1 = ie.get_property(deviceName, configKey), ov::Exception);++ ASSERT_THROW(ov::CompiledModel compiled_model1 = ie.compile_model(model, deviceName, {{configKey, configValue}}),+ ov::Exception);++ ov::CompiledModel compiled_model2;++ OV_ASSERT_NO_THROW(compiled_model2 = ie.compile_model(model, deviceName));++ ASSERT_THROW(compiled_model2.set_property({{configKey, configValue}}),+ ov::Exception); // Expect to throw due to unimplemented method++ ASSERT_THROW(auto property2 = compiled_model2.get_property(configKey),+ ov::Exception); // Expect to throw due to unsupported config+}++using ClassPluginPropertiesTestSuite5NPU = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(ClassPluginPropertiesTestSuite5NPU, CanSetMutablePropertiesToCompiledModel) {+ // Encryption callbacks require L0 graph ext version >= 1.17+ NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);++ // ie.set_property won't call plugin Engine::SetConfig due to empty string-ov::Plugin map from core_impl+ // workaround to overcome this is to call first ie.get_property which calls get_plugin() from core_impl and+ // populates plugin map+ std::vector<ov::PropertyName> properties;+ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));++ OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));++ OV_ASSERT_NO_THROW(ov::CompiledModel compiled_model1 =+ ie.compile_model(model, deviceName, {{configKey, configValue}}));++ ov::CompiledModel compiled_model2;++ OV_ASSERT_NO_THROW(compiled_model2 = ie.compile_model(model, deviceName));++ OV_ASSERT_NO_THROW(compiled_model2.set_property({{configKey, configValue}}));+}++using ClassExecutableNetworkInvalidDeviceIDTestSuite = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(ClassExecutableNetworkInvalidDeviceIDTestSuite, InvalidNPUdeviceIDTest) {+ deviceName = configValue.as<std::string>();+ const bool is_non_negative_numeric_device_id = has_non_negative_numeric_suffix(deviceName);++ auto backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto device = backend->getDevice();+ if (device != nullptr && device->getName() == ov::intel_npu::Platform::AUTO_DETECT) {+ if (is_non_negative_numeric_device_id) {+ GTEST_SKIP()+ << "Skip since AUTO_DETECT platform should ignore numeric suffix and find the device successfully\n";+ }++ OV_EXPECT_THROW_HAS_SUBSTRING(ov::CompiledModel compiled_model = ie.compile_model(model, deviceName),+ ov::Exception,+ "Compilation failed.");+ return;+ }++ OV_EXPECT_THROW_HAS_SUBSTRING(ov::CompiledModel compiled_model = ie.compile_model(model, deviceName),+ ov::Exception,+ "Could not find a valid NPU device for the provided configuration.");+}++using CheckCompilerTypeProperty = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(CheckCompilerTypeProperty, CheckCompilerTypePropertyFromCompiledModel) {+ std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(deviceName);+ const std::vector<std::string> plugin_compiler_platforms = {"4000", "5010", "5020", "6010"};+ bool is_plugin_compiler_platform = false;+ for (const auto& p : plugin_compiler_platforms) {+ if (platform.find(p) != std::string::npos) {+ is_plugin_compiler_platform = true;+ break;+ }+ }+ ov::Core core;++ ov::CompiledModel compiled_model;+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));+ auto compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);++ if (is_plugin_compiler_platform) {+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);+ } else {+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);+ }++ OV_ASSERT_NO_THROW(+ compiled_model =+ core.compile_model(model, deviceName, {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));+ compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);++ if (is_plugin_compiler_platform) {+ OV_ASSERT_NO_THROW(compiled_model =+ core.compile_model(model,+ deviceName,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}));+ compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);+ }+}++TEST_P(CheckCompilerTypeProperty, CheckCompilerTypePropertyAfterSettingExtraConfigToGetProperty) {+ std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(deviceName);+ const std::vector<std::string> plugin_compiler_platforms = {"4000", "5010", "5020", "6010"};+ bool is_plugin_compiler_platform = false;+ for (const auto& p : plugin_compiler_platforms) {+ if (platform.find(p) != std::string::npos) {+ is_plugin_compiler_platform = true;+ break;+ }+ }+ ov::Core core;++ auto test_custom_compiler_type =+ core.get_property(deviceName,+ ov::intel_npu::compiler_type,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)});+ ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::DRIVER);++ test_custom_compiler_type = core.get_property(deviceName, ov::intel_npu::compiler_type);+ if (is_plugin_compiler_platform) {+ ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::PREFER_PLUGIN);+ } else {+ ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::DRIVER);+ }++ ov::CompiledModel compiled_model;+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));+ auto compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);++ if (is_plugin_compiler_platform) {+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);+ } else {+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);+ }+}++TEST_P(CheckCompilerTypeProperty, CheckLogAfterSettingExtraConfigToGetProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));++ auto compiler_type = ov::intel_npu::CompilerType::PLUGIN;+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ compiler_type = core.get_property(+ deviceName,+ ov::intel_npu::compiler_type,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER), ov::intel_npu::qdq_optimization(true)});+ }++ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ compiler_type = core.get_property(deviceName, ov::intel_npu::compiler_type);+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);+}++TEST_P(CheckCompilerTypeProperty, CheckLogAfterGettingPropertyWithExtraConfig) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.get_property(deviceName,+ ov::intel_npu::defer_weights_load,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.get_property(deviceName,+ ov::intel_npu::defer_weights_load,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::qdq_optimization(true)}));+ }++ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+}++TEST_P(CheckCompilerTypeProperty, SetRuntimeProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));+ }++ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+}++TEST_P(CheckCompilerTypeProperty, SetCompilerPropertyForDifferentCompiler) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));+ }+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));+ }+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));+ }+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));+ }+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));+ }+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);++ logs.clear();++ OV_ASSERT_NO_THROW(+ core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));+ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));+ }+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);++ logs.clear();++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.get_property(deviceName,+ ov::intel_npu::compiler_version,+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));+ }+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);++ logs.clear();+}++using CheckCompilerVersionProperty = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(CheckCompilerVersionProperty, GetCompilerVersionFromCompiledModel) {+ ov::Core core;+ ov::CompiledModel compiled_model;+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));++ uint32_t compiled_model_version = 0;+ OV_ASSERT_NO_THROW(compiled_model_version = compiled_model.get_property(ov::intel_npu::compiler_version));++ uint32_t plugin_version = 0;+ OV_ASSERT_NO_THROW(plugin_version = core.get_property(deviceName, ov::intel_npu::compiler_version));+ ASSERT_EQ(compiled_model_version, plugin_version);+}++TEST_P(CheckCompilerVersionProperty, CompilerVersionAvailableAfterImport) {+ ov::Core core_compile, core_import;+ ov::CompiledModel compiled_model, imported_model;+ std::stringstream export_stream;++ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));++ uint32_t compiled_version = 0;+ OV_ASSERT_NO_THROW(compiled_version = compiled_model.get_property(ov::intel_npu::compiler_version));++ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ OV_ASSERT_NO_THROW(imported_model = core_import.import_model(export_stream, deviceName));++ uint32_t imported_version = 0;+ OV_ASSERT_NO_THROW(imported_version = imported_model.get_property(ov::intel_npu::compiler_version));+ ASSERT_EQ(imported_version, compiled_version);+}++using CheckCompilerPropertyWhenImporting = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(CheckCompilerPropertyWhenImporting, ExpectedThrowFromImportWithUnsupportedProperty) {+ ov::Core core_compile, core_import;+ ov::CompiledModel compiled_model;+ std::stringstream export_stream;++ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ ASSERT_THROW(core_import.import_model(export_stream, deviceName, {{{"DUMMY_PROPERTY", ov::Any("DUMMY_VALUE")}}}),+ ov::Exception); // Expect to throw due to unsupported property+}++TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithCompilerProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core_compile, core_import;+ ov::CompiledModel compiled_model;+ std::stringstream export_stream;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ core_import.set_property(deviceName, ov::log::level(ov::log::Level::INFO));+ OV_ASSERT_NO_THROW(+ core_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));+ }++ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),+ std::string::npos);+}++TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithBothProperty) {+ ov::Core core_compile, core_import;+ ov::CompiledModel compiled_model, imported_model;+ std::stringstream export_stream0, export_stream1;++ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream0));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream1));+ compiled_model = {};++ OV_ASSERT_NO_THROW(imported_model =+ core_import.import_model(export_stream0, deviceName, {{ov::intel_npu::turbo(true)}}));+ bool turbo = false;+ OV_ASSERT_NO_THROW(turbo = imported_model.get_property(ov::intel_npu::turbo));+ ASSERT_TRUE(turbo == true);++ OV_ASSERT_NO_THROW(imported_model = core_import.import_model(+ export_stream1,+ deviceName,+ {{ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)}}));+ ASSERT_THROW(imported_model.get_property(ov::intel_npu::turbo),+ ov::Exception); // Expect to throw due to unsupported property++ ov::hint::PerformanceMode perf_mode = ov::hint::PerformanceMode::LATENCY;+ OV_ASSERT_NO_THROW(perf_mode = imported_model.get_property(ov::hint::performance_mode));+ ASSERT_TRUE(perf_mode == ov::hint::PerformanceMode::THROUGHPUT);+}++TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithRuntimeProperty) {+ ov::Core core_compile, core_import;+ ov::CompiledModel compiled_model, imported_model;+ std::stringstream export_stream;++ OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ OV_ASSERT_NO_THROW(imported_model =+ core_import.import_model(export_stream,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::workload_type(ov::WorkloadType::EFFICIENT)}}));++ ov::intel_npu::CompilerType compiler_type = ov::intel_npu::CompilerType::PLUGIN;+ OV_ASSERT_NO_THROW(compiler_type = imported_model.get_property(ov::intel_npu::compiler_type));+ ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);++ ov::WorkloadType workload_type = ov::WorkloadType::DEFAULT;+ OV_ASSERT_NO_THROW(workload_type = imported_model.get_property(ov::workload_type));+ ASSERT_TRUE(workload_type == ov::WorkloadType::EFFICIENT);+}++TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core_for_compiler;+ ov::Core core_for_importing;+ ov::CompiledModel compiled_model;+ std::stringstream export_stream;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ OV_ASSERT_NO_THROW(compiled_model = core_for_compiler.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ core_for_importing.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(+ core_for_importing.import_model(export_stream,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::platform("5010"),+ ov::intel_npu::qdq_optimization(true)}}));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "+ "current configuration."),+ std::string::npos);+}++TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerPropertyAfterCompiling) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::CompiledModel compiled_model;+ std::stringstream export_stream;+ ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());++ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));+ OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));+ compiled_model = {};++ core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.import_model(export_stream,+ deviceName,+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ ov::intel_npu::platform("5010"),+ ov::intel_npu::qdq_optimization(true)}}));+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "+ "configuration."),+ std::string::npos);+ ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "+ "current configuration."),+ std::string::npos);+}++using CheckCpuPinning = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(CheckCpuPinning, CheckCompileModelWithCpuPinningFromSetProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::CompiledModel compiled_model;++ ov::test::utils::LoggerLevelGuard logGuard(ov::log::Level::WARNING);+ core.set_property(deviceName, ov::log::level(ov::log::Level::WARNING));++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::hint::enable_cpu_pinning(true)));+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));+ }++ bool enable_cpu_pinning = false;+ OV_ASSERT_NO_THROW(enable_cpu_pinning = compiled_model.get_property(ov::hint::enable_cpu_pinning));+ ASSERT_TRUE(enable_cpu_pinning);++ std::vector<ov::PropertyName> core_supported_properties;+ OV_ASSERT_NO_THROW(core_supported_properties = core.get_property(deviceName, ov::supported_properties));+ ASSERT_EQ(std::find(core_supported_properties.cbegin(),+ core_supported_properties.cend(),+ ov::hint::enable_cpu_pinning.name()),+ core_supported_properties.cend());++ std::vector<ov::PropertyName> compiled_supported_properties;+ OV_ASSERT_NO_THROW(compiled_supported_properties = compiled_model.get_property(ov::supported_properties));+ ASSERT_EQ(std::find(compiled_supported_properties.cbegin(),+ compiled_supported_properties.cend(),+ ov::hint::enable_cpu_pinning.name()),+ compiled_supported_properties.cend());++ ASSERT_NE(logs.find("The \"ENABLE_CPU_PINNING\" property is deprecated and has no effect on the NPU Plugin."),+ std::string::npos);+}++TEST_P(CheckCpuPinning, CheckCompileModelWithCpuPinningFromCompileProperty) {+ std::string logs;+ std::mutex logs_mutex;+ ov::Core core;+ ov::CompiledModel compiled_model;++ ov::test::utils::LoggerLevelGuard logGuard(ov::log::Level::WARNING);++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);+ OV_ASSERT_NO_THROW(compiled_model = core.compile_model(+ model,+ deviceName,+ {ov::hint::enable_cpu_pinning(true), ov::log::level(ov::log::Level::WARNING)}));+ }++ bool enable_cpu_pinning = false;+ OV_ASSERT_NO_THROW(enable_cpu_pinning = compiled_model.get_property(ov::hint::enable_cpu_pinning));+ ASSERT_TRUE(enable_cpu_pinning);++ std::vector<ov::PropertyName> core_supported_properties;+ OV_ASSERT_NO_THROW(core_supported_properties = core.get_property(deviceName, ov::supported_properties));+ ASSERT_EQ(std::find(core_supported_properties.cbegin(),+ core_supported_properties.cend(),+ ov::hint::enable_cpu_pinning.name()),+ core_supported_properties.cend());++ std::vector<ov::PropertyName> compiled_supported_properties;+ OV_ASSERT_NO_THROW(compiled_supported_properties = compiled_model.get_property(ov::supported_properties));+ ASSERT_EQ(std::find(compiled_supported_properties.cbegin(),+ compiled_supported_properties.cend(),+ ov::hint::enable_cpu_pinning.name()),+ compiled_supported_properties.cend());++ ASSERT_NE(logs.find("The \"ENABLE_CPU_PINNING\" property is deprecated and has no effect on the NPU Plugin."),+ std::string::npos);+}++using CheckSecureCompilationFlag = ClassExecutableNetworkGetPropertiesTestNPU;++TEST_P(CheckSecureCompilationFlag, EncryptionCallbacksForOlderDriverThrows) {+ ov::Core core;+ ov::AnyMap configuration = {{configKey, configValue},+ ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)};+ if (::intel_npu::ZeroInitStructsHolder::getInstance()->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 17)) {+ OV_EXPECT_THROW(core.compile_model(model, deviceName, configuration),+ ov::Exception,+ testing::HasSubstr(+ "Secure compilation was requested, but the current driver version does not support it."));+ core.set_property(deviceName, configuration);+ OV_EXPECT_THROW(core.compile_model(model, deviceName, {}),+ ov::Exception,+ testing::HasSubstr(+ "Secure compilation was requested, but the current driver version does not support it."));+ } else {+ OV_ASSERT_NO_THROW(core.compile_model(model, deviceName, configuration));+ core.set_property(deviceName, configuration);+ OV_ASSERT_NO_THROW(core.compile_model(model, deviceName, {}));+ }+}++} // namespace++namespace {+std::vector<std::pair<std::string, ov::Any>> exe_network_supported_properties = {{ov::hint::num_requests.name(), ov::Any(8)},{ov::hint::performance_mode.name(), ov::Any(ov::hint::PerformanceMode::THROUGHPUT)},diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hppdeleted file mode 100644index 6aae1ac7c92..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp+++ /dev/null@@ -1,906 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <memory>-#include <openvino/runtime/intel_npu/properties.hpp>-#include <vector>--#include "behavior/compiled_model/properties.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "openvino/core/log.hpp"-#include "zero_backend.hpp"--using namespace ov::test::behavior;--namespace {--bool has_non_negative_numeric_suffix(const std::string& value) {- const auto dot_pos = value.find('.');- if (dot_pos == std::string::npos || dot_pos + 1 >= value.size()) {- return false;- }-- const auto suffix = value.substr(dot_pos + 1);- return std::all_of(suffix.begin(), suffix.end(), [](const char ch) {- return ch >= '0' && ch <= '9';- });-}--// ExecutableNetwork Properties tests-class ClassExecutableNetworkGetPropertiesTestNPU- : public OVCompiledModelPropertiesBase,- public ::testing::WithParamInterface<std::tuple<std::string, std::pair<std::string, ov::Any>>> {-protected:- std::string deviceName;- std::string configKey;- ov::Any configValue;- ov::Core ie;--private:- std::optional<ov::test::utils::LoggerLevelGuard> _logGuard;--public:- void SetUp() override {- _logGuard.emplace(::intel_npu::Logger::global().level());- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- OVCompiledModelPropertiesBase::SetUp();-- deviceName = std::get<0>(GetParam());- std::tie(configKey, configValue) = std::get<1>(GetParam());-- model = ov::test::utils::make_conv_pool_relu();- }-- void TearDown() override {- _logGuard.reset();- OVCompiledModelPropertiesBase::TearDown();- }- static std::string getTestCaseName(- testing::TestParamInfo<std::tuple<std::string, std::pair<std::string, ov::Any>>> obj) {- std::string targetDevice;- std::pair<std::string, ov::Any> configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- std::ostringstream result;- static uint8_t testCounter = 0;- result << "_testCounter=" << std::to_string(testCounter++)- << "_"; // used to avoid same names for different tests- result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";- result << "config=(" << configuration.first << "=" << configuration.second.as<std::string>() << ")";- result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- return result.str();- }-};--// Plugin Properties tests-class ClassPluginPropertiesTestNPU- : public OVCompiledModelPropertiesBase,- public ::testing::WithParamInterface<std::tuple<std::string, std::pair<std::string, ov::Any>>> {-protected:- std::string deviceName;- std::string configKey;- ov::Any configValue;- ov::Core ie;--public:- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- OVCompiledModelPropertiesBase::SetUp();- deviceName = std::get<0>(GetParam());- std::tie(configKey, configValue) = std::get<1>(GetParam());- }- static std::string getTestCaseName(- testing::TestParamInfo<std::tuple<std::string, std::pair<std::string, ov::Any>>> obj) {- std::string targetDevice;- std::pair<std::string, ov::Any> configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- std::ostringstream result;- static uint8_t testCounter = 0;- result << "_testCounter="- << std::to_string(testCounter++) + "_"; // used to avoid same names for different tests- result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";- result << "config=(" << configuration.first << "=" << configuration.second.as<std::string>() << ")";- result << "_targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);- return result.str();- }-};--using ClassPluginPropertiesTestSuite0NPU = ClassPluginPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite0NPU, CanSetGetPublicMutableProperty) {- std::vector<ov::PropertyName> properties;-- OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));-- auto it = find(properties.cbegin(), properties.cend(), configKey);- ASSERT_TRUE(it != properties.cend());- ASSERT_TRUE(it->is_mutable());-- OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));-- ov::Any retrieved_value;- OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));-- ASSERT_EQ(retrieved_value.as<std::string>(), configValue.as<std::string>());-}--using ClassExecutableNetworkTestSuite1NPU = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(ClassExecutableNetworkTestSuite1NPU, PropertyIsSupportedAndImmutableAndGet) {- std::vector<ov::PropertyName> properties;-- ov::CompiledModel exeNetwork = ie.compile_model(model, deviceName);- OV_ASSERT_NO_THROW(properties = exeNetwork.get_property(ov::supported_properties));-- auto it = find(properties.cbegin(), properties.cend(), configKey);- ASSERT_TRUE(it != properties.cend());- ASSERT_FALSE(it->is_mutable());-- OV_ASSERT_NO_THROW(exeNetwork.get_property(configKey));-}--using ClassExecutableNetworkTestSuite2NPU = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(ClassExecutableNetworkTestSuite2NPU, PropertyIsSupportedAndImmutableAndCanNotSet) {- std::vector<ov::PropertyName> properties;-- ov::CompiledModel exeNetwork = ie.compile_model(model, deviceName);- OV_ASSERT_NO_THROW(properties = exeNetwork.get_property(ov::supported_properties));-- auto it = find(properties.cbegin(), properties.cend(), configKey);- ASSERT_TRUE(it != properties.cend());- ASSERT_FALSE(it->is_mutable());-- ASSERT_THROW(exeNetwork.set_property({{configKey, configValue}}), ov::Exception);-}--using ClassPluginPropertiesTestSuite1NPU = ClassPluginPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite1NPU, CanSetGetInternalMutableProperty) {- OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));-- ov::Any retrieved_value;- OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));-- ASSERT_EQ(retrieved_value.as<std::string>(), configValue.as<std::string>());-}--using ClassPluginPropertiesTestSuite2NPU = ClassPluginPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite2NPU, CanNotSetImmutableProperty) {- std::vector<ov::PropertyName> properties;-- OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));-- auto it = find(properties.cbegin(), properties.cend(), configKey);- ASSERT_TRUE(it != properties.cend());- ASSERT_FALSE(it->is_mutable());-- ov::Any orig_value;- OV_ASSERT_NO_THROW(orig_value = ie.get_property(deviceName, configKey));-- ASSERT_THROW(ie.set_property(deviceName, {{configKey, configValue}}), ov::Exception);-- ov::Any after_value;- OV_ASSERT_NO_THROW(after_value = ie.get_property(deviceName, configKey));-- ASSERT_EQ(orig_value.as<std::string>(), after_value.as<std::string>());-}--using ClassPluginPropertiesTestSuite3NPU = ClassPluginPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite3NPU, CanGetPropertyWithOptionsNotAffectingCore) {- std::vector<ov::PropertyName> properties;-- OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));-- auto it = find(properties.cbegin(), properties.cend(), configKey);- ASSERT_TRUE(it != properties.cend());-- ov::Any retrieved_value;- OV_ASSERT_NO_THROW(retrieved_value = ie.get_property(deviceName, configKey));-- ov::Any retrieved_value_with_options;- OV_ASSERT_NO_THROW(retrieved_value_with_options = ie.get_property(- deviceName,- configKey,- {{ov::hint::performance_mode.name(), ov::Any(ov::hint::PerformanceMode::THROUGHPUT)}}));-- ov::Any retrieved_value2;- OV_ASSERT_NO_THROW(retrieved_value2 = ie.get_property(deviceName, configKey));-- ASSERT_EQ(retrieved_value.as<std::string>(), retrieved_value2.as<std::string>());-}--using ClassPluginPropertiesTestSuite4NPU = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite4NPU, CanNotSetGetInexistentProperty) {- // ie.set_property won't call plugin Engine::SetConfig due to empty string-ov::Plugin map from core_impl- // workaround to overcome this is to call first ie.get_property which calls get_plugin() from core_impl and- // populates plugin map- std::vector<ov::PropertyName> properties;- OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));-- ASSERT_THROW(ie.set_property(deviceName, {{configKey, configValue}}), ov::Exception);-- ASSERT_THROW(auto property1 = ie.get_property(deviceName, configKey), ov::Exception);-- ASSERT_THROW(ov::CompiledModel compiled_model1 = ie.compile_model(model, deviceName, {{configKey, configValue}}),- ov::Exception);-- ov::CompiledModel compiled_model2;-- OV_ASSERT_NO_THROW(compiled_model2 = ie.compile_model(model, deviceName));-- ASSERT_THROW(compiled_model2.set_property({{configKey, configValue}}),- ov::Exception); // Expect to throw due to unimplemented method-- ASSERT_THROW(auto property2 = compiled_model2.get_property(configKey),- ov::Exception); // Expect to throw due to unsupported config-}--using ClassPluginPropertiesTestSuite5NPU = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(ClassPluginPropertiesTestSuite5NPU, CanSetMutablePropertiesToCompiledModel) {- // Encryption callbacks require L0 graph ext version >= 1.17- NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);-- // ie.set_property won't call plugin Engine::SetConfig due to empty string-ov::Plugin map from core_impl- // workaround to overcome this is to call first ie.get_property which calls get_plugin() from core_impl and- // populates plugin map- std::vector<ov::PropertyName> properties;- OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));-- OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));-- OV_ASSERT_NO_THROW(ov::CompiledModel compiled_model1 =- ie.compile_model(model, deviceName, {{configKey, configValue}}));-- ov::CompiledModel compiled_model2;-- OV_ASSERT_NO_THROW(compiled_model2 = ie.compile_model(model, deviceName));-- OV_ASSERT_NO_THROW(compiled_model2.set_property({{configKey, configValue}}));-}--using ClassExecutableNetworkInvalidDeviceIDTestSuite = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(ClassExecutableNetworkInvalidDeviceIDTestSuite, InvalidNPUdeviceIDTest) {- deviceName = configValue.as<std::string>();- const bool is_non_negative_numeric_device_id = has_non_negative_numeric_suffix(deviceName);-- auto backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto device = backend->getDevice();- if (device != nullptr && device->getName() == ov::intel_npu::Platform::AUTO_DETECT) {- if (is_non_negative_numeric_device_id) {- GTEST_SKIP()- << "Skip since AUTO_DETECT platform should ignore numeric suffix and find the device successfully\n";- }-- OV_EXPECT_THROW_HAS_SUBSTRING(ov::CompiledModel compiled_model = ie.compile_model(model, deviceName),- ov::Exception,- "Compilation failed.");- return;- }-- OV_EXPECT_THROW_HAS_SUBSTRING(ov::CompiledModel compiled_model = ie.compile_model(model, deviceName),- ov::Exception,- "Could not find a valid NPU device for the provided configuration.");-}--using CheckCompilerTypeProperty = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(CheckCompilerTypeProperty, CheckCompilerTypePropertyFromCompiledModel) {- std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(deviceName);- const std::vector<std::string> plugin_compiler_platforms = {"4000", "5010", "5020", "6010"};- bool is_plugin_compiler_platform = false;- for (const auto& p : plugin_compiler_platforms) {- if (platform.find(p) != std::string::npos) {- is_plugin_compiler_platform = true;- break;- }- }- ov::Core core;-- ov::CompiledModel compiled_model;- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));- auto compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);-- if (is_plugin_compiler_platform) {- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);- } else {- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);- }-- OV_ASSERT_NO_THROW(- compiled_model =- core.compile_model(model, deviceName, {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));- compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);-- if (is_plugin_compiler_platform) {- OV_ASSERT_NO_THROW(compiled_model =- core.compile_model(model,- deviceName,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)}));- compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);- }-}--TEST_P(CheckCompilerTypeProperty, CheckCompilerTypePropertyAfterSettingExtraConfigToGetProperty) {- std::string platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(deviceName);- const std::vector<std::string> plugin_compiler_platforms = {"4000", "5010", "5020", "6010"};- bool is_plugin_compiler_platform = false;- for (const auto& p : plugin_compiler_platforms) {- if (platform.find(p) != std::string::npos) {- is_plugin_compiler_platform = true;- break;- }- }- ov::Core core;-- auto test_custom_compiler_type =- core.get_property(deviceName,- ov::intel_npu::compiler_type,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)});- ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::DRIVER);-- test_custom_compiler_type = core.get_property(deviceName, ov::intel_npu::compiler_type);- if (is_plugin_compiler_platform) {- ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::PREFER_PLUGIN);- } else {- ASSERT_TRUE(test_custom_compiler_type == ov::intel_npu::CompilerType::DRIVER);- }-- ov::CompiledModel compiled_model;- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));- auto compiler_type = compiled_model.get_property(ov::intel_npu::compiler_type);-- if (is_plugin_compiler_platform) {- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);- } else {- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);- }-}--TEST_P(CheckCompilerTypeProperty, CheckLogAfterSettingExtraConfigToGetProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN));-- auto compiler_type = ov::intel_npu::CompilerType::PLUGIN;- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- compiler_type = core.get_property(- deviceName,- ov::intel_npu::compiler_type,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER), ov::intel_npu::qdq_optimization(true)});- }-- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- compiler_type = core.get_property(deviceName, ov::intel_npu::compiler_type);- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::PLUGIN);-}--TEST_P(CheckCompilerTypeProperty, CheckLogAfterGettingPropertyWithExtraConfig) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.get_property(deviceName,- ov::intel_npu::defer_weights_load,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));- }-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.get_property(deviceName,- ov::intel_npu::defer_weights_load,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::qdq_optimization(true)}));- }-- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-}--TEST_P(CheckCompilerTypeProperty, SetRuntimeProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));- }-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));- }-- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-}--TEST_P(CheckCompilerTypeProperty, SetCompilerPropertyForDifferentCompiler) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::defer_weights_load));- }- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));- }- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));- }- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::intel_npu::qdq_optimization(true)));- }- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-}--TEST_P(CheckCompilerTypeProperty, GetCompilerVersion) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)));- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));- }- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-- logs.clear();-- OV_ASSERT_NO_THROW(- core.set_property(deviceName, ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN)));- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.get_property(deviceName, ov::intel_npu::compiler_version));- }- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_NE(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-- logs.clear();-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.get_property(deviceName,- ov::intel_npu::compiler_version,- {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}));- }- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-- logs.clear();-}--using CheckCompilerVersionProperty = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(CheckCompilerVersionProperty, GetCompilerVersionFromCompiledModel) {- ov::Core core;- ov::CompiledModel compiled_model;- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));-- uint32_t compiled_model_version = 0;- OV_ASSERT_NO_THROW(compiled_model_version = compiled_model.get_property(ov::intel_npu::compiler_version));-- uint32_t plugin_version = 0;- OV_ASSERT_NO_THROW(plugin_version = core.get_property(deviceName, ov::intel_npu::compiler_version));- ASSERT_EQ(compiled_model_version, plugin_version);-}--TEST_P(CheckCompilerVersionProperty, CompilerVersionAvailableAfterImport) {- ov::Core core_compile, core_import;- ov::CompiledModel compiled_model, imported_model;- std::stringstream export_stream;-- OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));-- uint32_t compiled_version = 0;- OV_ASSERT_NO_THROW(compiled_version = compiled_model.get_property(ov::intel_npu::compiler_version));-- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- OV_ASSERT_NO_THROW(imported_model = core_import.import_model(export_stream, deviceName));-- uint32_t imported_version = 0;- OV_ASSERT_NO_THROW(imported_version = imported_model.get_property(ov::intel_npu::compiler_version));- ASSERT_EQ(imported_version, compiled_version);-}--using CheckCompilerPropertyWhenImporting = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(CheckCompilerPropertyWhenImporting, ExpectedThrowFromImportWithUnsupportedProperty) {- ov::Core core_compile, core_import;- ov::CompiledModel compiled_model;- std::stringstream export_stream;-- OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- ASSERT_THROW(core_import.import_model(export_stream, deviceName, {{{"DUMMY_PROPERTY", ov::Any("DUMMY_VALUE")}}}),- ov::Exception); // Expect to throw due to unsupported property-}--TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithCompilerProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core_compile, core_import;- ov::CompiledModel compiled_model;- std::stringstream export_stream;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- core_import.set_property(deviceName, ov::log::level(ov::log::Level::INFO));- OV_ASSERT_NO_THROW(- core_import.import_model(export_stream, deviceName, {{ov::intel_npu::qdq_optimization(true)}}));- }-- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used"),- std::string::npos);-}--TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithBothProperty) {- ov::Core core_compile, core_import;- ov::CompiledModel compiled_model, imported_model;- std::stringstream export_stream0, export_stream1;-- OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream0));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream1));- compiled_model = {};-- OV_ASSERT_NO_THROW(imported_model =- core_import.import_model(export_stream0, deviceName, {{ov::intel_npu::turbo(true)}}));- bool turbo = false;- OV_ASSERT_NO_THROW(turbo = imported_model.get_property(ov::intel_npu::turbo));- ASSERT_TRUE(turbo == true);-- OV_ASSERT_NO_THROW(imported_model = core_import.import_model(- export_stream1,- deviceName,- {{ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT)}}));- ASSERT_THROW(imported_model.get_property(ov::intel_npu::turbo),- ov::Exception); // Expect to throw due to unsupported property-- ov::hint::PerformanceMode perf_mode = ov::hint::PerformanceMode::LATENCY;- OV_ASSERT_NO_THROW(perf_mode = imported_model.get_property(ov::hint::performance_mode));- ASSERT_TRUE(perf_mode == ov::hint::PerformanceMode::THROUGHPUT);-}--TEST_P(CheckCompilerPropertyWhenImporting, ExpectedNoThrowFromImportWithRuntimeProperty) {- ov::Core core_compile, core_import;- ov::CompiledModel compiled_model, imported_model;- std::stringstream export_stream;-- OV_ASSERT_NO_THROW(compiled_model = core_compile.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- OV_ASSERT_NO_THROW(imported_model =- core_import.import_model(export_stream,- deviceName,- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::workload_type(ov::WorkloadType::EFFICIENT)}}));-- ov::intel_npu::CompilerType compiler_type = ov::intel_npu::CompilerType::PLUGIN;- OV_ASSERT_NO_THROW(compiler_type = imported_model.get_property(ov::intel_npu::compiler_type));- ASSERT_TRUE(compiler_type == ov::intel_npu::CompilerType::DRIVER);-- ov::WorkloadType workload_type = ov::WorkloadType::DEFAULT;- OV_ASSERT_NO_THROW(workload_type = imported_model.get_property(ov::workload_type));- ASSERT_TRUE(workload_type == ov::WorkloadType::EFFICIENT);-}--TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core_for_compiler;- ov::Core core_for_importing;- ov::CompiledModel compiled_model;- std::stringstream export_stream;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- OV_ASSERT_NO_THROW(compiled_model = core_for_compiler.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- core_for_importing.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(- core_for_importing.import_model(export_stream,- deviceName,- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::platform("5010"),- ov::intel_npu::qdq_optimization(true)}}));- }-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "- "configuration."),- std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "- "current configuration."),- std::string::npos);-}--TEST_P(CheckCompilerPropertyWhenImporting, CheckImportWithCompilerPropertyAfterCompiling) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::CompiledModel compiled_model;- std::stringstream export_stream;- ov::test::utils::LoggerLevelGuard levelGuard(::intel_npu::Logger::global().level());-- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));- OV_ASSERT_NO_THROW(compiled_model.export_model(export_stream));- compiled_model = {};-- core.set_property(deviceName, ov::log::level(ov::log::Level::INFO));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.import_model(export_stream,- deviceName,- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- ov::intel_npu::platform("5010"),- ov::intel_npu::qdq_optimization(true)}}));- }-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_PLATFORM' is recognized as a compiler option, will not be used for current "- "configuration."),- std::string::npos);- ASSERT_NE(logs.find("Config key 'NPU_QDQ_OPTIMIZATION' is recognized as a compiler option, will not be used for "- "current configuration."),- std::string::npos);-}--using CheckCpuPinning = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(CheckCpuPinning, CheckCompileModelWithCpuPinningFromSetProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::CompiledModel compiled_model;-- ov::test::utils::LoggerLevelGuard logGuard(ov::log::Level::WARNING);- core.set_property(deviceName, ov::log::level(ov::log::Level::WARNING));-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(core.set_property(deviceName, ov::hint::enable_cpu_pinning(true)));- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(model, deviceName));- }-- bool enable_cpu_pinning = false;- OV_ASSERT_NO_THROW(enable_cpu_pinning = compiled_model.get_property(ov::hint::enable_cpu_pinning));- ASSERT_TRUE(enable_cpu_pinning);-- std::vector<ov::PropertyName> core_supported_properties;- OV_ASSERT_NO_THROW(core_supported_properties = core.get_property(deviceName, ov::supported_properties));- ASSERT_EQ(std::find(core_supported_properties.cbegin(),- core_supported_properties.cend(),- ov::hint::enable_cpu_pinning.name()),- core_supported_properties.cend());-- std::vector<ov::PropertyName> compiled_supported_properties;- OV_ASSERT_NO_THROW(compiled_supported_properties = compiled_model.get_property(ov::supported_properties));- ASSERT_EQ(std::find(compiled_supported_properties.cbegin(),- compiled_supported_properties.cend(),- ov::hint::enable_cpu_pinning.name()),- compiled_supported_properties.cend());-- ASSERT_NE(logs.find("The \"ENABLE_CPU_PINNING\" property is deprecated and has no effect on the NPU Plugin."),- std::string::npos);-}--TEST_P(CheckCpuPinning, CheckCompileModelWithCpuPinningFromCompileProperty) {- std::string logs;- std::mutex logs_mutex;- ov::Core core;- ov::CompiledModel compiled_model;-- ov::test::utils::LoggerLevelGuard logGuard(ov::log::Level::WARNING);-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- ov::test::utils::LogCallbackGuard log_callback_guard(log_cb);- OV_ASSERT_NO_THROW(compiled_model = core.compile_model(- model,- deviceName,- {ov::hint::enable_cpu_pinning(true), ov::log::level(ov::log::Level::WARNING)}));- }-- bool enable_cpu_pinning = false;- OV_ASSERT_NO_THROW(enable_cpu_pinning = compiled_model.get_property(ov::hint::enable_cpu_pinning));- ASSERT_TRUE(enable_cpu_pinning);-- std::vector<ov::PropertyName> core_supported_properties;- OV_ASSERT_NO_THROW(core_supported_properties = core.get_property(deviceName, ov::supported_properties));- ASSERT_EQ(std::find(core_supported_properties.cbegin(),- core_supported_properties.cend(),- ov::hint::enable_cpu_pinning.name()),- core_supported_properties.cend());-- std::vector<ov::PropertyName> compiled_supported_properties;- OV_ASSERT_NO_THROW(compiled_supported_properties = compiled_model.get_property(ov::supported_properties));- ASSERT_EQ(std::find(compiled_supported_properties.cbegin(),- compiled_supported_properties.cend(),- ov::hint::enable_cpu_pinning.name()),- compiled_supported_properties.cend());-- ASSERT_NE(logs.find("The \"ENABLE_CPU_PINNING\" property is deprecated and has no effect on the NPU Plugin."),- std::string::npos);-}--using CheckSecureCompilationFlag = ClassExecutableNetworkGetPropertiesTestNPU;--TEST_P(CheckSecureCompilationFlag, EncryptionCallbacksForOlderDriverThrows) {- ov::Core core;- ov::AnyMap configuration = {{configKey, configValue},- ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)};- if (::intel_npu::ZeroInitStructsHolder::getInstance()->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 17)) {- OV_EXPECT_THROW(core.compile_model(model, deviceName, configuration),- ov::Exception,- testing::HasSubstr(- "Secure compilation was requested, but the current driver version does not support it."));- core.set_property(deviceName, configuration);- OV_EXPECT_THROW(core.compile_model(model, deviceName, {}),- ov::Exception,- testing::HasSubstr(- "Secure compilation was requested, but the current driver version does not support it."));- } else {- OV_ASSERT_NO_THROW(core.compile_model(model, deviceName, configuration));- core.set_property(deviceName, configuration);- OV_ASSERT_NO_THROW(core.compile_model(model, deviceName, {}));- }-}--} // namespacediff --git a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.cpp b/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.cppindex 4226484011f..ec91acb6391 100644--- a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.cpp@@ -2,12 +2,743 @@// SPDX-License-Identifier: Apache-2.0//-#include "infer_with_host_compile.hpp"+#include <algorithm>+#include <common_test_utils/ov_tensor_utils.hpp>+#include <cstring>+#include <functional>+#include <iostream>+#include <sstream>+#include <string>+#include <string_view>+#include <tuple>+#include <vector>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "openvino/openvino.hpp"+#include "openvino/opsets/opset6.hpp"+#include "openvino/pass/manager.hpp"+#include "openvino/pass/serialize.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov {+namespace test {+namespace behavior {++inline std::shared_ptr<ov::Model> createMaxPoolModel(bool dynamicBatch = false, bool nhwcLayout = true) {+ std::shared_ptr<ov::op::v0::Parameter> input;+ if (dynamicBatch) {+ input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16,+ ov::PartialShape{ov::Dimension(1, 10), 16, 720, 1280});+ } else {+ input = std::make_shared<ov::op::v0::Parameter>(+ ov::element::f16,+ ov::PartialShape{1, 16, ov::Dimension(10, 720), ov::Dimension(10, 1280)});+ }++ std::string inputName = "input1";+ input->set_friendly_name(inputName);+ input->get_output_tensor(0).set_names({inputName});+ if (!nhwcLayout)+ input->set_layout("NCHW");+ auto maxpool = std::make_shared<ov::op::v1::MaxPool>(input,+ Strides{1, 1},+ Shape{0, 0},+ Shape{0, 0},+ Shape{1, 1},+ op::RoundingType::FLOOR,+ op::PadType::EXPLICIT);+ maxpool->set_friendly_name("MaxPool_2");++ auto result = std::make_shared<ov::op::v0::Result>(maxpool);+ std::string outputName = "output";+ if (!nhwcLayout)+ result->set_layout("NCHW");+ result->set_friendly_name(outputName);+ result->get_output_tensor(0).set_names({outputName});++ auto model = std::make_shared<Model>(ResultVector{result}, ParameterVector{input}, "MaxPool");++ // making input and output to be NHWC+ if (nhwcLayout) {+ auto preProc = ov::preprocess::PrePostProcessor(model);+ preProc.input(0).tensor().set_layout("NHWC");+ preProc.input(0).model().set_layout("NCHW");+ preProc.output(0).tensor().set_layout("NHWC");+ preProc.output(0).model().set_layout("NCHW");++ model = preProc.build();+ }++ return model;+}++inline std::shared_ptr<ov::Model> createCustomNetModel() {+ auto input = std::make_shared<ov::op::v0::Parameter>(+ ov::element::f16,+ ov::PartialShape{1, 16, ov::Dimension(1, 1080), ov::Dimension(10, 1920)});+ input->set_friendly_name("Parameter_59");++ auto make_conv_add = [](const ov::Output<ov::Node>& data,+ const std::string& convName,+ const std::string& addName,+ float weightValue,+ float biasValue) -> ov::Output<ov::Node> {+ const std::vector<float> weightValues(16 * 16, weightValue);+ const std::vector<float> biasValues(16, biasValue);++ auto weights = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{16, 16, 1, 1}, weightValues);+ auto conv = std::make_shared<ov::op::v1::Convolution>(data,+ weights,+ ov::Strides{1, 1},+ ov::CoordinateDiff{0, 0},+ ov::CoordinateDiff{0, 0},+ ov::Strides{1, 1},+ ov::op::PadType::EXPLICIT);+ conv->set_friendly_name(convName);++ auto bias = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1, 16, 1, 1}, biasValues);+ auto add = std::make_shared<ov::op::v1::Add>(conv, bias);+ add->set_friendly_name(addName);+ return add;+ };++ auto x = make_conv_add(input, "Convolution_61", "Add_63", 0.01f, 0.001f);+ x = make_conv_add(x, "Convolution_65", "Add_67", 0.011f, 0.001f);++ auto relu68 = std::make_shared<ov::op::v0::Relu>(x);+ relu68->set_friendly_name("Relu_68");+ x = relu68;++ x = make_conv_add(x, "Convolution_70", "Add_72", 0.012f, 0.001f);+ auto relu73 = std::make_shared<ov::op::v0::Relu>(x);+ relu73->set_friendly_name("Relu_73");+ x = relu73;++ x = make_conv_add(x, "Convolution_75", "Add_77", 0.013f, 0.001f);+ auto relu78 = std::make_shared<ov::op::v0::Relu>(x);+ relu78->set_friendly_name("Relu_78");+ x = relu78;++ x = make_conv_add(x, "Convolution_82", "Add_84", 0.014f, 0.001f);+ auto relu85 = std::make_shared<ov::op::v0::Relu>(x);+ relu85->set_friendly_name("Relu_85");+ x = relu85;++ x = make_conv_add(x, "Convolution_87", "Add_89", 0.015f, 0.001f);+ auto relu90 = std::make_shared<ov::op::v0::Relu>(x);+ relu90->set_friendly_name("Relu_90");+ x = relu90;++ x = make_conv_add(x, "Convolution_92", "Add_94", 0.016f, 0.001f);+ auto relu95 = std::make_shared<ov::op::v0::Relu>(x);+ relu95->set_friendly_name("Relu_95");+ x = relu95;++ auto multiplyScale = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1, 16, 1, 1}, {0.5f});+ auto multiply97 = std::make_shared<ov::op::v1::Multiply>(x, multiplyScale);+ multiply97->set_friendly_name("Multiply_97");++ auto add98 = std::make_shared<ov::op::v1::Add>(multiply97, multiply97);+ add98->set_friendly_name("Add_98");++ x = make_conv_add(add98, "Convolution_100", "Add_102", 0.017f, 0.001f);++ auto result = std::make_shared<ov::op::v0::Result>(x);+ result->set_friendly_name("Result_104");++ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input}, "CustomNet");++ // making input and output to be NHWC+ auto preProc = ov::preprocess::PrePostProcessor(model);+ preProc.input(0).tensor().set_layout("NHWC");+ preProc.input(0).model().set_layout("NCHW");+ preProc.output(0).tensor().set_layout("NHWC");+ preProc.output(0).model().set_layout("NCHW");++ model = preProc.build();++ return model;+}++using InferWithHostCompileParams = std::tuple<std::string, // Device name+ ov::AnyMap, // Config+ std::string // Model name+ >;++// These tests are required by the NPU plugin to verify the support of dynamic shape during+// compilation and inference on different NPU drivers+class InferWithHostCompileTests : public testing::WithParamInterface<InferWithHostCompileParams>,+ public OVInferRequestTestBase {+public:+ enum class RuntimeCompareStatus {+ ready,+ skip,+ fail,+ };++ struct ScopedLogCapture {+ ScopedLogCapture();+ ~ScopedLogCapture();++ void clear();+ std::string str() const;++ private:+ std::stringstream stream;+ std::function<void(std::string_view)> callback;++ friend class InferWithHostCompileTests;+ };++ struct RuntimeCompareContext {+ std::shared_ptr<ov::Model> model;+ ov::CompiledModel compiledModel;+ ov::CompiledModel referenceCompiledModel;+ ov::InferRequest reqDynamic;+ ov::InferRequest reqReference;+ };++ struct RuntimeCompareSetupResult {+ RuntimeCompareStatus status = RuntimeCompareStatus::ready;+ std::string message;+ RuntimeCompareContext context;+ };++ static std::string getTestCaseName(testing::TestParamInfo<InferWithHostCompileParams> obj) {+ std::string target_device;+ ov::AnyMap configuration;+ std::string modelName;+ std::tie(target_device, configuration, modelName) = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '.');+ std::ostringstream result;+ result << "targetDevice=" << target_device << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ result << "_";+ }+ }+ result << "model=" << modelName;+ return result.str();+ }++ void SetUp() {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration, selectedModelName) = this->GetParam();++ configuration[ov::intel_npu::compile_log_level.name()] = ov::log::Level::ERR;+ std::vector<std::string> deviceNames =+ core->get_property("NPU", ov::available_devices.name()).as<std::vector<std::string>>();+ for (auto name : deviceNames) {+ if (target_device.find(name) != std::string::npos) {+ isTargetDevice = true;+ break;+ }+ }+ originalLogLevel = core->get_property("NPU", ov::log::level.name()).as<ov::log::Level>();++ APIBaseTest::SetUp();+ }++ void TearDown() {+ core->set_property("NPU", ov::log::level(originalLogLevel));+ }++ static void compareInferenceResult(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference);++ static void inferAndCompare(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference,+ const std::string& dumpPrefix);++ static void setInputInferAndCompare(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference,+ const ov::Tensor& inputTensor,+ const std::string& dumpPrefix);++ static bool logContains(const ScopedLogCapture& logCapture, const std::string& expectedEntry);++ static std::shared_ptr<ov::Model> createModelByName(const std::string& modelName);++ RuntimeCompareSetupResult prepareRuntimeCompareContext(const std::shared_ptr<ov::Model>& model);++protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::string selectedModelName;+ bool isTargetDevice = false;+ ov::log::Level originalLogLevel = ov::log::Level::ERR;+};++InferWithHostCompileTests::ScopedLogCapture::ScopedLogCapture()+ : callback([this](std::string_view s) {+ stream << s << std::endl;+ }) {+ ov::util::set_log_callback(callback);+}++InferWithHostCompileTests::ScopedLogCapture::~ScopedLogCapture() {+ ov::util::reset_log_callback();+}++void InferWithHostCompileTests::ScopedLogCapture::clear() {+ stream.str("");+ stream.clear();+}++std::string InferWithHostCompileTests::ScopedLogCapture::str() const {+ return stream.str();+}++void InferWithHostCompileTests::compareInferenceResult(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference) {+ const auto inputTensor = reqDynamic.get_input_tensor(0);+ const auto npuOutputTensor = reqDynamic.get_tensor(model->output());+ const auto referenceOutputTensor = reqReference.get_tensor(model->output());++ ov::test::utils::compare(referenceOutputTensor, npuOutputTensor, npuOutputTensor.get_element_type());+}++void InferWithHostCompileTests::inferAndCompare(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference,+ const std::string& stage) {+ OV_ASSERT_NO_THROW(reqDynamic.infer());+ OV_ASSERT_NO_THROW(reqReference.infer());+ try {+ compareInferenceResult(model, reqDynamic, reqReference);+ } catch (const ov::Exception& e) {+ FAIL() << "Inference result comparison failed at stage " << stage << ": " << e.what();+ }+}++void InferWithHostCompileTests::setInputInferAndCompare(const std::shared_ptr<ov::Model>& model,+ ov::InferRequest& reqDynamic,+ ov::InferRequest& reqReference,+ const ov::Tensor& inputTensor,+ const std::string& stage) {+ OV_ASSERT_NO_THROW(reqDynamic.set_input_tensor(0, inputTensor));+ OV_ASSERT_NO_THROW(reqReference.set_input_tensor(0, inputTensor));+ inferAndCompare(model, reqDynamic, reqReference, stage);+}++bool InferWithHostCompileTests::logContains(const ScopedLogCapture& logCapture, const std::string& expectedEntry) {+ return logCapture.str().find(expectedEntry) != std::string::npos;+}++std::shared_ptr<ov::Model> InferWithHostCompileTests::createModelByName(const std::string& modelName) {+ if (modelName == "CustomNet") {+ return createCustomNetModel();+ }+ if (modelName == "MaxPool") {+ return createMaxPoolModel();+ }+ if (modelName == "MaxPool_NCHW") {+ return createMaxPoolModel(false, false);+ }+ if (modelName == "MaxPool_NCHW_DynBatch") {+ return createMaxPoolModel(true, false);+ }++ OPENVINO_THROW("Unknown model name for InferWithHostCompileTests: ", modelName);+}++InferWithHostCompileTests::RuntimeCompareSetupResult InferWithHostCompileTests::prepareRuntimeCompareContext(+ const std::shared_ptr<ov::Model>& model) {+ RuntimeCompareSetupResult result;+ result.context.model = model;++ try {+ result.context.compiledModel = core->compile_model(model, target_device, configuration);+ } catch (const ov::Exception& e) {+ result.status = RuntimeCompareStatus::fail;+ result.message = std::string("Failed to compile model for target device: ") + e.what();+ return result;+ }++ try {+ result.context.referenceCompiledModel = core->compile_model(model, ov::test::utils::DEVICE_TEMPLATE);+ } catch (const ov::Exception& e) {+ result.status = RuntimeCompareStatus::skip;+ result.message = std::string("CPU plugin is not available for reference comparison: ") + e.what();+ return result;+ }++ try {+ result.context.reqDynamic = result.context.compiledModel.create_infer_request();+ } catch (const ov::Exception& e) {+ result.status = RuntimeCompareStatus::fail;+ result.message = std::string("Failed to create dynamic infer request: ") + e.what();+ return result;+ }++ try {+ result.context.reqReference = result.context.referenceCompiledModel.create_infer_request();+ } catch (const ov::Exception& e) {+ result.status = RuntimeCompareStatus::fail;+ result.message = std::string("Failed to create reference infer request: ") + e.what();+ return result;+ }+ return result;+}++TEST_P(InferWithHostCompileTests, CompileAndImportAndInfer) {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ if (!isTargetDevice) {+ GTEST_SKIP() << "Skip test for current device";+ }+ auto model = createModelByName(selectedModelName);++ ov::CompiledModel compiledModel;++ OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));++ std::stringstream modelStream;+ OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));++ ov::InferRequest reqDynamic;+ ov::CompiledModel importedModel;+ OV_ASSERT_NO_THROW(importedModel = core->import_model(modelStream, target_device));+ OV_ASSERT_NO_THROW(reqDynamic = importedModel.create_infer_request());+ OV_ASSERT_NO_THROW(reqDynamic.infer());+}++// Compile, infer with a large shape, then shrink the input shape and verify both output correctness and command-list+// reuse behavior.+TEST_P(InferWithHostCompileTests, CompileAndInferWithDecreasedSize) {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ if (!isTargetDevice) {+ GTEST_SKIP() << "Skip test for current device";+ }++ auto model = createModelByName(selectedModelName);+ ScopedLogCapture logCapture;++ core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));+ auto setupResult = prepareRuntimeCompareContext(model);+ if (setupResult.status == RuntimeCompareStatus::fail) {+ FAIL() << setupResult.message;+ }+ if (setupResult.status == RuntimeCompareStatus::skip) {+ GTEST_SKIP() << setupResult.message;+ }+ auto& testContext = setupResult.context;++ // Start with the largest shape in the dynamic range.+ ov::Shape shape = {1, 720, 1280, 16};+ ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor,+ "CompileAndInferWithDecreasedSize_first");+ // The first run materializes runtime state for the initial shape.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();++ logCapture.clear();+ inferAndCompare(model, testContext.reqDynamic, testContext.reqReference, "CompileAndInferWithDecreasedSize_second");+ // Reusing the same input should keep the existing command list intact.+ ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))+ << "Expected log to contain 'Reuse command list without update since no tensor change detected' for second "+ "inference, but got: "+ << logCapture.str();++ logCapture.clear();+ ov::Tensor inTensor1 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor1,+ "CompileAndInferWithDecreasedSize_third");+ // A new host tensor with the same shape should still reuse the command list.+ ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))+ << "Expected log to contain 'Reuse command list without update since no tensor change detected' for third "+ "inference, but got: "+ << logCapture.str();++ logCapture.clear();+ ov::Shape shape2 = {1, 720, 720, 16};+ ov::Tensor inTensor3 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape2, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor3,+ "CompileAndInferWithDecreasedSize_fourth");+ // Shrinking the shape should force runtime reconfiguration for the new tensor layout.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for fourth inference with new shape, but "+ "got: "+ << logCapture.str();+}++// Compile, infer with a small shape, then grow the input shape and verify both output correctness and command-list+// reuse behavior.+TEST_P(InferWithHostCompileTests, CompileAndInferWithIncreasedSize) {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ if (!isTargetDevice) {+ GTEST_SKIP() << "Skip test for current device";+ }++ auto model = createModelByName(selectedModelName);+ ScopedLogCapture logCapture;++ core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));+ auto setupResult = prepareRuntimeCompareContext(model);+ if (setupResult.status == RuntimeCompareStatus::fail) {+ FAIL() << setupResult.message;+ }+ if (setupResult.status == RuntimeCompareStatus::skip) {+ GTEST_SKIP() << setupResult.message;+ }++ auto& testContext = setupResult.context;++ // Start with a smaller valid dynamic shape.+ ov::Shape shape = {1, 720, 720, 16};+ ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor,+ "CompileAndInferWithIncreasedSize_first");+ // The first run materializes runtime state for the initial shape.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();++ logCapture.clear();+ inferAndCompare(model, testContext.reqDynamic, testContext.reqReference, "CompileAndInferWithIncreasedSize_second");+ // Reusing the same input should keep the existing command list intact.+ ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))+ << "Expected log to contain 'Reuse command list without update since no tensor change detected' for second "+ "inference, but got: "+ << logCapture.str();++ logCapture.clear();+ ov::Tensor inTensor1 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor1,+ "CompileAndInferWithIncreasedSize_third");+ // A new host tensor with the same shape should still reuse the command list.+ ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))+ << "Expected log to contain 'Reuse command list without update since no tensor change detected' for third "+ "inference, but got: "+ << logCapture.str();++ logCapture.clear();+ ov::Shape shape2 = {1, 720, 1280, 16};+ ov::Tensor inTensor3 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape2, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor3,+ "CompileAndInferWithIncreasedSize_fourth");+ // Growing the shape should force runtime reconfiguration for the new tensor layout.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for fourth inference with new shape, but "+ "got: "+ << logCapture.str();+}++// Exercise imported Level Zero tensors and verify both output correctness and command-list pointer updates.+TEST_P(InferWithHostCompileTests, CompileAndInferWithZeroTensor) {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ if (!isTargetDevice) {+ GTEST_SKIP() << "Skip test for current device";+ }++ auto model = createModelByName(selectedModelName);+ ScopedLogCapture logCapture;++ core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));+ auto setupResult = prepareRuntimeCompareContext(model);+ if (setupResult.status == RuntimeCompareStatus::fail) {+ FAIL() << setupResult.message;+ }+ if (setupResult.status == RuntimeCompareStatus::skip) {+ GTEST_SKIP() << setupResult.message;+ }+ auto& testContext = setupResult.context;++ // Start from a regular host tensor.+ ov::Shape shape = {1, 720, 1280, 16};+ ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ setInputInferAndCompare(model,+ testContext.reqDynamic,+ testContext.reqReference,+ inTensor,+ "CompileAndInferWithZeroTensor_first");++ // The first run materializes runtime state for the initial shape.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();++ logCapture.clear();+ ov::InferRequest reqDynamic1 = testContext.compiledModel.create_infer_request();+ ov::InferRequest reqReference1 = testContext.referenceCompiledModel.create_infer_request();+ setInputInferAndCompare(model, reqDynamic1, reqReference1, inTensor, "CompileAndInferWithZeroTensor_second");+ // A fresh infer request rebuilds runtime state on its first execution.+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();++ logCapture.clear();+ auto outputTensorFromReq = testContext.reqDynamic.get_tensor(model->output());+ setInputInferAndCompare(model,+ reqDynamic1,+ reqReference1,+ outputTensorFromReq,+ "CompileAndInferWithZeroTensor_third");+ // Feeding an imported output tensor, ptr change detected and rebuild runtime+ // TODO: Update commandlist once dynamic stride supported+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for third inference, but got: "+ << logCapture.str();++ logCapture.clear();+ auto zeroContext = core->get_default_context(target_device);+ auto inputHostTensorForForthInfer = zeroContext.create_host_tensor(model->input().get_element_type(), shape);+ auto hostTensorSourceForForthInfer =+ ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);+ ASSERT_EQ(hostTensorSourceForForthInfer.get_byte_size(), inputHostTensorForForthInfer.get_byte_size())+ << "Source and destination tensors must have identical byte sizes for copy";+ std::memcpy(inputHostTensorForForthInfer.data(),+ hostTensorSourceForForthInfer.data(),+ hostTensorSourceForForthInfer.get_byte_size());+ setInputInferAndCompare(model,+ reqDynamic1,+ reqReference1,+ inputHostTensorForForthInfer,+ "CompileAndInferWithZeroTensor_fourth");+ // Feeding a context-allocated host tensor, ptr change detected and rebuild runtime+ // TODO: Update commandlist once dynamic stride supported+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for fourth inference, but got: "+ << logCapture.str();++ logCapture.clear();+ auto outputShape = reqDynamic1.get_tensor(model->output()).get_shape();+ auto zeroOutputTensorForFifthInfer = zeroContext.create_host_tensor(model->input().get_element_type(), outputShape);+ auto hostTensorSourceForOutputForFifthInfer =+ ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), outputShape, 100, 0);+ ASSERT_EQ(hostTensorSourceForOutputForFifthInfer.get_byte_size(), zeroOutputTensorForFifthInfer.get_byte_size())+ << "Source and destination tensors must have identical byte sizes for copy";+ std::memcpy(zeroOutputTensorForFifthInfer.data(),+ hostTensorSourceForOutputForFifthInfer.data(),+ hostTensorSourceForOutputForFifthInfer.get_byte_size());+ OV_ASSERT_NO_THROW(reqDynamic1.set_tensor(model->output(), zeroOutputTensorForFifthInfer));+ inferAndCompare(model, reqDynamic1, reqReference1, "CompileAndInferWithZeroTensor_fifth");+ // Feeding a context-allocated host tensor as output, ptr change detected and rebuild runtime+ // TODO: Update commandlist once dynamic stride supported+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for fifth inference, but got: "+ << logCapture.str();++ logCapture.clear();+ auto inputTensorForSixthInfer =+ ov::test::utils::create_and_fill_tensor(model->input().get_element_type(),+ reqDynamic1.get_tensor(model->input()).get_shape(),+ 100,+ 0);++ auto outputShapeForSixthInfer = reqDynamic1.get_tensor(model->output()).get_shape();+ auto zeroOutputTensorForSixthInfer =+ zeroContext.create_host_tensor(model->input().get_element_type(), outputShapeForSixthInfer);+ auto hostTensorSourceForOutputForSixthInfer =+ ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), outputShapeForSixthInfer, 100, 0);+ ASSERT_EQ(hostTensorSourceForOutputForSixthInfer.get_byte_size(), zeroOutputTensorForSixthInfer.get_byte_size())+ << "Source and destination tensors must have identical byte sizes for copy";+ std::memcpy(zeroOutputTensorForSixthInfer.data(),+ hostTensorSourceForOutputForSixthInfer.data(),+ hostTensorSourceForOutputForSixthInfer.get_byte_size());+ OV_ASSERT_NO_THROW(reqDynamic1.set_tensor(model->output(), zeroOutputTensorForSixthInfer));+ setInputInferAndCompare(model,+ reqDynamic1,+ reqReference1,+ inputTensorForSixthInfer,+ "CompileAndInferWithZeroTensor_sixth");+ // Feeding a context-allocated host tensor, ptr change detected and rebuild runtime+ // TODO: Update commandlist once dynamic stride supported+ ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))+ << "Expected log to contain 'Reset command list to run with runtime' for sixth inference, but got: "+ << logCapture.str();+}++using InferWithDefaultHostCompileTests = InferWithHostCompileTests;++inline bool isByteCodeBlob(const std::string& blob) {+ const size_t headerSize = std::min(blob.size(), size_t{20});+ const std::string_view header(blob.data(), headerSize);+ return header.find("NPUByte\x00") != std::string_view::npos;+};++inline bool isElfBlob(const std::string& blob) {+ const size_t headerSize = std::min(blob.size(), size_t{20});+ const std::string_view header(blob.data(), headerSize);+ return header.find("ELF\x00") != std::string_view::npos;+};++TEST_P(InferWithDefaultHostCompileTests, CompileDynamicModelWithNoHostCompileMode) {+ // Skip test according to plugin specific disabledTestPatterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ if (!isTargetDevice) {+ GTEST_SKIP() << "Skip test for current device";+ }++ auto model = createModelByName(selectedModelName);++ ov::CompiledModel compiledModel;+ // Compilation shall pass since load of npu_mlir_runtime is deffered with NPU_CREATE_EXECUTOR=0+ OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));++ std::stringstream modelStream;+ OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));++ if (modelStream.str().empty()) {+ FAIL() << "Exported model stream is empty";+ }++ if (selectedModelName == "MaxPool_NCHW_DynBatch") {+ ASSERT_TRUE(isElfBlob(modelStream.str())) << "Expected exported model to be an ELF blob";+ } else if (selectedModelName == "MaxPool_NCHW") {+ ASSERT_TRUE(isByteCodeBlob(modelStream.str())) << "Expected exported model to be a bytecode";+ }++ ov::InferRequest reqDynamic;+ try {+ ov::CompiledModel importedModel = core->import_model(modelStream, target_device);+ reqDynamic = importedModel.create_infer_request();+ } catch (const ov::Exception& e) {+ if (std::string(e.what()).find("Cannot load library") == std::string::npos) {+ FAIL() << "Expected exception message to contain 'Cannot load library', but got: " << e.what();+ } else {+ GTEST_SKIP() << "Cannot load library, skip test.";+ }+ }++ OV_ASSERT_NO_THROW(reqDynamic.infer());+}++} // namespace behavior+} // namespace test+} // namespace ovconst std::vector<std::string> devices = {"NPU.4000", "NPU.5010"};diff --git a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp b/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hppdeleted file mode 100644index 53294d2cb59..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/dynamic_host_pipeline/infer_with_host_compile.hpp+++ /dev/null@@ -1,740 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <algorithm>-#include <common_test_utils/ov_tensor_utils.hpp>-#include <cstring>-#include <functional>-#include <iostream>-#include <sstream>-#include <string>-#include <string_view>-#include <tuple>-#include <vector>--#include "intel_npu/npu_private_properties.hpp"-#include "openvino/openvino.hpp"-#include "openvino/opsets/opset6.hpp"-#include "openvino/pass/manager.hpp"-#include "openvino/pass/serialize.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov {-namespace test {-namespace behavior {--inline std::shared_ptr<ov::Model> createMaxPoolModel(bool dynamicBatch = false, bool nhwcLayout = true) {- std::shared_ptr<ov::op::v0::Parameter> input;- if (dynamicBatch) {- input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16,- ov::PartialShape{ov::Dimension(1, 10), 16, 720, 1280});- } else {- input = std::make_shared<ov::op::v0::Parameter>(- ov::element::f16,- ov::PartialShape{1, 16, ov::Dimension(10, 720), ov::Dimension(10, 1280)});- }-- std::string inputName = "input1";- input->set_friendly_name(inputName);- input->get_output_tensor(0).set_names({inputName});- if (!nhwcLayout)- input->set_layout("NCHW");- auto maxpool = std::make_shared<ov::op::v1::MaxPool>(input,- Strides{1, 1},- Shape{0, 0},- Shape{0, 0},- Shape{1, 1},- op::RoundingType::FLOOR,- op::PadType::EXPLICIT);- maxpool->set_friendly_name("MaxPool_2");-- auto result = std::make_shared<ov::op::v0::Result>(maxpool);- std::string outputName = "output";- if (!nhwcLayout)- result->set_layout("NCHW");- result->set_friendly_name(outputName);- result->get_output_tensor(0).set_names({outputName});-- auto model = std::make_shared<Model>(ResultVector{result}, ParameterVector{input}, "MaxPool");-- // making input and output to be NHWC- if (nhwcLayout) {- auto preProc = ov::preprocess::PrePostProcessor(model);- preProc.input(0).tensor().set_layout("NHWC");- preProc.input(0).model().set_layout("NCHW");- preProc.output(0).tensor().set_layout("NHWC");- preProc.output(0).model().set_layout("NCHW");-- model = preProc.build();- }-- return model;-}--inline std::shared_ptr<ov::Model> createCustomNetModel() {- auto input = std::make_shared<ov::op::v0::Parameter>(- ov::element::f16,- ov::PartialShape{1, 16, ov::Dimension(1, 1080), ov::Dimension(10, 1920)});- input->set_friendly_name("Parameter_59");-- auto make_conv_add = [](const ov::Output<ov::Node>& data,- const std::string& convName,- const std::string& addName,- float weightValue,- float biasValue) -> ov::Output<ov::Node> {- const std::vector<float> weightValues(16 * 16, weightValue);- const std::vector<float> biasValues(16, biasValue);-- auto weights = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{16, 16, 1, 1}, weightValues);- auto conv = std::make_shared<ov::op::v1::Convolution>(data,- weights,- ov::Strides{1, 1},- ov::CoordinateDiff{0, 0},- ov::CoordinateDiff{0, 0},- ov::Strides{1, 1},- ov::op::PadType::EXPLICIT);- conv->set_friendly_name(convName);-- auto bias = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1, 16, 1, 1}, biasValues);- auto add = std::make_shared<ov::op::v1::Add>(conv, bias);- add->set_friendly_name(addName);- return add;- };-- auto x = make_conv_add(input, "Convolution_61", "Add_63", 0.01f, 0.001f);- x = make_conv_add(x, "Convolution_65", "Add_67", 0.011f, 0.001f);-- auto relu68 = std::make_shared<ov::op::v0::Relu>(x);- relu68->set_friendly_name("Relu_68");- x = relu68;-- x = make_conv_add(x, "Convolution_70", "Add_72", 0.012f, 0.001f);- auto relu73 = std::make_shared<ov::op::v0::Relu>(x);- relu73->set_friendly_name("Relu_73");- x = relu73;-- x = make_conv_add(x, "Convolution_75", "Add_77", 0.013f, 0.001f);- auto relu78 = std::make_shared<ov::op::v0::Relu>(x);- relu78->set_friendly_name("Relu_78");- x = relu78;-- x = make_conv_add(x, "Convolution_82", "Add_84", 0.014f, 0.001f);- auto relu85 = std::make_shared<ov::op::v0::Relu>(x);- relu85->set_friendly_name("Relu_85");- x = relu85;-- x = make_conv_add(x, "Convolution_87", "Add_89", 0.015f, 0.001f);- auto relu90 = std::make_shared<ov::op::v0::Relu>(x);- relu90->set_friendly_name("Relu_90");- x = relu90;-- x = make_conv_add(x, "Convolution_92", "Add_94", 0.016f, 0.001f);- auto relu95 = std::make_shared<ov::op::v0::Relu>(x);- relu95->set_friendly_name("Relu_95");- x = relu95;-- auto multiplyScale = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{1, 16, 1, 1}, {0.5f});- auto multiply97 = std::make_shared<ov::op::v1::Multiply>(x, multiplyScale);- multiply97->set_friendly_name("Multiply_97");-- auto add98 = std::make_shared<ov::op::v1::Add>(multiply97, multiply97);- add98->set_friendly_name("Add_98");-- x = make_conv_add(add98, "Convolution_100", "Add_102", 0.017f, 0.001f);-- auto result = std::make_shared<ov::op::v0::Result>(x);- result->set_friendly_name("Result_104");-- auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input}, "CustomNet");-- // making input and output to be NHWC- auto preProc = ov::preprocess::PrePostProcessor(model);- preProc.input(0).tensor().set_layout("NHWC");- preProc.input(0).model().set_layout("NCHW");- preProc.output(0).tensor().set_layout("NHWC");- preProc.output(0).model().set_layout("NCHW");-- model = preProc.build();-- return model;-}--using InferWithHostCompileParams = std::tuple<std::string, // Device name- ov::AnyMap, // Config- std::string // Model name- >;--// These tests are required by the NPU plugin to verify the support of dynamic shape during-// compilation and inference on different NPU drivers-class InferWithHostCompileTests : public testing::WithParamInterface<InferWithHostCompileParams>,- public OVInferRequestTestBase {-public:- enum class RuntimeCompareStatus {- ready,- skip,- fail,- };-- struct ScopedLogCapture {- ScopedLogCapture();- ~ScopedLogCapture();-- void clear();- std::string str() const;-- private:- std::stringstream stream;- std::function<void(std::string_view)> callback;-- friend class InferWithHostCompileTests;- };-- struct RuntimeCompareContext {- std::shared_ptr<ov::Model> model;- ov::CompiledModel compiledModel;- ov::CompiledModel referenceCompiledModel;- ov::InferRequest reqDynamic;- ov::InferRequest reqReference;- };-- struct RuntimeCompareSetupResult {- RuntimeCompareStatus status = RuntimeCompareStatus::ready;- std::string message;- RuntimeCompareContext context;- };-- static std::string getTestCaseName(testing::TestParamInfo<InferWithHostCompileParams> obj) {- std::string target_device;- ov::AnyMap configuration;- std::string modelName;- std::tie(target_device, configuration, modelName) = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '.');- std::ostringstream result;- result << "targetDevice=" << target_device << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- result << "_";- }- }- result << "model=" << modelName;- return result.str();- }-- void SetUp() {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration, selectedModelName) = this->GetParam();-- configuration[ov::intel_npu::compile_log_level.name()] = ov::log::Level::ERR;- std::vector<std::string> deviceNames =- core->get_property("NPU", ov::available_devices.name()).as<std::vector<std::string>>();- for (auto name : deviceNames) {- if (target_device.find(name) != std::string::npos) {- isTargetDevice = true;- break;- }- }- originalLogLevel = core->get_property("NPU", ov::log::level.name()).as<ov::log::Level>();-- APIBaseTest::SetUp();- }-- void TearDown() {- core->set_property("NPU", ov::log::level(originalLogLevel));- }-- static void compareInferenceResult(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference);-- static void inferAndCompare(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference,- const std::string& dumpPrefix);-- static void setInputInferAndCompare(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference,- const ov::Tensor& inputTensor,- const std::string& dumpPrefix);-- static bool logContains(const ScopedLogCapture& logCapture, const std::string& expectedEntry);-- static std::shared_ptr<ov::Model> createModelByName(const std::string& modelName);-- RuntimeCompareSetupResult prepareRuntimeCompareContext(const std::shared_ptr<ov::Model>& model);--protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::string selectedModelName;- bool isTargetDevice = false;- ov::log::Level originalLogLevel = ov::log::Level::ERR;-};--InferWithHostCompileTests::ScopedLogCapture::ScopedLogCapture()- : callback([this](std::string_view s) {- stream << s << std::endl;- }) {- ov::util::set_log_callback(callback);-}--InferWithHostCompileTests::ScopedLogCapture::~ScopedLogCapture() {- ov::util::reset_log_callback();-}--void InferWithHostCompileTests::ScopedLogCapture::clear() {- stream.str("");- stream.clear();-}--std::string InferWithHostCompileTests::ScopedLogCapture::str() const {- return stream.str();-}--void InferWithHostCompileTests::compareInferenceResult(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference) {- const auto inputTensor = reqDynamic.get_input_tensor(0);- const auto npuOutputTensor = reqDynamic.get_tensor(model->output());- const auto referenceOutputTensor = reqReference.get_tensor(model->output());-- ov::test::utils::compare(referenceOutputTensor, npuOutputTensor, npuOutputTensor.get_element_type());-}--void InferWithHostCompileTests::inferAndCompare(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference,- const std::string& stage) {- OV_ASSERT_NO_THROW(reqDynamic.infer());- OV_ASSERT_NO_THROW(reqReference.infer());- try {- compareInferenceResult(model, reqDynamic, reqReference);- } catch (const ov::Exception& e) {- FAIL() << "Inference result comparison failed at stage " << stage << ": " << e.what();- }-}--void InferWithHostCompileTests::setInputInferAndCompare(const std::shared_ptr<ov::Model>& model,- ov::InferRequest& reqDynamic,- ov::InferRequest& reqReference,- const ov::Tensor& inputTensor,- const std::string& stage) {- OV_ASSERT_NO_THROW(reqDynamic.set_input_tensor(0, inputTensor));- OV_ASSERT_NO_THROW(reqReference.set_input_tensor(0, inputTensor));- inferAndCompare(model, reqDynamic, reqReference, stage);-}--bool InferWithHostCompileTests::logContains(const ScopedLogCapture& logCapture, const std::string& expectedEntry) {- return logCapture.str().find(expectedEntry) != std::string::npos;-}--std::shared_ptr<ov::Model> InferWithHostCompileTests::createModelByName(const std::string& modelName) {- if (modelName == "CustomNet") {- return createCustomNetModel();- }- if (modelName == "MaxPool") {- return createMaxPoolModel();- }- if (modelName == "MaxPool_NCHW") {- return createMaxPoolModel(false, false);- }- if (modelName == "MaxPool_NCHW_DynBatch") {- return createMaxPoolModel(true, false);- }-- OPENVINO_THROW("Unknown model name for InferWithHostCompileTests: ", modelName);-}--InferWithHostCompileTests::RuntimeCompareSetupResult InferWithHostCompileTests::prepareRuntimeCompareContext(- const std::shared_ptr<ov::Model>& model) {- RuntimeCompareSetupResult result;- result.context.model = model;-- try {- result.context.compiledModel = core->compile_model(model, target_device, configuration);- } catch (const ov::Exception& e) {- result.status = RuntimeCompareStatus::fail;- result.message = std::string("Failed to compile model for target device: ") + e.what();- return result;- }-- try {- result.context.referenceCompiledModel = core->compile_model(model, ov::test::utils::DEVICE_TEMPLATE);- } catch (const ov::Exception& e) {- result.status = RuntimeCompareStatus::skip;- result.message = std::string("CPU plugin is not available for reference comparison: ") + e.what();- return result;- }-- try {- result.context.reqDynamic = result.context.compiledModel.create_infer_request();- } catch (const ov::Exception& e) {- result.status = RuntimeCompareStatus::fail;- result.message = std::string("Failed to create dynamic infer request: ") + e.what();- return result;- }-- try {- result.context.reqReference = result.context.referenceCompiledModel.create_infer_request();- } catch (const ov::Exception& e) {- result.status = RuntimeCompareStatus::fail;- result.message = std::string("Failed to create reference infer request: ") + e.what();- return result;- }- return result;-}--TEST_P(InferWithHostCompileTests, CompileAndImportAndInfer) {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- if (!isTargetDevice) {- GTEST_SKIP() << "Skip test for current device";- }- auto model = createModelByName(selectedModelName);-- ov::CompiledModel compiledModel;-- OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));-- std::stringstream modelStream;- OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));-- ov::InferRequest reqDynamic;- ov::CompiledModel importedModel;- OV_ASSERT_NO_THROW(importedModel = core->import_model(modelStream, target_device));- OV_ASSERT_NO_THROW(reqDynamic = importedModel.create_infer_request());- OV_ASSERT_NO_THROW(reqDynamic.infer());-}--// Compile, infer with a large shape, then shrink the input shape and verify both output correctness and command-list-// reuse behavior.-TEST_P(InferWithHostCompileTests, CompileAndInferWithDecreasedSize) {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- if (!isTargetDevice) {- GTEST_SKIP() << "Skip test for current device";- }-- auto model = createModelByName(selectedModelName);- ScopedLogCapture logCapture;-- core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));- auto setupResult = prepareRuntimeCompareContext(model);- if (setupResult.status == RuntimeCompareStatus::fail) {- FAIL() << setupResult.message;- }- if (setupResult.status == RuntimeCompareStatus::skip) {- GTEST_SKIP() << setupResult.message;- }- auto& testContext = setupResult.context;-- // Start with the largest shape in the dynamic range.- ov::Shape shape = {1, 720, 1280, 16};- ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor,- "CompileAndInferWithDecreasedSize_first");- // The first run materializes runtime state for the initial shape.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();-- logCapture.clear();- inferAndCompare(model, testContext.reqDynamic, testContext.reqReference, "CompileAndInferWithDecreasedSize_second");- // Reusing the same input should keep the existing command list intact.- ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))- << "Expected log to contain 'Reuse command list without update since no tensor change detected' for second "- "inference, but got: "- << logCapture.str();-- logCapture.clear();- ov::Tensor inTensor1 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor1,- "CompileAndInferWithDecreasedSize_third");- // A new host tensor with the same shape should still reuse the command list.- ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))- << "Expected log to contain 'Reuse command list without update since no tensor change detected' for third "- "inference, but got: "- << logCapture.str();-- logCapture.clear();- ov::Shape shape2 = {1, 720, 720, 16};- ov::Tensor inTensor3 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape2, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor3,- "CompileAndInferWithDecreasedSize_fourth");- // Shrinking the shape should force runtime reconfiguration for the new tensor layout.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for fourth inference with new shape, but "- "got: "- << logCapture.str();-}--// Compile, infer with a small shape, then grow the input shape and verify both output correctness and command-list-// reuse behavior.-TEST_P(InferWithHostCompileTests, CompileAndInferWithIncreasedSize) {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- if (!isTargetDevice) {- GTEST_SKIP() << "Skip test for current device";- }-- auto model = createModelByName(selectedModelName);- ScopedLogCapture logCapture;-- core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));- auto setupResult = prepareRuntimeCompareContext(model);- if (setupResult.status == RuntimeCompareStatus::fail) {- FAIL() << setupResult.message;- }- if (setupResult.status == RuntimeCompareStatus::skip) {- GTEST_SKIP() << setupResult.message;- }-- auto& testContext = setupResult.context;-- // Start with a smaller valid dynamic shape.- ov::Shape shape = {1, 720, 720, 16};- ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor,- "CompileAndInferWithIncreasedSize_first");- // The first run materializes runtime state for the initial shape.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();-- logCapture.clear();- inferAndCompare(model, testContext.reqDynamic, testContext.reqReference, "CompileAndInferWithIncreasedSize_second");- // Reusing the same input should keep the existing command list intact.- ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))- << "Expected log to contain 'Reuse command list without update since no tensor change detected' for second "- "inference, but got: "- << logCapture.str();-- logCapture.clear();- ov::Tensor inTensor1 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor1,- "CompileAndInferWithIncreasedSize_third");- // A new host tensor with the same shape should still reuse the command list.- ASSERT_TRUE(logContains(logCapture, "Reuse command list without update since no tensor change detected"))- << "Expected log to contain 'Reuse command list without update since no tensor change detected' for third "- "inference, but got: "- << logCapture.str();-- logCapture.clear();- ov::Shape shape2 = {1, 720, 1280, 16};- ov::Tensor inTensor3 = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape2, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor3,- "CompileAndInferWithIncreasedSize_fourth");- // Growing the shape should force runtime reconfiguration for the new tensor layout.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for fourth inference with new shape, but "- "got: "- << logCapture.str();-}--// Exercise imported Level Zero tensors and verify both output correctness and command-list pointer updates.-TEST_P(InferWithHostCompileTests, CompileAndInferWithZeroTensor) {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- if (!isTargetDevice) {- GTEST_SKIP() << "Skip test for current device";- }-- auto model = createModelByName(selectedModelName);- ScopedLogCapture logCapture;-- core->set_property("NPU", ov::log::level(ov::log::Level::DEBUG));- auto setupResult = prepareRuntimeCompareContext(model);- if (setupResult.status == RuntimeCompareStatus::fail) {- FAIL() << setupResult.message;- }- if (setupResult.status == RuntimeCompareStatus::skip) {- GTEST_SKIP() << setupResult.message;- }- auto& testContext = setupResult.context;-- // Start from a regular host tensor.- ov::Shape shape = {1, 720, 1280, 16};- ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- setInputInferAndCompare(model,- testContext.reqDynamic,- testContext.reqReference,- inTensor,- "CompileAndInferWithZeroTensor_first");-- // The first run materializes runtime state for the initial shape.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();-- logCapture.clear();- ov::InferRequest reqDynamic1 = testContext.compiledModel.create_infer_request();- ov::InferRequest reqReference1 = testContext.referenceCompiledModel.create_infer_request();- setInputInferAndCompare(model, reqDynamic1, reqReference1, inTensor, "CompileAndInferWithZeroTensor_second");- // A fresh infer request rebuilds runtime state on its first execution.- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime', but got: " << logCapture.str();-- logCapture.clear();- auto outputTensorFromReq = testContext.reqDynamic.get_tensor(model->output());- setInputInferAndCompare(model,- reqDynamic1,- reqReference1,- outputTensorFromReq,- "CompileAndInferWithZeroTensor_third");- // Feeding an imported output tensor, ptr change detected and rebuild runtime- // TODO: Update commandlist once dynamic stride supported- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for third inference, but got: "- << logCapture.str();-- logCapture.clear();- auto zeroContext = core->get_default_context(target_device);- auto inputHostTensorForForthInfer = zeroContext.create_host_tensor(model->input().get_element_type(), shape);- auto hostTensorSourceForForthInfer =- ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), shape, 100, 0);- ASSERT_EQ(hostTensorSourceForForthInfer.get_byte_size(), inputHostTensorForForthInfer.get_byte_size())- << "Source and destination tensors must have identical byte sizes for copy";- std::memcpy(inputHostTensorForForthInfer.data(),- hostTensorSourceForForthInfer.data(),- hostTensorSourceForForthInfer.get_byte_size());- setInputInferAndCompare(model,- reqDynamic1,- reqReference1,- inputHostTensorForForthInfer,- "CompileAndInferWithZeroTensor_fourth");- // Feeding a context-allocated host tensor, ptr change detected and rebuild runtime- // TODO: Update commandlist once dynamic stride supported- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for fourth inference, but got: "- << logCapture.str();-- logCapture.clear();- auto outputShape = reqDynamic1.get_tensor(model->output()).get_shape();- auto zeroOutputTensorForFifthInfer = zeroContext.create_host_tensor(model->input().get_element_type(), outputShape);- auto hostTensorSourceForOutputForFifthInfer =- ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), outputShape, 100, 0);- ASSERT_EQ(hostTensorSourceForOutputForFifthInfer.get_byte_size(), zeroOutputTensorForFifthInfer.get_byte_size())- << "Source and destination tensors must have identical byte sizes for copy";- std::memcpy(zeroOutputTensorForFifthInfer.data(),- hostTensorSourceForOutputForFifthInfer.data(),- hostTensorSourceForOutputForFifthInfer.get_byte_size());- OV_ASSERT_NO_THROW(reqDynamic1.set_tensor(model->output(), zeroOutputTensorForFifthInfer));- inferAndCompare(model, reqDynamic1, reqReference1, "CompileAndInferWithZeroTensor_fifth");- // Feeding a context-allocated host tensor as output, ptr change detected and rebuild runtime- // TODO: Update commandlist once dynamic stride supported- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for fifth inference, but got: "- << logCapture.str();-- logCapture.clear();- auto inputTensorForSixthInfer =- ov::test::utils::create_and_fill_tensor(model->input().get_element_type(),- reqDynamic1.get_tensor(model->input()).get_shape(),- 100,- 0);-- auto outputShapeForSixthInfer = reqDynamic1.get_tensor(model->output()).get_shape();- auto zeroOutputTensorForSixthInfer =- zeroContext.create_host_tensor(model->input().get_element_type(), outputShapeForSixthInfer);- auto hostTensorSourceForOutputForSixthInfer =- ov::test::utils::create_and_fill_tensor(model->input().get_element_type(), outputShapeForSixthInfer, 100, 0);- ASSERT_EQ(hostTensorSourceForOutputForSixthInfer.get_byte_size(), zeroOutputTensorForSixthInfer.get_byte_size())- << "Source and destination tensors must have identical byte sizes for copy";- std::memcpy(zeroOutputTensorForSixthInfer.data(),- hostTensorSourceForOutputForSixthInfer.data(),- hostTensorSourceForOutputForSixthInfer.get_byte_size());- OV_ASSERT_NO_THROW(reqDynamic1.set_tensor(model->output(), zeroOutputTensorForSixthInfer));- setInputInferAndCompare(model,- reqDynamic1,- reqReference1,- inputTensorForSixthInfer,- "CompileAndInferWithZeroTensor_sixth");- // Feeding a context-allocated host tensor, ptr change detected and rebuild runtime- // TODO: Update commandlist once dynamic stride supported- ASSERT_TRUE(logContains(logCapture, "Reset command list to run with runtime"))- << "Expected log to contain 'Reset command list to run with runtime' for sixth inference, but got: "- << logCapture.str();-}--using InferWithDefaultHostCompileTests = InferWithHostCompileTests;--inline bool isByteCodeBlob(const std::string& blob) {- const size_t headerSize = std::min(blob.size(), size_t{20});- const std::string_view header(blob.data(), headerSize);- return header.find("NPUByte\x00") != std::string_view::npos;-};--inline bool isElfBlob(const std::string& blob) {- const size_t headerSize = std::min(blob.size(), size_t{20});- const std::string_view header(blob.data(), headerSize);- return header.find("ELF\x00") != std::string_view::npos;-};--TEST_P(InferWithDefaultHostCompileTests, CompileDynamicModelWithNoHostCompileMode) {- // Skip test according to plugin specific disabledTestPatterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- if (!isTargetDevice) {- GTEST_SKIP() << "Skip test for current device";- }-- auto model = createModelByName(selectedModelName);-- ov::CompiledModel compiledModel;- // Compilation shall pass since load of npu_mlir_runtime is deffered with NPU_CREATE_EXECUTOR=0- OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));-- std::stringstream modelStream;- OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));-- if (modelStream.str().empty()) {- FAIL() << "Exported model stream is empty";- }-- if (selectedModelName == "MaxPool_NCHW_DynBatch") {- ASSERT_TRUE(isElfBlob(modelStream.str())) << "Expected exported model to be an ELF blob";- } else if (selectedModelName == "MaxPool_NCHW") {- ASSERT_TRUE(isByteCodeBlob(modelStream.str())) << "Expected exported model to be a bytecode";- }-- ov::InferRequest reqDynamic;- try {- ov::CompiledModel importedModel = core->import_model(modelStream, target_device);- reqDynamic = importedModel.create_infer_request();- } catch (const ov::Exception& e) {- if (std::string(e.what()).find("Cannot load library") == std::string::npos) {- FAIL() << "Expected exception message to contain 'Cannot load library', but got: " << e.what();- } else {- GTEST_SKIP() << "Cannot load library, skip test.";- }- }-- OV_ASSERT_NO_THROW(reqDynamic.infer());-}--} // namespace behavior-} // namespace test-} // namespace ov\ No newline at end of filediff --git a/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.cpp b/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.cppindex 79b06b75f30..da0891d1645 100644--- a/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.cpp@@ -2,11 +2,135 @@// SPDX-License-Identifier: Apache-2.0//-#include "behavior/fail_gracefully_forward_compatibility.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>++#include <exception>+#include <openvino/core/any.hpp>+#include <openvino/core/node_vector.hpp>+#include <openvino/op/op.hpp>+#include <openvino/runtime/compiled_model.hpp>+#include <openvino/runtime/core.hpp>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common_test_utils/node_builders/constant.hpp"#include "intel_npu/config/options.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {++class UnsupportedTestOperation : public ov::op::Op {+public:+ OPENVINO_OP("UnsupportedTestOperation");++ UnsupportedTestOperation() = default;+ explicit UnsupportedTestOperation(const ov::Output<ov::Node>& arg) : Op({arg}) {+ constructor_validate_and_infer_types();+ }++ void validate_and_infer_types() override {+ auto input_pshape = get_input_partial_shape(0);+ auto input_shape = input_pshape.to_shape();+ ov::Shape output_shape(input_shape);+ set_output_type(0, get_input_element_type(0), ov::PartialShape(output_shape));+ }++ bool visit_attributes(AttributeVisitor& /*visitor*/) override;++ std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override {+ OPENVINO_ASSERT(new_args.size() == 1, "Incorrect number of new arguments");+ return std::make_shared<UnsupportedTestOperation>(new_args.at(0));+ }+};++class FailGracefullyTest : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ ov_model = createModelWithUnknownNode();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }++private:+ std::shared_ptr<ov::Model> createModelWithUnknownNode() {+ const ov::Shape input_shape = {1, 4096};+ const ov::element::Type precision = ov::element::f32;++ ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{input_shape})};+ auto constant = ov::test::utils::make_constant(precision, ov::Shape{4096, 1024});+ auto custom_op = std::make_shared<UnsupportedTestOperation>(constant);++ ov::OutputVector results{custom_op};+ return std::make_shared<ov::Model>(results, ov::ParameterVector{params}, "CustomOpModel");+ }+};++TEST_P(FailGracefullyTest, OnUnsupportedOperator) {+ auto compilerType = configuration[ov::intel_npu::compiler_type.name()].as<std::string>();+ try {+ core->compile_model(ov_model, target_device, configuration);+ } catch (std::exception& ex) {+ // TODO: the below error messages will be improved in E#64716+ if (compilerType == "PLUGIN") {+ EXPECT_THAT(ex.what(),+ AllOf(HasSubstr("Unsupported operation"), HasSubstr("with type UnsupportedTestOperation")));+ } else if (compilerType == "DRIVER") {+ EXPECT_THAT(ex.what(), AllOf(HasSubstr("Failed to compile network")));+ }+ return;+ }++ ASSERT_FALSE(true) << "Oops, compilation of unsupported op happened";+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.hpp b/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.hppdeleted file mode 100644index 092a1577bce..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/fail_gracefully_forward_compatibility.hpp+++ /dev/null@@ -1,133 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <exception>-#include <openvino/core/any.hpp>-#include <openvino/core/node_vector.hpp>-#include <openvino/op/op.hpp>-#include <openvino/runtime/compiled_model.hpp>-#include <openvino/runtime/core.hpp>--#include "common/npu_test_env_cfg.hpp"-#include "common_test_utils/node_builders/constant.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {--class UnsupportedTestOperation : public ov::op::Op {-public:- OPENVINO_OP("UnsupportedTestOperation");-- UnsupportedTestOperation() = default;- explicit UnsupportedTestOperation(const ov::Output<ov::Node>& arg) : Op({arg}) {- constructor_validate_and_infer_types();- }-- void validate_and_infer_types() override {- auto input_pshape = get_input_partial_shape(0);- auto input_shape = input_pshape.to_shape();- ov::Shape output_shape(input_shape);- set_output_type(0, get_input_element_type(0), ov::PartialShape(output_shape));- }-- bool visit_attributes(AttributeVisitor& /*visitor*/) override;-- std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override {- OPENVINO_ASSERT(new_args.size() == 1, "Incorrect number of new arguments");- return std::make_shared<UnsupportedTestOperation>(new_args.at(0));- }-};--class FailGracefullyTest : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- ov_model = createModelWithUnknownNode();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }--private:- std::shared_ptr<ov::Model> createModelWithUnknownNode() {- const ov::Shape input_shape = {1, 4096};- const ov::element::Type precision = ov::element::f32;-- ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{input_shape})};- auto constant = ov::test::utils::make_constant(precision, ov::Shape{4096, 1024});- auto custom_op = std::make_shared<UnsupportedTestOperation>(constant);-- ov::OutputVector results{custom_op};- return std::make_shared<ov::Model>(results, ov::ParameterVector{params}, "CustomOpModel");- }-};--TEST_P(FailGracefullyTest, OnUnsupportedOperator) {- auto compilerType = configuration[ov::intel_npu::compiler_type.name()].as<std::string>();- try {- core->compile_model(ov_model, target_device, configuration);- } catch (std::exception& ex) {- // TODO: the below error messages will be improved in E#64716- if (compilerType == "PLUGIN") {- EXPECT_THAT(ex.what(),- AllOf(HasSubstr("Unsupported operation"), HasSubstr("with type UnsupportedTestOperation")));- } else if (compilerType == "DRIVER") {- EXPECT_THAT(ex.what(), AllOf(HasSubstr("Failed to compile network")));- }- return;- }-- ASSERT_FALSE(true) << "Oops, compilation of unsupported op happened";-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.cpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.cppindex a7e71e45794..fc682e9cdac 100644--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.cpp@@ -2,11 +2,98 @@// SPDX-License-Identifier: Apache-2.0//-#include "downgrade_interpolate11.hpp"-#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "openvino/op/constant.hpp"+#include "openvino/op/interpolate.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {+class DriverCompilerAdapterDowngradeInterpolate11TestNPU :+ public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ result << "model="+ << "Interpolate11Model"+ << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov_model = createInterpolate11Model();+ OVPluginTestBase::SetUp();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }++private:+ std::shared_ptr<ov::Model> createInterpolate11Model() {+ using InterpolateAttrs = op::v11::Interpolate::InterpolateAttrs;+ using InterpolateMode = op::v11::Interpolate::InterpolateMode;+ using ShapeCalcMode = op::v11::Interpolate::ShapeCalcMode;+ using TransformMode = op::v11::Interpolate::CoordinateTransformMode;+ using NearestMode = op::v11::Interpolate::NearestMode;+ const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{2, 2, 30, 60});+ const auto scales =+ ov::op::v0::Constant::create(ov::element::f32, ov::Shape{2}, std::vector<float>{0.5f, 0.5f});+ const auto axes = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, std::vector<int64_t>{2, 3});+ // Only modes of NEAREST, LINEAR, LINEAR_ONNX and CUBIC are supported for ConvertInterpolate11ToInterpolate4,+ // here we use mode of NEAREST .+ const InterpolateAttrs attrs{InterpolateMode::NEAREST,+ ShapeCalcMode::SCALES,+ std::vector<size_t>{0, 0, 0, 0},+ std::vector<size_t>{0, 0, 0, 0},+ TransformMode::HALF_PIXEL,+ NearestMode::ROUND_PREFER_FLOOR,+ false,+ -0.75};+ const auto interpolate = std::make_shared<ov::op::v11::Interpolate>(data, scales, axes, attrs);+ ov::ResultVector results{std::make_shared<ov::op::v0::Result>(interpolate)};+ return std::make_shared<ov::Model>(results, ov::ParameterVector{{data}}, "Interpolate-11");+ }+};++TEST_P(DriverCompilerAdapterDowngradeInterpolate11TestNPU, CheckOpsetVersion) {+ EXPECT_NO_THROW(auto compiledModel = core->compile_model(ov_model, target_device, configuration););+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.hpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.hppdeleted file mode 100644index fb9c8afd16a..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/downgrade_interpolate11.hpp+++ /dev/null@@ -1,97 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "common/npu_test_env_cfg.hpp"--#include "openvino/op/constant.hpp"-#include "openvino/op/interpolate.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {-class DriverCompilerAdapterDowngradeInterpolate11TestNPU :- public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- result << "model="- << "Interpolate11Model"- << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov_model = createInterpolate11Model();- OVPluginTestBase::SetUp();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }--private:- std::shared_ptr<ov::Model> createInterpolate11Model() {- using InterpolateAttrs = op::v11::Interpolate::InterpolateAttrs;- using InterpolateMode = op::v11::Interpolate::InterpolateMode;- using ShapeCalcMode = op::v11::Interpolate::ShapeCalcMode;- using TransformMode = op::v11::Interpolate::CoordinateTransformMode;- using NearestMode = op::v11::Interpolate::NearestMode;- const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{2, 2, 30, 60});- const auto scales =- ov::op::v0::Constant::create(ov::element::f32, ov::Shape{2}, std::vector<float>{0.5f, 0.5f});- const auto axes = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, std::vector<int64_t>{2, 3});- // Only modes of NEAREST, LINEAR, LINEAR_ONNX and CUBIC are supported for ConvertInterpolate11ToInterpolate4,- // here we use mode of NEAREST .- const InterpolateAttrs attrs{InterpolateMode::NEAREST,- ShapeCalcMode::SCALES,- std::vector<size_t>{0, 0, 0, 0},- std::vector<size_t>{0, 0, 0, 0},- TransformMode::HALF_PIXEL,- NearestMode::ROUND_PREFER_FLOOR,- false,- -0.75};- const auto interpolate = std::make_shared<ov::op::v11::Interpolate>(data, scales, axes, attrs);- ov::ResultVector results{std::make_shared<ov::op::v0::Result>(interpolate)};- return std::make_shared<ov::Model>(results, ov::ParameterVector{{data}}, "Interpolate-11");- }-};--TEST_P(DriverCompilerAdapterDowngradeInterpolate11TestNPU, CheckOpsetVersion) {- EXPECT_NO_THROW(auto compiledModel = core->compile_model(ov_model, target_device, configuration););-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.cpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.cppindex 94780c83b47..2c9f656eca6 100644--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.cpp@@ -2,10 +2,96 @@// SPDX-License-Identifier: Apache-2.0//-#include "expected_throw.hpp"+#include <stdlib.h>+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {+class DriverCompilerAdapterExpectedThrowNPU :+ public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDevice();+ ov::AnyMap params;+ for (auto&& v : configuration) {+ params.emplace(v.first, v.second);+ }+ }++ std::string getEnv(const char* name) {+ const char* ret = getenv(name);+ if (!ret)+ return std::string();+ return std::string(ret);+ }+};++TEST_P(DriverCompilerAdapterExpectedThrowNPU, CheckWrongGraphExtAndThrow) {+#if defined(NPU_PLUGIN_DEVELOPER_BUILD)+ const char* name = "ADAPTER_MANUAL_CONFIG";+ std::string env_value = getEnv(name);++#ifdef _WIN32+ _putenv_s(name, "WRONG_VERSION");+#else+ setenv(name, "WRONG_VERSION", 1);+#endif++ EXPECT_THROW(auto compiledModel = core->compile_model(ov_model, target_device, configuration);, std::exception);++#ifdef _WIN32+ _putenv_s(name, env_value.c_str());+#else+ if (!env_value.empty()) {+ setenv(name, env_value.c_str(), 1);+ } else {+ unsetenv(name);+ }+#endif+#endif+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.hpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.hppdeleted file mode 100644index 975886f2e50..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/expected_throw.hpp+++ /dev/null@@ -1,94 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <stdlib.h>--#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "common/npu_test_env_cfg.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {-class DriverCompilerAdapterExpectedThrowNPU :- public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDevice();- ov::AnyMap params;- for (auto&& v : configuration) {- params.emplace(v.first, v.second);- }- }-- std::string getEnv(const char* name) {- const char* ret = getenv(name);- if (!ret)- return std::string();- return std::string(ret);- }-};--TEST_P(DriverCompilerAdapterExpectedThrowNPU, CheckWrongGraphExtAndThrow) {-#if defined(NPU_PLUGIN_DEVELOPER_BUILD)- const char* name = "ADAPTER_MANUAL_CONFIG";- std::string env_value = getEnv(name);--#ifdef _WIN32- _putenv_s(name, "WRONG_VERSION");-#else- setenv(name, "WRONG_VERSION", 1);-#endif-- EXPECT_THROW(auto compiledModel = core->compile_model(ov_model, target_device, configuration);, std::exception);--#ifdef _WIN32- _putenv_s(name, env_value.c_str());-#else- if (!env_value.empty()) {- setenv(name, env_value.c_str(), 1);- } else {- unsetenv(name);- }-#endif-#endif-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.cpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.cppindex e249fe320f9..5739d52b489 100644--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.cpp@@ -2,11 +2,122 @@// SPDX-License-Identifier: Apache-2.0//-#include "inputs_outputs.hpp"-#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "openvino/op/relu.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {++class DriverCompilerAdapterInputsOutputsTestNPU :+ public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ result << "model="+ << "SimpleReluModel"+ << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov_model = createSimpleReluModel();+ OVPluginTestBase::SetUp();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }++private:+ std::shared_ptr<ov::Model> createSimpleReluModel() {+ auto arg0 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{1});+ arg0->set_friendly_name("data");+ arg0->get_output_tensor(0).set_names({"input"});++ auto relu = std::make_shared<ov::op::v0::Relu>(arg0);+ relu->set_friendly_name("relu");+ relu->get_output_tensor(0).set_names({"relu_res"});+ auto f = std::make_shared<ov::Model>(relu, ov::ParameterVector{arg0});+ f->validate_nodes_and_infer_types();+ return f;+ }+};++TEST_P(DriverCompilerAdapterInputsOutputsTestNPU, CheckInOutputs) {+ auto compiledModel = core->compile_model(ov_model, target_device, configuration);+ for (auto&& input : compiledModel.inputs()) {+ std::string in_name;+ std::string in_node_name;+ try {+ for (const auto& name : input.get_names()) {+ in_name += name + " , ";+ }+ in_name = in_name.substr(0, in_name.size() - 3);+ } catch (const ov::Exception&) {+ }++ try {+ in_node_name = input.get_node()->get_friendly_name();+ } catch (const ov::Exception&) {+ }+ EXPECT_EQ(in_name, "input");+ EXPECT_EQ(in_node_name, "data");+ }++ for (auto&& output : compiledModel.outputs()) {+ std::string out_name;+ std::string out_node_name;++ try {+ for (const auto& name : output.get_names()) {+ out_name += name + " , ";+ }+ out_name = out_name.substr(0, out_name.size() - 3);+ } catch (const ov::Exception&) {+ }+ try {+ out_node_name = output.get_node()->get_input_node_ptr(0)->get_friendly_name();+ } catch (const ov::Exception&) {+ }+ EXPECT_EQ(out_name, "relu_res");+ EXPECT_EQ(out_node_name, "relu");+ }+}+} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.hpp b/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.hppdeleted file mode 100644index 1a59d268d25..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/npu_driver_compiler_adapter/inputs_outputs.hpp+++ /dev/null@@ -1,121 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "common/npu_test_env_cfg.hpp"--#include "openvino/op/relu.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {--class DriverCompilerAdapterInputsOutputsTestNPU :- public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- result << "model="- << "SimpleReluModel"- << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov_model = createSimpleReluModel();- OVPluginTestBase::SetUp();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }--private:- std::shared_ptr<ov::Model> createSimpleReluModel() {- auto arg0 = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{1});- arg0->set_friendly_name("data");- arg0->get_output_tensor(0).set_names({"input"});-- auto relu = std::make_shared<ov::op::v0::Relu>(arg0);- relu->set_friendly_name("relu");- relu->get_output_tensor(0).set_names({"relu_res"});- auto f = std::make_shared<ov::Model>(relu, ov::ParameterVector{arg0});- f->validate_nodes_and_infer_types();- return f;- }-};--TEST_P(DriverCompilerAdapterInputsOutputsTestNPU, CheckInOutputs) {- auto compiledModel = core->compile_model(ov_model, target_device, configuration);- for (auto&& input : compiledModel.inputs()) {- std::string in_name;- std::string in_node_name;- try {- for (const auto& name : input.get_names()) {- in_name += name + " , ";- }- in_name = in_name.substr(0, in_name.size() - 3);- } catch (const ov::Exception&) {- }-- try {- in_node_name = input.get_node()->get_friendly_name();- } catch (const ov::Exception&) {- }- EXPECT_EQ(in_name, "input");- EXPECT_EQ(in_node_name, "data");- }-- for (auto&& output : compiledModel.outputs()) {- std::string out_name;- std::string out_node_name;-- try {- for (const auto& name : output.get_names()) {- out_name += name + " , ";- }- out_name = out_name.substr(0, out_name.size() - 3);- } catch (const ov::Exception&) {- }- try {- out_node_name = output.get_node()->get_input_node_ptr(0)->get_friendly_name();- } catch (const ov::Exception&) {- }- EXPECT_EQ(out_name, "relu_res");- EXPECT_EQ(out_node_name, "relu");- }-}-} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.cppindex 8b93aca861b..8e95c3f98e2 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.cpp@@ -2,9 +2,78 @@// SPDX-License-Identifier: Apache-2.0//-#include "callback.hpp"+#include <atomic>+#include <chrono>+#include <future>+#include <memory>#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"++namespace ov {+namespace test {+namespace behavior {+using OVInferRequestCallbackTestsNPU = OVInferRequestTestsNPU;++TEST_P(OVInferRequestCallbackTestsNPU, callbackCanCallInfer) {+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());++ std::atomic<size_t> callback_calls{0};+ std::promise<void> done;+ auto done_future = done.get_future();+ std::atomic_bool done_signaled{false};++ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(nullptr, exception_ptr);+ callback_calls.fetch_add(1, std::memory_order_relaxed);+ req.infer();++ if (!done_signaled.exchange(true, std::memory_order_relaxed)) {+ done.set_value();+ }+ }));++ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());++ ASSERT_EQ(done_future.wait_for(std::chrono::seconds(30)), std::future_status::ready);+ ASSERT_EQ(callback_calls.load(std::memory_order_relaxed), 1);+}++TEST_P(OVInferRequestCallbackTestsNPU, callbackCanCallStartAsyncAndWait) {+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());++ std::atomic<size_t> callback_calls{0};+ std::promise<void> nested_done;+ auto nested_done_future = nested_done.get_future();+ std::atomic_bool nested_done_signaled{false};++ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(nullptr, exception_ptr);+ const auto call_index = callback_calls.fetch_add(1, std::memory_order_relaxed);++ if (call_index == 0) {+ req.start_async();+ req.wait();+ } else if (call_index == 1) {+ if (!nested_done_signaled.exchange(true, std::memory_order_relaxed)) {+ nested_done.set_value();+ }+ }+ }));++ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());++ ASSERT_EQ(nested_done_future.wait_for(std::chrono::seconds(30)), std::future_status::ready);+ ASSERT_GE(callback_calls.load(std::memory_order_relaxed), 2);+}++} // namespace behavior+} // namespace test+} // namespace ovnamespace {const std::vector<ov::AnyMap> configs = {{}};diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.hppdeleted file mode 100644index e25e524b7d4..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/callback.hpp+++ /dev/null@@ -1,77 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <atomic>-#include <chrono>-#include <future>-#include <memory>--#include "common/utils.hpp"--namespace ov {-namespace test {-namespace behavior {-using OVInferRequestCallbackTestsNPU = OVInferRequestTestsNPU;--TEST_P(OVInferRequestCallbackTestsNPU, callbackCanCallInfer) {- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());-- std::atomic<size_t> callback_calls{0};- std::promise<void> done;- auto done_future = done.get_future();- std::atomic_bool done_signaled{false};-- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(nullptr, exception_ptr);- callback_calls.fetch_add(1, std::memory_order_relaxed);- req.infer();-- if (!done_signaled.exchange(true, std::memory_order_relaxed)) {- done.set_value();- }- }));-- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());-- ASSERT_EQ(done_future.wait_for(std::chrono::seconds(30)), std::future_status::ready);- ASSERT_EQ(callback_calls.load(std::memory_order_relaxed), 1);-}--TEST_P(OVInferRequestCallbackTestsNPU, callbackCanCallStartAsyncAndWait) {- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());-- std::atomic<size_t> callback_calls{0};- std::promise<void> nested_done;- auto nested_done_future = nested_done.get_future();- std::atomic_bool nested_done_signaled{false};-- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(nullptr, exception_ptr);- const auto call_index = callback_calls.fetch_add(1, std::memory_order_relaxed);-- if (call_index == 0) {- req.start_async();- req.wait();- } else if (call_index == 1) {- if (!nested_done_signaled.exchange(true, std::memory_order_relaxed)) {- nested_done.set_value();- }- }- }));-- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());-- ASSERT_EQ(nested_done_future.wait_for(std::chrono::seconds(30)), std::future_status::ready);- ASSERT_GE(callback_calls.load(std::memory_order_relaxed), 2);-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cppindex 56e38bf00c6..9f8cdb54c2f 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.cpp@@ -2,11 +2,639 @@// SPDX-License-Identifier: Apache-2.0//-#include "compile_and_infer.hpp"--#include <intel_npu/npu_private_properties.hpp>+#include <algorithm>+#include <chrono>+#include <common_test_utils/test_assertions.hpp>+#include <exception>+#include <gtest/gtest.h>+#include <mutex>+#include <sstream>+#include <thread>+#include <vector>#include "common/utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "openvino/core/except.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"+#include "openvino/runtime/properties.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov {+namespace test {+namespace behavior {++inline std::shared_ptr<ov::Model> getConstantGraph(element::Type type) {+ ResultVector results;+ ParameterVector params;+ auto op = std::make_shared<ov::op::v1::Add>(opset8::Constant::create(type, {1}, {1}),+ opset8::Constant::create(type, {1}, {1}));+ op->set_friendly_name("Add");+ auto res = std::make_shared<ov::op::v0::Result>(op);+ res->set_friendly_name("Result");+ res->get_output_tensor(0).set_names({"tensor_output"});+ results.push_back(res);+ return std::make_shared<Model>(results, params);+}++inline std::shared_ptr<ov::Model> createSimpleModel() {+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ auto add_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1});+ auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);++ return std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{data});+}++inline std::shared_ptr<ov::Model> createModelContainingSubgraph() {+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});+ input->get_output_tensor(0).set_names({"tensor_input"});++ // Simple subgraph that adds 1 to the input+ std::shared_ptr<ov::Model> body = createSimpleModel();+ auto tensor_iterator = std::make_shared<ov::op::v0::TensorIterator>();+ tensor_iterator->set_body(body);+ tensor_iterator->set_sliced_input(+ std::dynamic_pointer_cast<ov::op::v0::Parameter>(body->input().get_node_shared_ptr()),+ input,+ 0,+ 1,+ 1,+ -1,+ 0);++ // Outside the subgraph, add 1 to the output+ auto add_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1});+ auto add = std::make_shared<ov::op::v1::Add>(tensor_iterator->get_iter_value(body->output(), -1), add_constant);++ auto result = std::make_shared<ov::op::v0::Result>(add);+ result->get_output_tensor(0).set_names({"tensor_output"});++ return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});+}++inline bool isCommandQueueExtSupported() {+ return std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() > 0;+}++typedef std::tuple<std::shared_ptr<ov::Model>, // Model+ std::string, // Device name+ ov::AnyMap // Config+ >+ CompileAndInferRequestParams;++class OVCompileAndInferRequest : public testing::WithParamInterface<CompileAndInferRequestParams>,+ public OVInferRequestTestBase {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompileAndInferRequestParams>& obj) {+ std::shared_ptr<ov::Model> model;+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(model, targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');+ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ if (!configuration.empty()) {+ using namespace ov::test::utils;+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }+ void SetUp() override {+ std::tie(function, target_device, configuration) = this->GetParam();+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ APIBaseTest::SetUp();+ }++protected:+ ov::CompiledModel execNet;+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ std::string targetDevice;+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> function;+};++TEST_P(OVCompileAndInferRequest, AsyncInferRequest) {+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+}++TEST_P(OVCompileAndInferRequest, EvictGraphMemoryThenInferAgain) {+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());++ OV_ASSERT_NO_THROW(execNet.release_memory());++ OV_ASSERT_NO_THROW(req.infer());+}++// Disabled test that checks that memory eviction works correctly and does not cause memory leaks after inference runs.+// The test is disabled due to the fact that it requires another check of the memory since device_alloc_mem_size doesn't+// provide memory feedback after eviction is called.+TEST_P(OVCompileAndInferRequest, DISABLED_CheckMemoryAfterEvictGraphMemoryAndAfterRunningInferAgain) {+ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {+ GTEST_SKIP() << "Memory eviction is not supported by the current driver version.";+ }++ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());++ uint64_t device_alloc_mem_size = 0;+ OV_ASSERT_NO_THROW(+ device_alloc_mem_size =+ core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());++ OV_ASSERT_NO_THROW(execNet.release_memory());++ uint64_t device_alloc_mem_size_after_evict = 0;+ OV_ASSERT_NO_THROW(+ device_alloc_mem_size_after_evict =+ core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());++ OV_ASSERT_NO_THROW(req.infer());++ uint64_t device_alloc_mem_size_final = 0;+ OV_ASSERT_NO_THROW(+ device_alloc_mem_size_final =+ core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());++ ASSERT_EQ(device_alloc_mem_size, device_alloc_mem_size_final);+ ASSERT_LT(device_alloc_mem_size_after_evict, device_alloc_mem_size);+}++TEST_P(OVCompileAndInferRequest, PluginWorkloadType) {+ configuration[workload_type.name()] = WorkloadType::DEFAULT;+ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();+ bool workloadTypeSupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == workload_type.name();+ });++ if (isCommandQueueExtSupported()) {+ ASSERT_TRUE(workloadTypeSupported);+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));++ const auto properties = execNet.get_property(supported_properties.name()).as<std::vector<PropertyName>>();+ ASSERT_TRUE(std::any_of(properties.begin(), properties.end(), [](const PropertyName& property) {+ return property == workload_type.name();+ }));++ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+ } else {+ ASSERT_FALSE(workloadTypeSupported);+ OV_EXPECT_THROW_HAS_SUBSTRING(+ core->compile_model(function, target_device, configuration),+ ov::Exception,+ "[ NOT_FOUND ] Option 'WORKLOAD_TYPE' is not supported for current configuration");+ }+}++TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadType) {+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ov::AnyMap modelConfiguration;+ modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;+ auto supportedProperties = execNet.get_property(supported_properties.name()).as<std::vector<PropertyName>>();+ bool workloadTypeSupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == workload_type.name();+ });++ if (isCommandQueueExtSupported()) {+ ASSERT_TRUE(workloadTypeSupported);+ OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+ } else {+ ASSERT_FALSE(workloadTypeSupported);+ OV_EXPECT_THROW_HAS_SUBSTRING(execNet.set_property(modelConfiguration),+ ov::Exception,+ "Unsupported configuration key: WORKLOAD_TYPE");+ }+}++TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeDelayedExecutor) {+ configuration[intel_npu::defer_weights_load.name()] = true;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ov::AnyMap modelConfiguration;+ modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;++ if (isCommandQueueExtSupported()) {+ OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(execNet.set_property(modelConfiguration),+ ov::Exception,+ "Unsupported configuration key: WORKLOAD_TYPE");+ }+}++TEST_P(OVCompileAndInferRequest, CompiledModelAndCreateMultipleInferRequestsWithDelayedExecutor) {+ configuration[intel_npu::defer_weights_load.name()] = true;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ov::InferRequest req0, req1, req2;+ OV_ASSERT_NO_THROW(req0 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());++ OV_ASSERT_NO_THROW(req0.infer());+ OV_ASSERT_NO_THROW(req1.infer());+ OV_ASSERT_NO_THROW(req2.infer());+}++TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeUpdateAfterCompilation) {+ if (!isCommandQueueExtSupported()) {+ GTEST_SKIP() << "Workload type update is not supported with current driver.\n";+ }++ configuration[workload_type.name()] = WorkloadType::DEFAULT;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));++ ASSERT_EQ(execNet.get_property(workload_type.name()).as<WorkloadType>(), WorkloadType::DEFAULT);+ ov::AnyMap modelConfiguration;+ modelConfiguration[workload_type.name()] = WorkloadType::EFFICIENT;+ OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));+ ASSERT_EQ(execNet.get_property(workload_type.name()).as<WorkloadType>(), WorkloadType::EFFICIENT);+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+}++TEST_P(OVCompileAndInferRequest, CompiledModelModelPriorityUpdateAfterCompilation) {+ configuration[hint::model_priority.name()] = hint::Priority::MEDIUM;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::MEDIUM);++ ov::AnyMap modelConfiguration;+ ov::InferRequest req;++ modelConfiguration[hint::model_priority.name()] = hint::Priority::HIGH;+ OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));+ ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::HIGH);+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());++ modelConfiguration[hint::model_priority.name()] = hint::Priority::LOW;+ OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));+ ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::LOW);+ OV_ASSERT_NO_THROW(req.infer());+}++using OVCompileAndInferRequestMultiThreading = OVCompileAndInferRequest;++TEST_P(OVCompileAndInferRequestMultiThreading, CreateInferRequestsAndRunOnDifferentThreads) {+ configuration[intel_npu::defer_weights_load.name()] = true;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));++ const int num_threads = 64;+ std::vector<std::thread> threads;+ std::vector<std::exception_ptr> exceptions;+ std::mutex exceptions_mutex;++ for (int i = 0; i < num_threads; ++i) {+ threads.emplace_back([this, &exceptions, &exceptions_mutex]() {+ try {+ auto req = execNet.create_infer_request();+ req.infer();+ } catch (...) {+ std::lock_guard<std::mutex> lock(exceptions_mutex);+ exceptions.emplace_back(std::current_exception());+ }+ });+ }++ for (auto& thread : threads) {+ thread.join();+ }++ if (!exceptions.empty()) {+ try {+ std::rethrow_exception(exceptions.front());+ } catch (const std::exception& ex) {+ FAIL() << ex.what();+ } catch (...) {+ FAIL() << "Unknown exception occurred in one of the threads.";+ }+ }+}++TEST_P(OVCompileAndInferRequestMultiThreading, CreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypeAndPriority) {+ if (!isCommandQueueExtSupported()) {+ GTEST_SKIP() << "Workload type update is not supported with current driver.\n";+ }++ configuration[intel_npu::defer_weights_load.name()] = true;+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));++ int num_threads = 32;+ std::vector<std::thread> threads;+ std::vector<std::exception_ptr> exceptions;+ std::mutex exceptions_mutex;++ for (int i = 0; i < num_threads; ++i) {+ threads.emplace_back([this, &exceptions, &exceptions_mutex, i]() {+ try {+ // Stagger threads to desynchronize property setting and expose race conditions+ std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));+ if (i % 2 == 0) {+ execNet.set_property(ov::workload_type(WorkloadType::DEFAULT));+ } else {+ execNet.set_property(ov::workload_type(WorkloadType::EFFICIENT));+ }+ if (i % 3 == 0) {+ execNet.set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));+ } else if (i % 3 == 1) {+ execNet.set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));+ } else {+ execNet.set_property(ov::hint::model_priority(ov::hint::Priority::LOW));+ }+ auto req = execNet.create_infer_request();+ req.infer();+ } catch (...) {+ std::lock_guard<std::mutex> lock(exceptions_mutex);+ exceptions.emplace_back(std::current_exception());+ }+ });+ }++ for (auto& thread : threads) {+ thread.join();+ }++ if (!exceptions.empty()) {+ try {+ std::rethrow_exception(exceptions.front());+ } catch (const std::exception& ex) {+ FAIL() << ex.what();+ } catch (...) {+ FAIL() << "Unknown exception occurred in one of the threads.";+ }+ }+}++TEST_P(OVCompileAndInferRequestMultiThreading,+ CompileModelCreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypeAndPriority) {+ if (!isCommandQueueExtSupported()) {+ GTEST_SKIP() << "Workload type update is not supported with current driver.\n";+ }++ configuration[intel_npu::defer_weights_load.name()] = true;++ int num_threads = 32;+ std::vector<std::thread> threads;+ std::vector<std::exception_ptr> exceptions;+ std::vector<ov::CompiledModel> compiled_models(num_threads);+ std::mutex exceptions_mutex;++ for (int i = 0; i < num_threads; ++i) {+ threads.emplace_back([this, &exceptions, &exceptions_mutex, &compiled_models, i]() {+ try {+ compiled_models[i] = core->compile_model(function, target_device, configuration);+ // Stagger threads to desynchronize property setting and expose race conditions+ std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));+ if (i % 2 == 0) {+ compiled_models[i].set_property(ov::workload_type(WorkloadType::DEFAULT));+ } else {+ compiled_models[i].set_property(ov::workload_type(WorkloadType::EFFICIENT));+ }+ if (i % 3 == 0) {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));+ } else if (i % 3 == 1) {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));+ } else {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::LOW));+ }+ auto req = compiled_models[i].create_infer_request();+ req.infer();+ } catch (...) {+ std::lock_guard<std::mutex> lock(exceptions_mutex);+ exceptions.emplace_back(std::current_exception());+ }+ });+ }++ for (auto& thread : threads) {+ thread.join();+ }++ if (!exceptions.empty()) {+ try {+ std::rethrow_exception(exceptions.front());+ } catch (const std::exception& ex) {+ FAIL() << ex.what();+ } catch (...) {+ FAIL() << "Unknown exception occurred in one of the threads.";+ }+ }++ for (int i = 0; i < num_threads; ++i) {+ if (i % 2 == 0) {+ ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),+ WorkloadType::DEFAULT);+ } else {+ ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),+ WorkloadType::EFFICIENT);+ }++ if (i % 3 == 0) {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::HIGH);+ } else if (i % 3 == 1) {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::MEDIUM);+ } else {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::LOW);+ }+ }+}++TEST_P(OVCompileAndInferRequestMultiThreading,+ CompileModelCreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypePriorityAndSharedCommonQueueDisabled) {+ if (!isCommandQueueExtSupported()) {+ GTEST_SKIP() << "Workload type update is not supported with current driver.\n";+ }++ configuration[intel_npu::defer_weights_load.name()] = true;+ configuration[intel_npu::shared_common_queue.name()] = false;++ int num_threads = 32;+ std::vector<std::thread> threads;+ std::vector<std::exception_ptr> exceptions;+ std::vector<ov::CompiledModel> compiled_models(num_threads);+ std::mutex exceptions_mutex;++ for (int i = 0; i < num_threads; ++i) {+ threads.emplace_back([this, &exceptions, &exceptions_mutex, &compiled_models, i]() {+ try {+ compiled_models[i] = core->compile_model(function, target_device, configuration);+ // Stagger threads to desynchronize property setting and expose race conditions+ std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));+ if (i % 2 == 0) {+ compiled_models[i].set_property(ov::workload_type(WorkloadType::DEFAULT));+ } else {+ compiled_models[i].set_property(ov::workload_type(WorkloadType::EFFICIENT));+ }+ if (i % 3 == 0) {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));+ } else if (i % 3 == 1) {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));+ } else {+ compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::LOW));+ }+ auto req = compiled_models[i].create_infer_request();+ req.infer();+ } catch (...) {+ std::lock_guard<std::mutex> lock(exceptions_mutex);+ exceptions.emplace_back(std::current_exception());+ }+ });+ }++ for (auto& thread : threads) {+ thread.join();+ }++ if (!exceptions.empty()) {+ try {+ std::rethrow_exception(exceptions.front());+ } catch (const std::exception& ex) {+ FAIL() << ex.what();+ } catch (...) {+ FAIL() << "Unknown exception occurred in one of the threads.";+ }+ }++ for (int i = 0; i < num_threads; ++i) {+ if (i % 2 == 0) {+ ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),+ WorkloadType::DEFAULT);+ } else {+ ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),+ WorkloadType::EFFICIENT);+ }++ if (i % 3 == 0) {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::HIGH);+ } else if (i % 3 == 1) {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::MEDIUM);+ } else {+ ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),+ ov::hint::Priority::LOW);+ }+ }+}++using OVCompileAndInferRequestTurbo = OVCompileAndInferRequest;++TEST_P(OVCompileAndInferRequestTurbo, CompiledModelTurbo) {+ configuration[intel_npu::turbo.name()] = true;++ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();+ bool isTurboSupported =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::turbo.name();+ });++ if (isCommandQueueExtSupported()) {+ ASSERT_TRUE(isTurboSupported);+ OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));+ auto turbosetting_compiled_model = execNet.get_property(intel_npu::turbo.name());+ OV_ASSERT_NO_THROW(turbosetting_compiled_model = true);+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ bool is_called = false;+ OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {+ ASSERT_EQ(exception_ptr, nullptr);+ is_called = true;+ }));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ ASSERT_TRUE(is_called);+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(core->compile_model(function, target_device, configuration),+ ov::Exception,+ "[ NOT_FOUND ] Option 'NPU_TURBO' is not supported for current configuration");+ }+}++using OVCompileAndInferRequestSerializers = OVCompileAndInferRequest;++TEST_P(OVCompileAndInferRequestSerializers, AccurateResults) {+ try {+ execNet = core->compile_model(function, target_device, configuration);+ ov::InferRequest inference_request;+ OV_ASSERT_NO_THROW(inference_request = execNet.create_infer_request());++ const ov::Tensor input = utils::create_tensor(ov::element::f32, ov::Shape{1}, std::vector<float>{1.0f});+ inference_request.set_input_tensor(input);+ OV_ASSERT_NO_THROW(inference_request.infer());++ const ov::Tensor output = inference_request.get_tensor("tensor_output");+ const ov::Tensor expected = utils::create_tensor(ov::element::f32, ov::Shape{1}, std::vector<float>{3.0f});+ OV_ASSERT_NO_THROW(utils::compare(expected, output));+ } catch (const ov::Exception& exception) {+ ASSERT_STR_CONTAINS(+ exception.what(),+ "[ NOT_FOUND ] Option 'NPU_MODEL_SERIALIZER_VERSION' is not supported for current configuration");+ }+}++} // namespace behavior+} // namespace test+} // namespace ovnamespace {diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hppdeleted file mode 100644index 8e45b187449..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer.hpp+++ /dev/null@@ -1,639 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>--#include <algorithm>-#include <chrono>-#include <common_test_utils/test_assertions.hpp>-#include <exception>-#include <mutex>-#include <sstream>-#include <thread>-#include <vector>--#include "common_test_utils/ov_tensor_utils.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "openvino/core/except.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"-#include "openvino/runtime/properties.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov {-namespace test {-namespace behavior {--inline std::shared_ptr<ov::Model> getConstantGraph(element::Type type) {- ResultVector results;- ParameterVector params;- auto op = std::make_shared<ov::op::v1::Add>(opset8::Constant::create(type, {1}, {1}),- opset8::Constant::create(type, {1}, {1}));- op->set_friendly_name("Add");- auto res = std::make_shared<ov::op::v0::Result>(op);- res->set_friendly_name("Result");- res->get_output_tensor(0).set_names({"tensor_output"});- results.push_back(res);- return std::make_shared<Model>(results, params);-}--inline std::shared_ptr<ov::Model> createSimpleModel() {- auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});- auto add_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1});- auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);-- return std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{data});-}--inline std::shared_ptr<ov::Model> createModelContainingSubgraph() {- auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::Shape{1});- input->get_output_tensor(0).set_names({"tensor_input"});-- // Simple subgraph that adds 1 to the input- std::shared_ptr<ov::Model> body = createSimpleModel();- auto tensor_iterator = std::make_shared<ov::op::v0::TensorIterator>();- tensor_iterator->set_body(body);- tensor_iterator->set_sliced_input(- std::dynamic_pointer_cast<ov::op::v0::Parameter>(body->input().get_node_shared_ptr()),- input,- 0,- 1,- 1,- -1,- 0);-- // Outside the subgraph, add 1 to the output- auto add_constant = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {1});- auto add = std::make_shared<ov::op::v1::Add>(tensor_iterator->get_iter_value(body->output(), -1), add_constant);-- auto result = std::make_shared<ov::op::v0::Result>(add);- result->get_output_tensor(0).set_names({"tensor_output"});-- return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{input});-}--inline bool isCommandQueueExtSupported() {- return std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() > 0;-}--typedef std::tuple<std::shared_ptr<ov::Model>, // Model- std::string, // Device name- ov::AnyMap // Config- >- CompileAndInferRequestParams;--class OVCompileAndInferRequest : public testing::WithParamInterface<CompileAndInferRequestParams>,- public OVInferRequestTestBase {-public:- static std::string getTestCaseName(const testing::TestParamInfo<CompileAndInferRequestParams>& obj) {- std::shared_ptr<ov::Model> model;- std::string targetDevice;- ov::AnyMap configuration;- std::tie(model, targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- if (!configuration.empty()) {- using namespace ov::test::utils;- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }- void SetUp() override {- std::tie(function, target_device, configuration) = this->GetParam();- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- APIBaseTest::SetUp();- }--protected:- ov::CompiledModel execNet;- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- std::string targetDevice;- ov::AnyMap configuration;- std::shared_ptr<ov::Model> function;-};--TEST_P(OVCompileAndInferRequest, AsyncInferRequest) {- ov::InferRequest req;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);-}--TEST_P(OVCompileAndInferRequest, EvictGraphMemoryThenInferAgain) {- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());-- OV_ASSERT_NO_THROW(execNet.release_memory());-- OV_ASSERT_NO_THROW(req.infer());-}--// Disabled test that checks that memory eviction works correctly and does not cause memory leaks after inference runs.-// The test is disabled due to the fact that it requires another check of the memory since device_alloc_mem_size doesn't-// provide memory feedback after eviction is called.-TEST_P(OVCompileAndInferRequest, DISABLED_CheckMemoryAfterEvictGraphMemoryAndAfterRunningInferAgain) {- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {- GTEST_SKIP() << "Memory eviction is not supported by the current driver version.";- }-- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());-- uint64_t device_alloc_mem_size = 0;- OV_ASSERT_NO_THROW(- device_alloc_mem_size =- core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());-- OV_ASSERT_NO_THROW(execNet.release_memory());-- uint64_t device_alloc_mem_size_after_evict = 0;- OV_ASSERT_NO_THROW(- device_alloc_mem_size_after_evict =- core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());-- OV_ASSERT_NO_THROW(req.infer());-- uint64_t device_alloc_mem_size_final = 0;- OV_ASSERT_NO_THROW(- device_alloc_mem_size_final =- core->get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()).as<uint64_t>());-- ASSERT_EQ(device_alloc_mem_size, device_alloc_mem_size_final);- ASSERT_LT(device_alloc_mem_size_after_evict, device_alloc_mem_size);-}--TEST_P(OVCompileAndInferRequest, PluginWorkloadType) {- configuration[workload_type.name()] = WorkloadType::DEFAULT;- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();- bool workloadTypeSupported =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == workload_type.name();- });-- if (isCommandQueueExtSupported()) {- ASSERT_TRUE(workloadTypeSupported);- ov::InferRequest req;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));-- const auto properties = execNet.get_property(supported_properties.name()).as<std::vector<PropertyName>>();- ASSERT_TRUE(std::any_of(properties.begin(), properties.end(), [](const PropertyName& property) {- return property == workload_type.name();- }));-- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);- } else {- ASSERT_FALSE(workloadTypeSupported);- OV_EXPECT_THROW_HAS_SUBSTRING(- core->compile_model(function, target_device, configuration),- ov::Exception,- "[ NOT_FOUND ] Option 'WORKLOAD_TYPE' is not supported for current configuration");- }-}--TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadType) {- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ov::AnyMap modelConfiguration;- modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;- auto supportedProperties = execNet.get_property(supported_properties.name()).as<std::vector<PropertyName>>();- bool workloadTypeSupported =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == workload_type.name();- });-- if (isCommandQueueExtSupported()) {- ASSERT_TRUE(workloadTypeSupported);- OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);- } else {- ASSERT_FALSE(workloadTypeSupported);- OV_EXPECT_THROW_HAS_SUBSTRING(execNet.set_property(modelConfiguration),- ov::Exception,- "Unsupported configuration key: WORKLOAD_TYPE");- }-}--TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeDelayedExecutor) {- configuration[intel_npu::defer_weights_load.name()] = true;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ov::AnyMap modelConfiguration;- modelConfiguration[workload_type.name()] = WorkloadType::DEFAULT;-- if (isCommandQueueExtSupported()) {- OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);- } else {- OV_EXPECT_THROW_HAS_SUBSTRING(execNet.set_property(modelConfiguration),- ov::Exception,- "Unsupported configuration key: WORKLOAD_TYPE");- }-}--TEST_P(OVCompileAndInferRequest, CompiledModelAndCreateMultipleInferRequestsWithDelayedExecutor) {- configuration[intel_npu::defer_weights_load.name()] = true;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ov::InferRequest req0, req1, req2;- OV_ASSERT_NO_THROW(req0 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());-- OV_ASSERT_NO_THROW(req0.infer());- OV_ASSERT_NO_THROW(req1.infer());- OV_ASSERT_NO_THROW(req2.infer());-}--TEST_P(OVCompileAndInferRequest, CompiledModelWorkloadTypeUpdateAfterCompilation) {- if (!isCommandQueueExtSupported()) {- GTEST_SKIP() << "Workload type update is not supported with current driver.\n";- }-- configuration[workload_type.name()] = WorkloadType::DEFAULT;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));-- ASSERT_EQ(execNet.get_property(workload_type.name()).as<WorkloadType>(), WorkloadType::DEFAULT);- ov::AnyMap modelConfiguration;- modelConfiguration[workload_type.name()] = WorkloadType::EFFICIENT;- OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));- ASSERT_EQ(execNet.get_property(workload_type.name()).as<WorkloadType>(), WorkloadType::EFFICIENT);- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);-}--TEST_P(OVCompileAndInferRequest, CompiledModelModelPriorityUpdateAfterCompilation) {- configuration[hint::model_priority.name()] = hint::Priority::MEDIUM;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::MEDIUM);-- ov::AnyMap modelConfiguration;- ov::InferRequest req;-- modelConfiguration[hint::model_priority.name()] = hint::Priority::HIGH;- OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));- ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::HIGH);- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());-- modelConfiguration[hint::model_priority.name()] = hint::Priority::LOW;- OV_ASSERT_NO_THROW(execNet.set_property(modelConfiguration));- ASSERT_EQ(execNet.get_property(hint::model_priority.name()).as<hint::Priority>(), hint::Priority::LOW);- OV_ASSERT_NO_THROW(req.infer());-}--using OVCompileAndInferRequestMultiThreading = OVCompileAndInferRequest;--TEST_P(OVCompileAndInferRequestMultiThreading, CreateInferRequestsAndRunOnDifferentThreads) {- configuration[intel_npu::defer_weights_load.name()] = true;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));-- const int num_threads = 64;- std::vector<std::thread> threads;- std::vector<std::exception_ptr> exceptions;- std::mutex exceptions_mutex;-- for (int i = 0; i < num_threads; ++i) {- threads.emplace_back([this, &exceptions, &exceptions_mutex]() {- try {- auto req = execNet.create_infer_request();- req.infer();- } catch (...) {- std::lock_guard<std::mutex> lock(exceptions_mutex);- exceptions.emplace_back(std::current_exception());- }- });- }-- for (auto& thread : threads) {- thread.join();- }-- if (!exceptions.empty()) {- try {- std::rethrow_exception(exceptions.front());- } catch (const std::exception& ex) {- FAIL() << ex.what();- } catch (...) {- FAIL() << "Unknown exception occurred in one of the threads.";- }- }-}--TEST_P(OVCompileAndInferRequestMultiThreading, CreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypeAndPriority) {- if (!isCommandQueueExtSupported()) {- GTEST_SKIP() << "Workload type update is not supported with current driver.\n";- }-- configuration[intel_npu::defer_weights_load.name()] = true;- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));-- int num_threads = 32;- std::vector<std::thread> threads;- std::vector<std::exception_ptr> exceptions;- std::mutex exceptions_mutex;-- for (int i = 0; i < num_threads; ++i) {- threads.emplace_back([this, &exceptions, &exceptions_mutex, i]() {- try {- // Stagger threads to desynchronize property setting and expose race conditions- std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));- if (i % 2 == 0) {- execNet.set_property(ov::workload_type(WorkloadType::DEFAULT));- } else {- execNet.set_property(ov::workload_type(WorkloadType::EFFICIENT));- }- if (i % 3 == 0) {- execNet.set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));- } else if (i % 3 == 1) {- execNet.set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));- } else {- execNet.set_property(ov::hint::model_priority(ov::hint::Priority::LOW));- }- auto req = execNet.create_infer_request();- req.infer();- } catch (...) {- std::lock_guard<std::mutex> lock(exceptions_mutex);- exceptions.emplace_back(std::current_exception());- }- });- }-- for (auto& thread : threads) {- thread.join();- }-- if (!exceptions.empty()) {- try {- std::rethrow_exception(exceptions.front());- } catch (const std::exception& ex) {- FAIL() << ex.what();- } catch (...) {- FAIL() << "Unknown exception occurred in one of the threads.";- }- }-}--TEST_P(OVCompileAndInferRequestMultiThreading,- CompileModelCreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypeAndPriority) {- if (!isCommandQueueExtSupported()) {- GTEST_SKIP() << "Workload type update is not supported with current driver.\n";- }-- configuration[intel_npu::defer_weights_load.name()] = true;-- int num_threads = 32;- std::vector<std::thread> threads;- std::vector<std::exception_ptr> exceptions;- std::vector<ov::CompiledModel> compiled_models(num_threads);- std::mutex exceptions_mutex;-- for (int i = 0; i < num_threads; ++i) {- threads.emplace_back([this, &exceptions, &exceptions_mutex, &compiled_models, i]() {- try {- compiled_models[i] = core->compile_model(function, target_device, configuration);- // Stagger threads to desynchronize property setting and expose race conditions- std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));- if (i % 2 == 0) {- compiled_models[i].set_property(ov::workload_type(WorkloadType::DEFAULT));- } else {- compiled_models[i].set_property(ov::workload_type(WorkloadType::EFFICIENT));- }- if (i % 3 == 0) {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));- } else if (i % 3 == 1) {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));- } else {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::LOW));- }- auto req = compiled_models[i].create_infer_request();- req.infer();- } catch (...) {- std::lock_guard<std::mutex> lock(exceptions_mutex);- exceptions.emplace_back(std::current_exception());- }- });- }-- for (auto& thread : threads) {- thread.join();- }-- if (!exceptions.empty()) {- try {- std::rethrow_exception(exceptions.front());- } catch (const std::exception& ex) {- FAIL() << ex.what();- } catch (...) {- FAIL() << "Unknown exception occurred in one of the threads.";- }- }-- for (int i = 0; i < num_threads; ++i) {- if (i % 2 == 0) {- ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),- WorkloadType::DEFAULT);- } else {- ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),- WorkloadType::EFFICIENT);- }-- if (i % 3 == 0) {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::HIGH);- } else if (i % 3 == 1) {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::MEDIUM);- } else {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::LOW);- }- }-}--TEST_P(OVCompileAndInferRequestMultiThreading,- CompileModelCreateInferRequestsAndRunOnDifferentThreadsWithWorkloadTypePriorityAndSharedCommonQueueDisabled) {- if (!isCommandQueueExtSupported()) {- GTEST_SKIP() << "Workload type update is not supported with current driver.\n";- }-- configuration[intel_npu::defer_weights_load.name()] = true;- configuration[intel_npu::shared_common_queue.name()] = false;-- int num_threads = 32;- std::vector<std::thread> threads;- std::vector<std::exception_ptr> exceptions;- std::vector<ov::CompiledModel> compiled_models(num_threads);- std::mutex exceptions_mutex;-- for (int i = 0; i < num_threads; ++i) {- threads.emplace_back([this, &exceptions, &exceptions_mutex, &compiled_models, i]() {- try {- compiled_models[i] = core->compile_model(function, target_device, configuration);- // Stagger threads to desynchronize property setting and expose race conditions- std::this_thread::sleep_for(std::chrono::milliseconds(i % 10));- if (i % 2 == 0) {- compiled_models[i].set_property(ov::workload_type(WorkloadType::DEFAULT));- } else {- compiled_models[i].set_property(ov::workload_type(WorkloadType::EFFICIENT));- }- if (i % 3 == 0) {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::HIGH));- } else if (i % 3 == 1) {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::MEDIUM));- } else {- compiled_models[i].set_property(ov::hint::model_priority(ov::hint::Priority::LOW));- }- auto req = compiled_models[i].create_infer_request();- req.infer();- } catch (...) {- std::lock_guard<std::mutex> lock(exceptions_mutex);- exceptions.emplace_back(std::current_exception());- }- });- }-- for (auto& thread : threads) {- thread.join();- }-- if (!exceptions.empty()) {- try {- std::rethrow_exception(exceptions.front());- } catch (const std::exception& ex) {- FAIL() << ex.what();- } catch (...) {- FAIL() << "Unknown exception occurred in one of the threads.";- }- }-- for (int i = 0; i < num_threads; ++i) {- if (i % 2 == 0) {- ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),- WorkloadType::DEFAULT);- } else {- ASSERT_EQ(compiled_models[i].get_property(ov::workload_type.name()).as<WorkloadType>(),- WorkloadType::EFFICIENT);- }-- if (i % 3 == 0) {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::HIGH);- } else if (i % 3 == 1) {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::MEDIUM);- } else {- ASSERT_EQ(compiled_models[i].get_property(ov::hint::model_priority.name()).as<ov::hint::Priority>(),- ov::hint::Priority::LOW);- }- }-}--using OVCompileAndInferRequestTurbo = OVCompileAndInferRequest;--TEST_P(OVCompileAndInferRequestTurbo, CompiledModelTurbo) {- configuration[intel_npu::turbo.name()] = true;-- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();- bool isTurboSupported =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == intel_npu::turbo.name();- });-- if (isCommandQueueExtSupported()) {- ASSERT_TRUE(isTurboSupported);- OV_ASSERT_NO_THROW(execNet = core->compile_model(function, target_device, configuration));- auto turbosetting_compiled_model = execNet.get_property(intel_npu::turbo.name());- OV_ASSERT_NO_THROW(turbosetting_compiled_model = true);- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- bool is_called = false;- OV_ASSERT_NO_THROW(req.set_callback([&](std::exception_ptr exception_ptr) {- ASSERT_EQ(exception_ptr, nullptr);- is_called = true;- }));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- ASSERT_TRUE(is_called);- } else {- OV_EXPECT_THROW_HAS_SUBSTRING(core->compile_model(function, target_device, configuration),- ov::Exception,- "[ NOT_FOUND ] Option 'NPU_TURBO' is not supported for current configuration");- }-}--using OVCompileAndInferRequestSerializers = OVCompileAndInferRequest;--TEST_P(OVCompileAndInferRequestSerializers, AccurateResults) {- try {- execNet = core->compile_model(function, target_device, configuration);- ov::InferRequest inference_request;- OV_ASSERT_NO_THROW(inference_request = execNet.create_infer_request());-- const ov::Tensor input = utils::create_tensor(ov::element::f32, ov::Shape{1}, std::vector<float>{1.0f});- inference_request.set_input_tensor(input);- OV_ASSERT_NO_THROW(inference_request.infer());-- const ov::Tensor output = inference_request.get_tensor("tensor_output");- const ov::Tensor expected = utils::create_tensor(ov::element::f32, ov::Shape{1}, std::vector<float>{3.0f});- OV_ASSERT_NO_THROW(utils::compare(expected, output));- } catch (const ov::Exception& exception) {- ASSERT_STR_CONTAINS(- exception.what(),- "[ NOT_FOUND ] Option 'NPU_MODEL_SERIALIZER_VERSION' is not supported for current configuration");- }-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.cppindex f30fc73236f..1e9e384ef86 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.cpp@@ -2,12 +2,330 @@// SPDX-License-Identifier: Apache-2.0//-#include "compile_and_infer_different_element_type.hpp"-+#include <common_test_utils/ov_tensor_utils.hpp>+#include <sstream>+#include <string>#include <vector>#include "common/utils.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "openvino/pass/serialize.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov {+namespace test {+namespace behavior {++using InferRequestElementTypeParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++// These tests are required by the NPU plugin to verify the compatibility of undefined type and dynamic type during+// compilation and inference on different NPU drivers, hence they are kept here. Compared to test in serialize it+// includes an additional comparison of inference results.+class InferRequestElementTypeTests : public testing::WithParamInterface<InferRequestElementTypeParams>,+ public OVInferRequestTestBase {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<InferRequestElementTypeParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ std::tie(target_device, configuration) = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '.');+ std::ostringstream result;+ result << "targetDevice=" << target_device << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ result << "_";+ }+ }+ return result.str();+ }++ void SetUp() {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration) = this->GetParam();+ APIBaseTest::SetUp();+ }++protected:+ bool compareTensorOutputs(const ov::Tensor& dynamicInferenceOutput, const ov::Tensor& undefinedInferenceOutput);++ std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();+ ov::AnyMap configuration;+};++bool InferRequestElementTypeTests::compareTensorOutputs(const ov::Tensor& dynamicInferenceOutput,+ const ov::Tensor& undefinedInferenceOutput) {+ const auto dynamicShape = dynamicInferenceOutput.get_shape();+ const auto undefinedShape = undefinedInferenceOutput.get_shape();++ // compare two models' element types+ if (dynamicInferenceOutput.get_element_type() != undefinedInferenceOutput.get_element_type()) {+ return false;+ }++ // compare two models' shapes+ if (dynamicShape.size() != undefinedShape.size()) {+ return false;+ }++ if (!std::equal(dynamicShape.cbegin(), dynamicShape.cend(), undefinedShape.cbegin())) {+ return false;+ }+ // compare two models' data+ for (size_t i = 0; i < undefinedInferenceOutput.get_size(); i++) {+ if (fabs(dynamicInferenceOutput.data<float>()[i] - undefinedInferenceOutput.data<float>()[i]) >+ std::numeric_limits<float>::epsilon())+ return false;+ }+ return true;+}++// Test whether the serialization and inference results of the dynamic type model and the undefined type model are the+// same+TEST_P(InferRequestElementTypeTests, CompareDynamicAndUndefinedTypeNetwork) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ // Customize a model with a dynamic type+ std::string dynamicTypeModelXmlString = R"V0G0N(<?xml version="1.0"?>+<net name="custom_model" version="11">+ <layers>+ <layer id="0" name="Parameter_1" type="Parameter" version="opset1">+ <data shape="1,1,128" element_type="f32" />+ <output>+ <port id="0" precision="FP32" names="Parameter_1">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="1" name="Relu_2" type="ReLU" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="2" name="ReadValue_3" type="ReadValue" version="opset6">+ <data variable_id="my_var" variable_type="dynamic" variable_shape="..." />+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="3" name="Assign_4" type="Assign" version="opset6">+ <data variable_id="my_var" />+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="4" name="Squeeze_5" type="Squeeze" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32" names="Output_5">+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="5" name="Result_6" type="Result" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>128</dim>+ </port>+ </input>+ </layer>+ </layers>+ <edges>+ <edge from-layer="0" from-port="0" to-layer="1" to-port="0" />+ <edge from-layer="1" from-port="1" to-layer="2" to-port="0" />+ <edge from-layer="2" from-port="1" to-layer="3" to-port="0" />+ <edge from-layer="3" from-port="1" to-layer="4" to-port="0" />+ <edge from-layer="4" from-port="1" to-layer="5" to-port="0" />+ </edges>+ <rt_info />+</net>+)V0G0N";++ // Customize a model with a undefined type+ std::string undefinedTypeModelXmlString = R"V0G0N(<?xml version="1.0"?>+<net name="custom_model" version="11">+ <layers>+ <layer id="0" name="Parameter_1" type="Parameter" version="opset1">+ <data shape="1,1,128" element_type="f32" />+ <output>+ <port id="0" precision="FP32" names="Parameter_1">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="1" name="Relu_2" type="ReLU" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="2" name="ReadValue_3" type="ReadValue" version="opset6">+ <data variable_id="my_var" variable_type="undefined" variable_shape="..." />+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="3" name="Assign_4" type="Assign" version="opset6">+ <data variable_id="my_var" />+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="4" name="Squeeze_5" type="Squeeze" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>1</dim>+ <dim>1</dim>+ <dim>128</dim>+ </port>+ </input>+ <output>+ <port id="1" precision="FP32" names="Output_5">+ <dim>128</dim>+ </port>+ </output>+ </layer>+ <layer id="5" name="Result_6" type="Result" version="opset1">+ <input>+ <port id="0" precision="FP32">+ <dim>128</dim>+ </port>+ </input>+ </layer>+ </layers>+ <edges>+ <edge from-layer="0" from-port="0" to-layer="1" to-port="0" />+ <edge from-layer="1" from-port="1" to-layer="2" to-port="0" />+ <edge from-layer="2" from-port="1" to-layer="3" to-port="0" />+ <edge from-layer="3" from-port="1" to-layer="4" to-port="0" />+ <edge from-layer="4" from-port="1" to-layer="5" to-port="0" />+ </edges>+ <rt_info />+</net>+)V0G0N";++ std::stringstream dynamicTypeModelXmlStream, undefinedTypeModelXmlStream, dynamicTypeModelBinStream,+ undefinedTypeModelBinStream;++ // Test whether the serialization results of the two models are the same+ auto dynamicTypeModel = ie->read_model(dynamicTypeModelXmlString, ov::Tensor());+ auto undefinedTypeModel = ie->read_model(undefinedTypeModelXmlString, ov::Tensor());++ // compile the serialized models+ ov::pass::Serialize(dynamicTypeModelXmlStream, dynamicTypeModelBinStream).run_on_model(dynamicTypeModel);+ ov::pass::Serialize(undefinedTypeModelXmlStream, undefinedTypeModelBinStream).run_on_model(undefinedTypeModel);++ ASSERT_TRUE(dynamicTypeModelXmlStream.str() == undefinedTypeModelXmlStream.str())+ << "Serialized XML files are different: dynamic type vs undefined type";++ // Test whether the inference results of the two models are the same+ // set input and output names+ const std::string inputName = "Parameter_1";+ const std::string outputName = "Output_5";++ // create input tensor match the customized models+ ov::Shape shape = {1, 1, 128};+ ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);++ auto execNetDynamic = ie->compile_model(dynamicTypeModel, target_device, configuration);+ ov::InferRequest reqDynamic;+ OV_ASSERT_NO_THROW(reqDynamic = execNetDynamic.create_infer_request());+ OV_ASSERT_NO_THROW(reqDynamic.set_tensor(inputName, inTensor));+ OV_ASSERT_NO_THROW(reqDynamic.infer());++ auto execNetUndefined = ie->compile_model(undefinedTypeModel, target_device, configuration);+ ov::InferRequest reqUndefined;+ OV_ASSERT_NO_THROW(reqUndefined = execNetUndefined.create_infer_request());+ OV_ASSERT_NO_THROW(reqUndefined.set_tensor(inputName, inTensor));+ OV_ASSERT_NO_THROW(reqUndefined.infer());++ // compare the reference outputs between dynamic type model and undefined type model+ ASSERT_TRUE(compareTensorOutputs(reqDynamic.get_tensor(outputName), reqUndefined.get_tensor(outputName)))+ << "Inference results are different: dynamic type vs undefined type";+}++} // namespace behavior+} // namespace test+} // namespace ovnamespace {diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.hppdeleted file mode 100644index cfc59147a0c..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/compile_and_infer_different_element_type.hpp+++ /dev/null@@ -1,327 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <common_test_utils/ov_tensor_utils.hpp>-#include <sstream>-#include <string>--#include "openvino/pass/serialize.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov {-namespace test {-namespace behavior {--using InferRequestElementTypeParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--// These tests are required by the NPU plugin to verify the compatibility of undefined type and dynamic type during-// compilation and inference on different NPU drivers, hence they are kept here. Compared to test in serialize it-// includes an additional comparison of inference results.-class InferRequestElementTypeTests : public testing::WithParamInterface<InferRequestElementTypeParams>,- public OVInferRequestTestBase {-public:- static std::string getTestCaseName(const testing::TestParamInfo<InferRequestElementTypeParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- std::tie(target_device, configuration) = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '.');- std::ostringstream result;- result << "targetDevice=" << target_device << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- result << "_";- }- }- return result.str();- }-- void SetUp() {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration) = this->GetParam();- APIBaseTest::SetUp();- }--protected:- bool compareTensorOutputs(const ov::Tensor& dynamicInferenceOutput, const ov::Tensor& undefinedInferenceOutput);-- std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();- ov::AnyMap configuration;-};--bool InferRequestElementTypeTests::compareTensorOutputs(const ov::Tensor& dynamicInferenceOutput,- const ov::Tensor& undefinedInferenceOutput) {- const auto dynamicShape = dynamicInferenceOutput.get_shape();- const auto undefinedShape = undefinedInferenceOutput.get_shape();-- // compare two models' element types- if (dynamicInferenceOutput.get_element_type() != undefinedInferenceOutput.get_element_type()) {- return false;- }-- // compare two models' shapes- if (dynamicShape.size() != undefinedShape.size()) {- return false;- }-- if (!std::equal(dynamicShape.cbegin(), dynamicShape.cend(), undefinedShape.cbegin())) {- return false;- }- // compare two models' data- for (size_t i = 0; i < undefinedInferenceOutput.get_size(); i++) {- if (fabs(dynamicInferenceOutput.data<float>()[i] - undefinedInferenceOutput.data<float>()[i]) >- std::numeric_limits<float>::epsilon())- return false;- }- return true;-}--// Test whether the serialization and inference results of the dynamic type model and the undefined type model are the-// same-TEST_P(InferRequestElementTypeTests, CompareDynamicAndUndefinedTypeNetwork) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- // Customize a model with a dynamic type- std::string dynamicTypeModelXmlString = R"V0G0N(<?xml version="1.0"?>-<net name="custom_model" version="11">- <layers>- <layer id="0" name="Parameter_1" type="Parameter" version="opset1">- <data shape="1,1,128" element_type="f32" />- <output>- <port id="0" precision="FP32" names="Parameter_1">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="1" name="Relu_2" type="ReLU" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="2" name="ReadValue_3" type="ReadValue" version="opset6">- <data variable_id="my_var" variable_type="dynamic" variable_shape="..." />- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="3" name="Assign_4" type="Assign" version="opset6">- <data variable_id="my_var" />- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="4" name="Squeeze_5" type="Squeeze" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32" names="Output_5">- <dim>128</dim>- </port>- </output>- </layer>- <layer id="5" name="Result_6" type="Result" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>128</dim>- </port>- </input>- </layer>- </layers>- <edges>- <edge from-layer="0" from-port="0" to-layer="1" to-port="0" />- <edge from-layer="1" from-port="1" to-layer="2" to-port="0" />- <edge from-layer="2" from-port="1" to-layer="3" to-port="0" />- <edge from-layer="3" from-port="1" to-layer="4" to-port="0" />- <edge from-layer="4" from-port="1" to-layer="5" to-port="0" />- </edges>- <rt_info />-</net>-)V0G0N";-- // Customize a model with a undefined type- std::string undefinedTypeModelXmlString = R"V0G0N(<?xml version="1.0"?>-<net name="custom_model" version="11">- <layers>- <layer id="0" name="Parameter_1" type="Parameter" version="opset1">- <data shape="1,1,128" element_type="f32" />- <output>- <port id="0" precision="FP32" names="Parameter_1">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="1" name="Relu_2" type="ReLU" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="2" name="ReadValue_3" type="ReadValue" version="opset6">- <data variable_id="my_var" variable_type="undefined" variable_shape="..." />- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="3" name="Assign_4" type="Assign" version="opset6">- <data variable_id="my_var" />- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </output>- </layer>- <layer id="4" name="Squeeze_5" type="Squeeze" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>1</dim>- <dim>1</dim>- <dim>128</dim>- </port>- </input>- <output>- <port id="1" precision="FP32" names="Output_5">- <dim>128</dim>- </port>- </output>- </layer>- <layer id="5" name="Result_6" type="Result" version="opset1">- <input>- <port id="0" precision="FP32">- <dim>128</dim>- </port>- </input>- </layer>- </layers>- <edges>- <edge from-layer="0" from-port="0" to-layer="1" to-port="0" />- <edge from-layer="1" from-port="1" to-layer="2" to-port="0" />- <edge from-layer="2" from-port="1" to-layer="3" to-port="0" />- <edge from-layer="3" from-port="1" to-layer="4" to-port="0" />- <edge from-layer="4" from-port="1" to-layer="5" to-port="0" />- </edges>- <rt_info />-</net>-)V0G0N";-- std::stringstream dynamicTypeModelXmlStream, undefinedTypeModelXmlStream, dynamicTypeModelBinStream,- undefinedTypeModelBinStream;-- // Test whether the serialization results of the two models are the same- auto dynamicTypeModel = ie->read_model(dynamicTypeModelXmlString, ov::Tensor());- auto undefinedTypeModel = ie->read_model(undefinedTypeModelXmlString, ov::Tensor());-- // compile the serialized models- ov::pass::Serialize(dynamicTypeModelXmlStream, dynamicTypeModelBinStream).run_on_model(dynamicTypeModel);- ov::pass::Serialize(undefinedTypeModelXmlStream, undefinedTypeModelBinStream).run_on_model(undefinedTypeModel);-- ASSERT_TRUE(dynamicTypeModelXmlStream.str() == undefinedTypeModelXmlStream.str())- << "Serialized XML files are different: dynamic type vs undefined type";-- // Test whether the inference results of the two models are the same- // set input and output names- const std::string inputName = "Parameter_1";- const std::string outputName = "Output_5";-- // create input tensor match the customized models- ov::Shape shape = {1, 1, 128};- ov::Tensor inTensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);-- auto execNetDynamic = ie->compile_model(dynamicTypeModel, target_device, configuration);- ov::InferRequest reqDynamic;- OV_ASSERT_NO_THROW(reqDynamic = execNetDynamic.create_infer_request());- OV_ASSERT_NO_THROW(reqDynamic.set_tensor(inputName, inTensor));- OV_ASSERT_NO_THROW(reqDynamic.infer());-- auto execNetUndefined = ie->compile_model(undefinedTypeModel, target_device, configuration);- ov::InferRequest reqUndefined;- OV_ASSERT_NO_THROW(reqUndefined = execNetUndefined.create_infer_request());- OV_ASSERT_NO_THROW(reqUndefined.set_tensor(inputName, inTensor));- OV_ASSERT_NO_THROW(reqUndefined.infer());-- // compare the reference outputs between dynamic type model and undefined type model- ASSERT_TRUE(compareTensorOutputs(reqDynamic.get_tensor(outputName), reqUndefined.get_tensor(outputName)))- << "Inference results are different: dynamic type vs undefined type";-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cppindex 8386c0b3c07..1ed6786ec00 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.cpp@@ -2,10 +2,2864 @@// SPDX-License-Identifier: Apache-2.0//-#include "infer_request_run.hpp"+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <thread>+#include "behavior/ov_infer_request/inference.hpp"+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common/zero_init_mock.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_types.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/log.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class InferRequestRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;+ ov::Output<const ov::Node> input;+ ov::Output<const ov::Node> output;+ std::string m_cache_dir;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration) = this->GetParam();+ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555+ }++ std::string generateCacheDirName(const std::string& test_name) {+ using namespace std::chrono;+ // Generate unique file names based on test name, thread id and timestamp+ // This allows execution of tests in parallel (stress mode)+ auto hash = std::to_string(std::hash<std::string>()(test_name));+ std::stringstream ss;+ auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());+ ss << hash << "_" << "_" << ts.count();+ return ss.str();+ }++ void TearDown() override {+ if (!m_cache_dir.empty()) {+ core->set_property({ov::cache_dir()});+ core.reset();+ ov::test::utils::PluginCache::get().reset();+ ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");+ ov::test::utils::removeDir(m_cache_dir);+ }++ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }++ std::shared_ptr<ov::Model> createModel(element::Type type, const PartialShape& shape, const ov::Layout& layout) {+ ResultVector res;+ ParameterVector params;++ auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);+ data1->set_friendly_name("input");+ data1->get_output_tensor(0).set_names({"tensor_input"});+ data1->set_layout(layout);+ auto constant = opset8::Constant::create(type, {1}, {1});+ auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);+ op1->set_friendly_name("Add");+ auto res1 = std::make_shared<ov::op::v0::Result>(op1);+ res1->set_friendly_name("Result");+ res1->get_output_tensor(0).set_names({"tensor_output"});+ params.push_back(data1);+ res.push_back(res1);++ return std::make_shared<Model>(res, params);+ }+};++using BooleanPrecisionCompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap, // Config+ bool, // With warmup infer()+ bool>; // With reset Infer Request++class BooleanPrecisionInferRequestRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<BooleanPrecisionCompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;+ bool withWarmUpInfer = false;+ bool withResetInferRequest = false;++ std::shared_ptr<ov::Model> createTwoInputLessEqualModel(const PartialShape& shape = {2, 16, 16, 16}) {+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);+ param0->get_output_tensor(0).set_names({"tensor_input_0"});+ param0->set_layout("N...");+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);+ param1->get_output_tensor(0).set_names({"tensor_input_1"});+ param1->set_layout("N...");+ auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);+ auto result = std::make_shared<ov::op::v0::Result>(lessEqual);+ result->get_output_tensor(0).set_names({"tensor_output"});++ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});+ model->set_friendly_name("TwoInputLessEqual");+ return model;+ }++ std::shared_ptr<ov::Model> createTwoInputNonZeroAddModel(const PartialShape& shape = {2, 16, 16, 16}) {+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);+ param0->get_output_tensor(0).set_names({"tensor_input_0"});+ param0->set_layout("N...");+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);+ param1->get_output_tensor(0).set_names({"tensor_input_1"});+ param1->set_layout("N...");+ auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);+ auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);+ // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input+ // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf+ auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);+ auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);+ auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);+ auto result = std::make_shared<ov::op::v0::Result>(add);+ result->get_output_tensor(0).set_names({"tensor_output"});++ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});+ model->set_friendly_name("TwoTwoInputNonZeroAddModel");+ return model;+ }++public:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration, withWarmUpInfer, withResetInferRequest) = this->GetParam();+ OVPluginTestBase::SetUp();+ ov_model = createTwoInputNonZeroAddModel();+ }+};++TEST_P(InferRequestRunTests, AllocatorCanDisposeBlobWhenOnlyInferRequestIsInScope) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ ov::InferRequest req;+ ov::Tensor outputTensor;+ {+ core.reset();+ ov::test::utils::PluginCache::get().reset();+ }+ }+}++TEST_P(InferRequestRunTests, MultipleExecutorStreamsTestsSyncInfers) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ ov::CompiledModel compiled_model;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(input = compiled_model.input());+ OV_ASSERT_NO_THROW(output = compiled_model.output());++ const int inferReqNumber = 256;+ std::array<ov::InferRequest, inferReqNumber> inferReqs;+ std::array<std::thread, inferReqNumber> inferReqsThreads;+ for (int i = 0; i < inferReqNumber; ++i) {+ OV_ASSERT_NO_THROW(inferReqs[i] = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(input));+ }++ for (int i = 0; i < inferReqNumber; ++i) {+ ov::InferRequest& infReq = inferReqs[i];+ inferReqsThreads[i] = std::thread([&infReq]() -> void {+ OV_ASSERT_NO_THROW(infReq.infer());+ });+ }++ for (int i = 0; i < inferReqNumber; ++i) {+ inferReqsThreads[i].join();+ OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(output));+ }+}++TEST_P(InferRequestRunTests, MultipleExecutorStreamsTestsAsyncInfers) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ ov::CompiledModel compiled_model;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(input = compiled_model.input());+ OV_ASSERT_NO_THROW(output = compiled_model.output());++ const int inferReqNumber = 256;+ std::array<ov::InferRequest, inferReqNumber> inferReqs;+ for (int i = 0; i < inferReqNumber; ++i) {+ OV_ASSERT_NO_THROW(inferReqs[i] = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(input));+ }++ for (int i = 0; i < inferReqNumber; ++i) {+ OV_ASSERT_NO_THROW(inferReqs[i].start_async());+ }++ for (int i = 0; i < inferReqNumber; ++i) {+ inferReqs[i].wait();+ OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(output));+ }+}++TEST_P(BooleanPrecisionInferRequestRunTests, BooleanTensorDataTypesForBooleanModelsWork) {+ // TODO: Also test createTwoInputLessEqualModel model when we have compiler support+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ ov::CompiledModel compiled_model_boolean, compiled_model_boolean_imported;+ std::shared_ptr<ov::InferRequest> infer_request_boolean, infer_request_boolean_imported;++ try {+ (void)core->get_property(target_device, ov::intel_npu::batch_mode);+ } catch (...) {+ configuration.erase(ov::intel_npu::batch_mode.name());+ }++ bool isPVDriver = (core->get_property(target_device, ov::intel_npu::driver_version) == 1688);++ bool isDriverCompiler =+ (configuration.find(ov::intel_npu::compiler_type.name()) != configuration.end() &&+ configuration.find(ov::intel_npu::compiler_type.name())->second.as<ov::intel_npu::CompilerType>() ==+ ov::intel_npu::CompilerType::DRIVER);+ if (isPVDriver && isDriverCompiler) {+ GTEST_SKIP() << "CID from PV driver cannot compile models with boolean inputs!";+ }++ OV_ASSERT_NO_THROW(compiled_model_boolean = core->compile_model(ov_model, target_device, configuration));+ OPENVINO_ASSERT(compiled_model_boolean.input(0).get_element_type() == ov::element::boolean);+ OPENVINO_ASSERT(compiled_model_boolean.input(1).get_element_type() == ov::element::boolean);++ if (!isPVDriver) {+ std::stringstream ss;+ compiled_model_boolean.export_model(ss);+ OV_ASSERT_NO_THROW(compiled_model_boolean_imported = core->import_model(ss, target_device, configuration));+ infer_request_boolean_imported =+ std::make_shared<ov::InferRequest>(compiled_model_boolean_imported.create_infer_request());+ }+ infer_request_boolean = std::make_shared<ov::InferRequest>(compiled_model_boolean.create_infer_request());++ const auto infer_requests =+ (isPVDriver+ ? std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean}+ : std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean, infer_request_boolean_imported});++ auto [importMemoryBatchedTensor,+ importMemoryTensor_1,+ importMemoryTensor_2,+ unalignedBatchedTensor,+ unalignedTensor_1,+ unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);++ ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());+ ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());+ importMemoryBatchedTensor.copy_to(ref_import_tensor);+ unalignedBatchedTensor.copy_to(ref_tensor_unaligned);++ for (auto infer_request : infer_requests) {+ auto reset_infer_request_cb = [&infer_request]() {+ auto compiled_model = infer_request->get_compiled_model();+ infer_request = std::make_shared<ov::InferRequest>(compiled_model.create_infer_request());+ };++ if (withWarmUpInfer) {+ infer_request->infer();+ }++ const auto& compiled_model = infer_request->get_compiled_model();++ OV_ASSERT_NO_THROW(+ ov::test::utils::set_tensors_and_infer(infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiled_model.input(0),+ std::vector<ov::Tensor>{importMemoryTensor_1, unalignedTensor_2},+ reset_infer_request_cb));+ OV_ASSERT_NO_THROW(+ ov::test::utils::set_tensors_and_infer(infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiled_model.input(1),+ std::vector<ov::Tensor>{importMemoryTensor_2, unalignedTensor_1},+ reset_infer_request_cb));++ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiled_model.input(0),+ importMemoryBatchedTensor,+ reset_infer_request_cb));+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiled_model.input(1),+ unalignedBatchedTensor,+ reset_infer_request_cb));++ OV_ASSERT_NO_THROW(+ ov::test::utils::set_tensors_and_infer(infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiled_model.input(0),+ std::vector<ov::Tensor>{unalignedTensor_1, importMemoryTensor_1},+ reset_infer_request_cb));+ OV_ASSERT_NO_THROW(+ ov::test::utils::set_tensors_and_infer(infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiled_model.input(1),+ std::vector<ov::Tensor>{unalignedTensor_2, importMemoryTensor_2},+ reset_infer_request_cb));+ } // for infer_request++ // ensure user tensors don't get altered during tests+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));+}++using ProfilingBlob = InferRequestRunTests;++TEST_P(ProfilingBlob, NoProfilingCompileProfilingImport) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {+ GTEST_SKIP() << "Skip since driver extension version is lower than expected";+ }+ ov::CompiledModel compiled_model;++ configuration[ov::enable_profiling.name()] = false;+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration[ov::enable_profiling.name()] = true;+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));++ ov::InferRequest inferReq;++ OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());++ if (configuration.find(ov::intel_npu::profiling_type.name())->second == ov::intel_npu::ProfilingType::MODEL) {+ ASSERT_ANY_THROW(inferReq.infer());+ } else {+ OV_ASSERT_NO_THROW(inferReq.infer());+ }+}++TEST_P(ProfilingBlob, ProfilingCompileNoProfilingImport) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {+ GTEST_SKIP() << "Skip since driver extension version is lower than expected";+ }+ ov::CompiledModel compiled_model;++ configuration[ov::enable_profiling.name()] = true;+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration[ov::enable_profiling.name()] = false;+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));++ ov::InferRequest inferReq;++ OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());++ OV_ASSERT_NO_THROW(inferReq.infer());+}++TEST_P(ProfilingBlob, ProfilingCompileProfilingImport) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {+ GTEST_SKIP() << "Skip since driver extension version is lower than expected";+ }+ ov::CompiledModel compiled_model;++ configuration[ov::enable_profiling.name()] = true;+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));++ ov::InferRequest inferReq;++ OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());++ OV_ASSERT_NO_THROW(inferReq.infer());+}++TEST_P(InferRequestRunTests, MultipleExecutorTestsSyncInfers) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ ov::CompiledModel compiled_model;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(input = compiled_model.input());+ OV_ASSERT_NO_THROW(output = compiled_model.output());++ const int inferReqNumber = 256;+ ov::InferRequest inferReq;+ ov::Tensor input_tensor;+ for (int i = 0; i < inferReqNumber; ++i) {+ OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(input_tensor = inferReq.get_tensor(input));+ OV_ASSERT_NO_THROW(inferReq.set_input_tensor(input_tensor));+ OV_ASSERT_NO_THROW(inferReq.infer());+ OV_ASSERT_NO_THROW(inferReq.get_tensor(output));+ }+}++TEST_P(InferRequestRunTests, CheckOutputDataFromTwoRuns) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;+ float* data;++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ const size_t byte_size = tensor.get_byte_size();+ data = new float[byte_size / sizeof(float)];+ memset(data, 1, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ first_output = inference_request.get_output_tensor(0);++ for (int i = 0; i < 10; i++) {+ delete[] data;+ compiled_model = {};+ inference_request = {};++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ const size_t byte_size = tensor.get_byte_size();+ data = new float[byte_size / sizeof(float)];+ memset(data, 1, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);+ }+}++TEST_P(InferRequestRunTests, CheckOutputDataFromMultipleRunsUsingSameL0Tensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;+ ov::Tensor global_input;++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ global_input = inference_request.get_input_tensor();+ const size_t byte_size = global_input.get_byte_size();+ memset(global_input.data(), 1, byte_size);+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ first_output = inference_request.get_output_tensor(0);++ for (int i = 0; i < 10; i++) {+ compiled_model = {};+ inference_request = {};++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);+ }+}++TEST_P(InferRequestRunTests, RecreateL0TensorIfNeeded) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;+ ov::Tensor global_input;+ float* data;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ global_input = inference_request.get_input_tensor();+ memset(global_input.data(), 1, global_input.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor(0);++ compiled_model = {};+ inference_request = {};++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);++ for (int i = 0; i < 10; i++) {+ {+ const size_t byte_size = global_input.get_byte_size();+ data = new float[byte_size / sizeof(float)];+ memset(data, 1, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, global_input.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);++ delete[] data;+ }+}++TEST_P(InferRequestRunTests, RunWithConstData) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ const auto tensor = inference_request.get_input_tensor();+ const std::vector<float> data(tensor.get_byte_size() / sizeof(float));+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor({ov::element::f32, tensor.get_shape(), data.data()}));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++using RandomTensorOverZeroTensorRunTests = InferRequestRunTests;++TEST_P(RandomTensorOverZeroTensorRunTests, SetRandomTensorOverZeroTensor0) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;++ auto shape = Shape{1, 2, 2, 2};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input_zero_tensor = inference_request.get_input_tensor(0);+ auto* input_zero_data = input_zero_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_zero_data[i] = 5.f;+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_tensor = inference_request.get_output_tensor(0);+ auto* output_data = output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data[i] << " for index " << i;+ }++ float* buffer = new float[shape_size];+ ov::Tensor tensor{element::f32, shape, buffer};+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 9.f;+ }++ inference_request.set_input_tensor(tensor);+ inference_request.infer(); // Adds '1' to each element+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data[i], 10.f, 1e-5) << "Expected=10, actual=" << output_data[i] << " for index " << i;+ }++ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(input_zero_data[i], 5.f, 1e-5) << "Expected=5, actual=" << input_zero_data[i] << " for index " << i;+ }++ delete[] buffer;+}++TEST_P(RandomTensorOverZeroTensorRunTests, SetRandomTensorOverZeroTensor1) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;++ auto shape = Shape{1, 2, 2, 2};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request0, inference_request1;+ inference_request0 = compiled_model.create_infer_request();+ inference_request1 = compiled_model.create_infer_request();++ auto input_zero_tensor = inference_request0.get_input_tensor(0);+ auto* input_zero_data = input_zero_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_zero_data[i] = 5.f;+ }++ inference_request0.infer(); // Adds '1' to each element++ auto output_tensor0 = inference_request0.get_output_tensor(0);+ auto* output_data0 = output_tensor0.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data0[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data0[i] << " for index " << i;+ }++ inference_request1.set_input_tensor(output_tensor0);+ inference_request1.infer(); // Adds '1' to each element++ auto output_tensor1 = inference_request1.get_output_tensor(0);+ auto* output_data1 = output_tensor1.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data1[i], 7.f, 1e-5) << "Expected=7, actual=" << output_data1[i] << " for index " << i;+ }++ float* buffer = new float[shape_size];+ ov::Tensor tensor{element::f32, shape, buffer};+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 9.f;+ }++ inference_request1.set_input_tensor(tensor);+ inference_request1.infer(); // Adds '1' to each element++ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data1[i], 10.f, 1e-5) << "Expected=10, actual=" << output_data1[i] << " for index " << i;+ }++ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(output_data0[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data0[i] << " for index " << i;+ }++ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(input_zero_data[i], 5.f, 1e-5) << "Expected=5, actual=" << input_zero_data[i] << " for index " << i;+ }++ delete[] buffer;+}++using BatchingRunTests = InferRequestRunTests;++TEST_P(BatchingRunTests, CheckBatchingSupportInfer) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;++ ov::InferRequest inference_request;+ auto batch_shape = Shape{4, 2, 32, 32};+ std::shared_ptr<ov::Model> ov_model_batch = createModel(element::f32, batch_shape, "N...");++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model_batch, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(BatchingRunTests, CheckBatchingSupportAsync) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ auto batch_shape = Shape{4, 2, 32, 32};+ std::shared_ptr<ov::Model> ov_model_batch = createModel(element::f32, batch_shape, "N...");++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model_batch, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.start_async());+ inference_request.wait();+}++TEST_P(BatchingRunTests, UseCompilerBatchingErrorPluginBatching) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::CompiledModel compiled_model;++ ov::InferRequest inference_request;+ std::shared_ptr<ov::Model> ov_model_batch = getDefaultNGraphFunctionForTheDeviceNPU({4, 2, 32, 32});++ auto batch_mode = configuration[ov::intel_npu::batch_mode.name()].as<std::string>();+ try {+ compiled_model = core->compile_model(ov_model_batch, target_device, configuration);+ inference_request = compiled_model.create_infer_request();+ inference_request.start_async();+ inference_request.wait();+ } catch (std::exception& ex) {+ if (batch_mode != "PLUGIN") {+ ASSERT_FALSE(true) << ex.what();+ }+ }+}++TEST_P(BatchingRunTests, SetInputTensorInfer) {+ auto batch_shape = Shape{4, 2, 2, 2};+ auto shape_size = ov::shape_size(batch_shape);+ auto model = createModel(element::f32, batch_shape, "N...");+ float* buffer = new float[shape_size];++ ov::CompiledModel compiled_model;++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ ov::Tensor tensor{element::f32, batch_shape, buffer};++ inference_request.set_input_tensor(tensor);+ auto actual_tensor = inference_request.get_output_tensor(0);+ auto* actual = actual_tensor.data<float>();+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }++ inference_request.infer(); // Adds '1' to each element+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }+}++TEST_P(BatchingRunTests, SetInputTensorAsync) {+ auto batch_shape = Shape{4, 2, 2, 2};+ auto shape_size = ov::shape_size(batch_shape);+ auto model = createModel(element::f32, batch_shape, "N...");+ float* buffer = new float[shape_size];++ ov::CompiledModel compiled_model;++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ ov::Tensor tensor{element::f32, batch_shape, buffer};++ inference_request.set_input_tensor(tensor);+ auto actual_tensor = inference_request.get_output_tensor(0);+ auto* actual = actual_tensor.data<float>();+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }++ inference_request.start_async(); // Adds '1' to each element+ inference_request.wait_for(std::chrono::milliseconds(1000));+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }+}++TEST_P(BatchingRunTests, SetInputTensorInfer_Caching) {+ auto batch_shape = Shape{4, 2, 2, 2};+ auto shape_size = ov::shape_size(batch_shape);+ auto model = createModel(element::f32, batch_shape, "N...");+ float* buffer = new float[shape_size];++ ov::CompiledModel compiled_model;++ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});+ auto compiled_model_no_cache = core->compile_model(model, target_device, configuration);+ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ ov::Tensor tensor{element::f32, batch_shape, buffer};++ inference_request.set_input_tensor(tensor);+ auto actual_tensor = inference_request.get_output_tensor(0);+ auto* actual = actual_tensor.data<float>();+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }++ inference_request.infer(); // Adds '1' to each element+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }++ delete[] buffer;+}++TEST_P(BatchingRunTests, CheckTwoRunsInfer) {+ auto batch_shape = Shape{4, 2, 2, 2};+ auto shape_size = ov::shape_size(batch_shape);+ auto model = createModel(element::f32, batch_shape, "N...");+ float* buffer = new float[shape_size];++ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device);++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ ov::Tensor tensor{element::f32, batch_shape, buffer};++ inference_request.set_input_tensor(tensor);+ auto actual_tensor = inference_request.get_output_tensor(0);+ auto* actual = actual_tensor.data<float>();+ auto* input_data = tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }+ inference_request.infer(); // Adds '1' to each element+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }++ auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, batch_shape);+ auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, actual_tensor.get_shape());++ auto* input_data_host_tensor = l0_host_input_tensor.data();+ input_data = reinterpret_cast<float*>(input_data_host_tensor);+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }+ inference_request.set_input_tensor(l0_host_input_tensor);+ inference_request.set_output_tensor(l0_host_output_tensor);+ inference_request.infer();++ auto* actual_host_tensor = l0_host_output_tensor.data();+ actual = reinterpret_cast<float*>(actual_host_tensor);+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }++ delete[] buffer;+}++using RunSeqTests = InferRequestRunTests;++TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {+ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const uint32_t inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);+ for (uint32_t i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ inference_request[0].set_input_tensor(input_tensor);+ inference_request[0].set_output_tensor(output_tensor[0]);++ const uint32_t runs = 10;+ for (uint32_t z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request[0].start_async(); // Adds '1' to each element++ for (uint32_t i = 1; i < inferences; i++) {+ inference_request[i].set_input_tensor(output_tensor[i - 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[inferences - 1].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (uint32_t i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+}++TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {+ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);++ for (int i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ inference_request[inferences - 1].set_input_tensor(input_tensor);+ inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);++ const int runs = 10;+ for (int z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request[inferences - 1].start_async(); // Adds '1' to each element++ for (int i = inferences - 2; i >= 0; i--) {+ inference_request[i].set_input_tensor(output_tensor[i + 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[0].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (int i = inferences - 1; i >= 0; i--) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+}++TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {+ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);++ for (int i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ inference_request[inferences - 1].set_input_tensor(input_tensor);+ inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);++ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 1.f;+ }++ inference_request[inferences - 1].start_async();++ for (int i = inferences - 2; i >= 0; i--) {+ inference_request[i].set_input_tensor(output_tensor[i + 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async();+ }++ inference_request[0].wait();++ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();++ bool isRunInferencesSequentially =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::run_inferences_sequentially.name();+ });++ if (::intel_npu::ZeroInitStructsHolder::getInstance()->getCommandQueueDdiTable().version() >=+ ZE_MAKE_VERSION(1, 1)) {+ ASSERT_TRUE(isRunInferencesSequentially);++ inference_request[5].start_async();+ inference_request[5].wait();+ } else {+ ASSERT_TRUE(!isRunInferencesSequentially);+ try {+ inference_request[5].start_async();+ inference_request[5].wait();+ } catch (const std::exception& ex) {+ ASSERT_FALSE(false) << ex.what();+ return;+ }++ ASSERT_FALSE(true) << "Exception is expected but it didn't throw any exception!";+ }+}++TEST_P(RunSeqTests, CheckMultipleRunsSeq3) {+ auto shape = Shape{1, 64, 64, 256};+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ OV_EXPECT_THROW(inference_request.infer(),+ ov::Exception,+ HasSubstr("Only start async is supported when RUN_INFERENCES_SEQUENTIALLY is enabled!"));+}++TEST_P(RunSeqTests, CheckMultipleRunsSeq4) {+ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();++ ov::CompiledModel compiled_model;++ bool isRunInferencesSequentially =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {+ return property == intel_npu::run_inferences_sequentially.name();+ });++ if (isRunInferencesSequentially) {+ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);++ for (int i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ const int runs = 10;+ for (int z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ if (runs % 2) {+ inference_request[inferences - 1].set_input_tensor(input_tensor);+ inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);++ inference_request[inferences - 1].start_async(); // Adds '1' to each element++ for (int i = inferences - 2; i >= 0; i--) {+ inference_request[i].set_input_tensor(output_tensor[i + 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[0].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (int i = inferences - 1; i >= 0; i--) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ } else {+ inference_request[0].set_input_tensor(input_tensor);+ inference_request[0].set_output_tensor(output_tensor[0]);++ inference_request[0].start_async(); // Adds '1' to each element++ for (uint32_t i = 1; i < inferences; i++) {+ inference_request[i].set_input_tensor(output_tensor[i - 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[inferences - 1].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (uint32_t i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+ }+ }+}++TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {+ auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();++ auto shape = Shape{1, 64, 64, 256};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model;++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[intel_npu::turbo.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);++ for (int i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ const int runs = 10;+ for (int z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request[inferences - 1].set_input_tensor(input_tensor);+ inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);++ inference_request[inferences - 1].start_async(); // Adds '1' to each element++ for (int i = inferences - 2; i >= 0; i--) {+ inference_request[i].set_input_tensor(output_tensor[i + 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[0].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (int i = inferences - 1; i >= 0; i--) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+}++using BatchingRunSeqTests = InferRequestRunTests;++TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {+ auto shape = Shape{4, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model;++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ compiled_model = core->compile_model(model, target_device, configuration);++ const uint32_t inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);+ for (uint32_t i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ inference_request[0].set_input_tensor(input_tensor);+ inference_request[0].set_output_tensor(output_tensor[0]);++ const uint32_t runs = 10;+ for (uint32_t z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request[0].start_async(); // Adds '1' to each element++ for (uint32_t i = 1; i < inferences; i++) {+ inference_request[i].set_input_tensor(output_tensor[i - 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[inferences - 1].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (uint32_t i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+}++using DynamicBatchingTests = InferRequestRunTests;++TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun0) {+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 64, 64};+ size_t batch_size = 1;+ auto shape = Shape{batch_size, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, modelShape, "N...");++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ ov::InferRequest inference_request;+ ov::Tensor input_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);++ inference_request = compiled_model.create_infer_request();++ inference_request.set_input_tensor(input_tensor);++ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(batch_size);+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_tensor = inference_request.get_output_tensor();++ float expected_result = static_cast<float>(batch_size) + 1.f;+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }++ for (auto z = batch_size + 1; z <= 10; z++) {+ auto host_shape = Shape{z, 2, 64, 64};+ auto input_host_tensor = context.create_host_tensor(ov::element::f32, host_shape);++ inference_request.set_input_tensor(input_host_tensor);++ auto* input_data = reinterpret_cast<float*>(input_host_tensor.data());+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_test_tensor = inference_request.get_output_tensor();++ float expected_result = static_cast<float>(z) + 1.f;+ auto* output_tensor_data = reinterpret_cast<float*>(output_test_tensor.data());++ EXPECT_EQ(output_test_tensor.get_size(), input_host_tensor.get_size());++ for (size_t j = 0; j < output_test_tensor.get_size(); ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ }+}++TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun1) {+ auto modelShape = PartialShape{-1, 2, 64, 64};+ size_t batch_size = 1;+ auto shape = Shape{batch_size, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, modelShape, "N...");++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ ov::InferRequest inference_request;+ ov::Tensor input_tensor;++ input_tensor = ov::Tensor(ov::element::f32, shape);++ inference_request = compiled_model.create_infer_request();++ inference_request.set_input_tensor(input_tensor);++ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(batch_size);+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_tensor = inference_request.get_output_tensor();++ float expected_result = static_cast<float>(batch_size) + 1.f;+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }++ for (auto z = batch_size + 1; z <= 10; z++) {+ auto host_shape = Shape{z, 2, 64, 64};+ auto input_host_tensor = ov::Tensor(ov::element::f32, host_shape);++ inference_request.set_input_tensor(input_host_tensor);++ auto* input_data = reinterpret_cast<float*>(input_host_tensor.data());+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_test_tensor = inference_request.get_output_tensor();++ float expected_result = static_cast<float>(z) + 1.f;+ auto* output_tensor_data = reinterpret_cast<float*>(output_test_tensor.data());++ EXPECT_EQ(output_test_tensor.get_size(), input_host_tensor.get_size());++ for (size_t j = 0; j < output_test_tensor.get_size(); ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ }+}++TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun2) {+ auto modelShape = PartialShape{-1, 2, 64, 64};+ size_t batch_size = 3;+ auto shape = Shape{batch_size, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, modelShape, "N...");++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ ov::InferRequest inference_request;+ ov::Tensor input_tensor;++ input_tensor = ov::Tensor(ov::element::f32, shape);++ inference_request = compiled_model.create_infer_request();++ inference_request.set_input_tensor(input_tensor);++ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(batch_size);+ }++ inference_request.infer(); // Adds '1' to each element++ auto output_tensor = inference_request.get_output_tensor();++ float expected_result = static_cast<float>(batch_size) + 1.f;+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+}++TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRunsSeq) {+ auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 64, 64};+ auto shape = Shape{4, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, modelShape, "N...");++ auto context = core->get_default_context(target_device);++ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;+ configuration[ov::intel_npu::tiles.name()] = 2;+ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ const uint32_t inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = context.create_host_tensor(ov::element::f32, shape);+ for (uint32_t i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ }++ inference_request[0].set_input_tensor(input_tensor);+ inference_request[0].set_output_tensor(output_tensor[0]);++ const uint32_t runs = 10;+ for (uint32_t z = 0; z < runs; z++) {+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(z);+ }++ inference_request[0].start_async(); // Adds '1' to each element++ for (uint32_t i = 1; i < inferences; i++) {+ inference_request[i].set_input_tensor(output_tensor[i - 1]);+ inference_request[i].set_output_tensor(output_tensor[i]);++ inference_request[i].start_async(); // Adds '1' to each element+ }++ inference_request[inferences - 1].wait();++ float expected_result = static_cast<float>(z) + 1.f;++ for (uint32_t i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Run=" << z << "Output=" << i << " Expected=" << expected_result+ << ", actual=" << output_tensor_data[j] << " for index " << j;+ }+ expected_result++;+ }+ }+}++using ROITensorInference = OVInferRequestInferenceTests;++TEST_P(ROITensorInference, InferenceROITensor) {+ auto model = OVInferRequestInferenceTests::create_n_inputs(1, ov::element::f32, m_param.m_shape);+ auto compiled_model = ie->compile_model(model, target_device);++ ov::InferRequest req;+ req = compiled_model.create_infer_request();+ const std::string tensor_name = "tensor_input0";++ OV_EXPECT_THROW_HAS_SUBSTRING(req.set_tensor(tensor_name, m_param.m_input_tensor),+ ov::Exception,+ "tensor has a non-contiguous memory");+}++using SetShapeInferRunTests = InferRequestRunTests;++TEST_P(SetShapeInferRunTests, checkResultsAfterIOBlobReallocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto original_shape = Shape{1, 10, 10, 10};+ auto dummy_shape = Shape{1, 50, 100, 100};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModel(element::f32, original_shape, "N...");++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ input = compiled_model.input();+ output = compiled_model.output();++ ov::Tensor input_tensor, first_output_tensor, second_output_tensor;+ auto in_shape = input.get_shape();+ auto out_shape = output.get_shape();++ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 5.f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());+ OV_ASSERT_NO_THROW(first_output_tensor = inference_request.get_tensor(output));+ // create dummy Tensors to force the driver to allocate memory for the initial tensor somewhere else+ [[maybe_unused]] auto l0_host_dummy_tensor_0 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_1 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_2 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_3 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_4 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_5 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_6 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_7 = context.create_host_tensor(ov::element::f32, dummy_shape);++ auto* actual = first_output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;+ }++ // imitates blob reallocation+ OV_ASSERT_NO_THROW(input_tensor.set_shape({1, 50, 20, 20}));+ OV_ASSERT_NO_THROW(input_tensor.set_shape(in_shape));++ OV_ASSERT_NO_THROW(second_output_tensor = inference_request.get_tensor(output));+ OV_ASSERT_NO_THROW(second_output_tensor.set_shape({1, 20, 20, 20}));+ OV_ASSERT_NO_THROW(second_output_tensor.set_shape(out_shape));++ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 9.f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());+ OV_ASSERT_NO_THROW(second_output_tensor = inference_request.get_tensor(output));++ actual = second_output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_NEAR(actual[i], 10.f, 1e-5) << "Expected=10, actual=" << actual[i] << " for index " << i;+ }+}++TEST_P(SetShapeInferRunTests, checkResultsAfterStateTensorsReallocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ testing::internal::Random random(1);+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 10, 10, 10};+ auto dummy_shape = Shape{1, 50, 100, 100};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ for (auto&& state : inference_request.query_state()) {+ state.reset();+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ ASSERT_NEAR(0.5f, output_data[i], 1e-5);+ }++ auto states = inference_request.query_state();+ for (auto state : states) {+ auto last_state = state.get_state();+ auto last_state_size = last_state.get_size();+ auto last_state_data = static_cast<float*>(last_state.data());++ ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";++ for (size_t i = 0; i < last_state_size; ++i) {+ ASSERT_NEAR(0.0, last_state_data[i], 1e-5);+ }+ }++ // create dummy Tensors to force the driver to allocate memory for the initial tensor somewhere else+ [[maybe_unused]] auto l0_host_dummy_tensor_0 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_1 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_2 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_3 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_4 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_5 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_6 = context.create_host_tensor(ov::element::f32, dummy_shape);+ [[maybe_unused]] auto l0_host_dummy_tensor_7 = context.create_host_tensor(ov::element::f32, dummy_shape);++ for (auto item : inference_request.query_state()) {+ auto tensor_state = item.get_state();+ auto original_shape = tensor_state.get_shape();+ OV_ASSERT_NO_THROW(tensor_state.set_shape({1, 50, 20, 20}));+ OV_ASSERT_NO_THROW(tensor_state.set_shape(original_shape));+ }++ for (auto&& state : inference_request.query_state()) {+ state.reset();+ }++ for (auto state : states) {+ auto last_state = state.get_state();+ auto last_state_size = last_state.get_size();+ auto last_state_data = static_cast<float*>(last_state.data());++ ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";++ for (size_t i = 0; i < last_state_size; ++i) {+ last_state_data[i] = 1.0f;+ }+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ for (auto state : states) {+ auto last_state = state.get_state();+ auto last_state_size = last_state.get_size();+ auto last_state_data = static_cast<float*>(last_state.data());++ ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";++ for (size_t i = 0; i < last_state_size; ++i) {+ ASSERT_NEAR(input_data[i], last_state_data[i], 1e-5);+ }+ }+}++using CpuVaTensorsTests = InferRequestRunTests;++TEST_P(CpuVaTensorsTests, DontDestroyImportedMemory) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;+ ov::Tensor global_input;+ float* data;+ ov::CompiledModel compiled_model;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ global_input = inference_request.get_input_tensor();+ memset(global_input.data(), 1, global_input.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor(0);++ compiled_model = {};+ inference_request = {};++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);++ const size_t byte_size = global_input.get_byte_size();+ data = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));+ memset(data, 1, byte_size);++ for (int i = 0; i < 10; i++) {+ {+ ov::Tensor input_data_tensor{ov::element::f32, global_input.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ }+ second_output = inference_request.get_output_tensor(0);++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);+ }++ inference_request = {};++ ::operator delete(data, std::align_val_t(4096));+}++TEST_P(CpuVaTensorsTests, SetMultiplePageAllignedTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ ov::InferRequest inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ float* input_data;+ float* output_data[inferences];++ const auto input_byte_size = shape_size * sizeof(float);+ input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 0.f;+ }+ input_tensor = ov::Tensor{ov::element::f32, shape, input_data};++ inference_request = compiled_model.create_infer_request();++ for (int i = 0; i < inferences; i++) {+ auto tensor = inference_request.get_output_tensor(0);+ const auto byte_size = tensor.get_byte_size();++ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};+ }++ inference_request.set_input_tensor(input_tensor);+ inference_request.set_output_tensor(output_tensor[0]);++ inference_request.infer(); // Adds '1' to each element++ for (int i = 1; i < inferences; i++) {+ inference_request.set_output_tensor(output_tensor[i]);+ inference_request.set_input_tensor(output_tensor[i - 1]);++ inference_request.infer(); // Adds '1' to each element+ }++ float expected_result = 1.f;++ for (int i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ EXPECT_EQ(output_tensor_data, output_data[i]);+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ expected_result++;+ }++ inference_request = {};++ input_tensor = {};+ ::operator delete(input_data, std::align_val_t(4096));+ for (int i = 0; i < inferences; i++) {+ output_tensor[i] = {};+ ::operator delete(output_data[i], std::align_val_t(4096));+ }+}++TEST_P(CpuVaTensorsTests, SetMultipleAllignedAndNotAllignedTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ ov::InferRequest inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ float* input_data;+ float* output_data[inferences];++ const auto input_byte_size = shape_size * sizeof(float);+ input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));+ input_tensor = ov::Tensor{ov::element::f32, shape, input_data};++ inference_request = compiled_model.create_infer_request();+ for (int i = 0; i < inferences; i++) {+ auto tensor = inference_request.get_output_tensor(0);+ const auto byte_size = tensor.get_byte_size();++ if (i % 2 == 0) {+ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(16)));+ } else {+ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));+ }+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};+ }++ inference_request.set_input_tensor(input_tensor);+ inference_request.set_output_tensor(output_tensor[0]);++ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 0.f;+ }++ inference_request.infer(); // Adds '1' to each element++ for (int i = 1; i < inferences; i++) {+ inference_request.set_output_tensor(output_tensor[i]);+ inference_request.set_input_tensor(output_tensor[i - 1]);++ inference_request.infer(); // Adds '1' to each element+ }++ float expected_result = 1.f;++ for (int i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ expected_result++;+ }++ inference_request = {};++ input_tensor = {};+ ::operator delete(input_data, std::align_val_t(4096));+ for (int i = 0; i < inferences; i++) {+ output_tensor[i] = {};+ if (i % 2 == 0) {+ ::operator delete(output_data[i], std::align_val_t(16));+ } else {+ ::operator delete(output_data[i], std::align_val_t(4096));+ }+ }+}++TEST_P(CpuVaTensorsTests, SetMultipleRemoteAllignedAndNotAllignedTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ auto context = core->get_default_context(target_device);+ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ ov::InferRequest inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ float* input_data;+ float* output_data[inferences];++ const auto input_byte_size = shape_size * sizeof(float);+ input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(16)));+ input_tensor = ov::Tensor{ov::element::f32, shape, input_data};++ inference_request = compiled_model.create_infer_request();+ for (int i = 0; i < inferences; i++) {+ auto tensor = inference_request.get_output_tensor(0);+ const auto byte_size = tensor.get_byte_size();++ if (i % 4 == 0) {+ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(16)));+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};+ } else if (i % 4 == 1) {+ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};+ } else if (i % 4 == 2) {+ output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);+ } else if (i % 4 == 3) {+ output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};+ }+ }++ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 0.f;+ }++ inference_request.set_input_tensor(input_tensor);+ inference_request.set_output_tensor(output_tensor[0]);++ inference_request.infer(); // Adds '1' to each element++ for (int i = 1; i < inferences; i++) {+ inference_request.set_output_tensor(output_tensor[i]);+ inference_request.set_input_tensor(output_tensor[i - 1]);++ inference_request.infer(); // Adds '1' to each element+ }++ float expected_result = 1.f;++ for (int i = 0; i < inferences; i++) {+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ expected_result++;+ }++ inference_request = {};++ input_tensor = {};+ ::operator delete(input_data, std::align_val_t(16));+ for (int i = 0; i < inferences; i++) {+ output_tensor[i] = {};+ if (i % 4 == 0) {+ ::operator delete(output_data[i], std::align_val_t(16));+ } else if (i % 4 == 1) {+ ::operator delete(output_data[i], std::align_val_t(4096));+ } else if (i % 4 == 3) {+ ::operator delete(output_data[i], std::align_val_t(4096));+ }+ }+}++TEST_P(CpuVaTensorsTests, SetAndDestroyDifferentAlignedTensors) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request0, inference_request1;++ const auto input_byte_size = shape_size * sizeof(float);+ auto input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));+ // Create two tensors for the same buffer to mimic weights/data sharing among multiple inference requests+ auto input_tensor0 = ov::Tensor{ov::element::f32, shape, input_data};+ auto input_tensor1 = ov::Tensor{ov::element::f32, shape, input_data};++ inference_request0 = compiled_model.create_infer_request();+ inference_request1 = compiled_model.create_infer_request();++ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 6.f;+ }++ inference_request0.set_input_tensor(input_tensor0);+ inference_request0.infer();+ inference_request0.set_input_tensor(input_tensor1);+ inference_request1.set_input_tensor(input_tensor1);+ inference_request0.infer();++ auto output_tensor0 = inference_request0.get_output_tensor();+ inference_request0 = {};++ inference_request1.infer();+ inference_request1.set_input_tensor(input_tensor0);+ inference_request1.infer();++ auto output_tensor1 = inference_request1.get_output_tensor();+ inference_request1 = {};++ float expected_result = 7.f;++ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor0.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ output_tensor_data = reinterpret_cast<float*>(output_tensor1.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ inference_request0 = {};+ inference_request1 = {};++ input_tensor0 = {};+ input_tensor1 = {};+ ::operator delete(input_data, std::align_val_t(4096));+}++TEST_P(CpuVaTensorsTests, checkResultsAfterStateTensorsUseImportCpuVa0) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ testing::internal::Random random(1);+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ float* state_data[3];+ ov::Tensor state_tensor[3];++ auto states = inference_request.query_state();++ auto get_tensor_state = states[0].get_state();+ auto tensor_state_shape = get_tensor_state.get_shape();+ auto l0_host_tensor = context.create_host_tensor(ov::element::f32, tensor_state_shape);+ states[0].set_state(l0_host_tensor);++ get_tensor_state = states[1].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ auto state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);+ state_data[0] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));+ state_tensor[0] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[0]};+ states[1].set_state(state_tensor[0]);++ for (auto&& state : states) {+ state.reset();+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ ASSERT_NEAR(0.5f, output_data[i], 1e-5);+ }++ states = inference_request.query_state();++ get_tensor_state = states[0].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);+ state_data[1] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));+ state_tensor[1] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[1]};+ states[0].set_state(state_tensor[1]);++ get_tensor_state = states[1].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);+ state_data[2] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(64)));+ state_tensor[2] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[2]};+ states[1].set_state(state_tensor[2]);++ for (size_t i = 0; i < states[0].get_state().get_size(); ++i) {+ state_data[1][i] = 1.0f;+ }+ for (size_t i = 0; i < states[1].get_state().get_size(); ++i) {+ state_data[2][i] = 1.0f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto get_state_data = static_cast<float*>(l0_host_tensor.data());+ for (size_t i = 0; i < get_tensor_state.get_size(); ++i) {+ ASSERT_NEAR(0.0, get_state_data[i], 1e-5);+ ASSERT_NEAR(0.0, state_data[0][i], 1e-5);++ ASSERT_NEAR(input_data[i], state_data[1][i], 1e-5);+ ASSERT_NEAR(input_data[i], state_data[2][i], 1e-5);+ }++ inference_request = {};++ state_tensor[0] = {};+ state_tensor[1] = {};+ state_tensor[2] = {};++ ::operator delete(state_data[0], std::align_val_t(4096));+ ::operator delete(state_data[1], std::align_val_t(4096));+ ::operator delete(state_data[2], std::align_val_t(64));+}++TEST_P(CpuVaTensorsTests, checkResultsAfterStateTensorsUseImportCpuVa1) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ testing::internal::Random random(1);+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device);++ ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ float* state_data[3];+ ov::Tensor state_tensor[3];++ auto states = inference_request.query_state();++ auto get_tensor_state = states[0].get_state();+ auto tensor_state_shape = get_tensor_state.get_shape();+ auto l0_host_tensor = context.create_host_tensor(ov::element::f32, tensor_state_shape);+ states[0].set_state(l0_host_tensor);++ get_tensor_state = states[1].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ auto state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);++ state_data[0] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));+ state_tensor[0] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[0]};+ states[1].set_state(state_tensor[0]);++ for (auto&& state : states) {+ state.reset();+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ ASSERT_NEAR(0.5f, output_data[i], 1e-5);+ }++ states = inference_request.query_state();++ get_tensor_state = states[0].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);+ state_data[1] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(64)));+ state_tensor[1] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[1]};+ states[0].set_state(state_tensor[1]);++ get_tensor_state = states[1].get_state();+ tensor_state_shape = get_tensor_state.get_shape();+ state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);+ state_data[2] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));+ state_tensor[2] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[2]};+ states[1].set_state(state_tensor[2]);++ for (size_t i = 0; i < states[0].get_state().get_size(); ++i) {+ state_data[1][i] = 1.0f;+ }+ for (size_t i = 0; i < states[1].get_state().get_size(); ++i) {+ state_data[2][i] = 1.0f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto get_state_data = static_cast<float*>(l0_host_tensor.data());+ for (size_t i = 0; i < get_tensor_state.get_size(); ++i) {+ ASSERT_NEAR(0.0, get_state_data[i], 1e-5);+ ASSERT_NEAR(0.0, state_data[0][i], 1e-5);++ ASSERT_NEAR(input_data[i], state_data[1][i], 1e-5);+ ASSERT_NEAR(input_data[i], state_data[2][i], 1e-5);+ }++ inference_request = {};++ state_tensor[0] = {};+ state_tensor[1] = {};+ state_tensor[2] = {};++ ::operator delete(state_data[0], std::align_val_t(4096));+ ::operator delete(state_data[1], std::align_val_t(64));+ ::operator delete(state_data[2], std::align_val_t(4096));+}++TEST_P(CpuVaTensorsTests, checkResultsAfterRawMemoryIsDestroyedAndReallocatedAfterEachRun) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";+ }++ ov::Core internal_core;+ ov::InferRequest inference_request;+ std::string logs;+ std::mutex logs_mutex;+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(ov::element::f32, shape, "N...");++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);+ internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));+ inference_request = compiled_model.create_infer_request();+ }+ logs.clear();++ for (size_t i = 0; i < 10; ++i) {+ float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));+ float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});+ inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});+ inference_request.infer();+ }++ ASSERT_NE(logs.find("deallocate the tensor data"), std::string::npos);++ logs.clear();++ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)+ << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }++ ::operator delete(input_data, std::align_val_t(4096));+ ::operator delete(output_data, std::align_val_t(4096));+ }+}++TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimes) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";+ }++ ov::Core internal_core;+ ov::InferRequest inference_request;+ std::string logs;+ std::mutex logs_mutex;+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(ov::element::f32, shape, "N...");++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));+ float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);+ internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));+ inference_request = compiled_model.create_infer_request();+ inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});+ inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});+ }+ logs.clear();++ for (size_t i = 0; i < 10; ++i) {+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ inference_request.infer();+ }++ if (i == 0) {+ ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);+ } else {+ ASSERT_NE(logs.find("import the tensor data"), std::string::npos);+ }+ ASSERT_NE(logs.find("deallocate the tensor data"), std::string::npos);++ logs.clear();++ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)+ << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }+ }++ ::operator delete(input_data, std::align_val_t(4096));+ ::operator delete(output_data, std::align_val_t(4096));+}++TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameZeroTensorMultipleTimes) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";+ }++ ov::Core internal_core;+ ov::InferRequest inference_request;+ float *input_data, *output_data;+ ov::Tensor input_tensor, output_tensor;+ std::string logs;+ std::mutex logs_mutex;+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(ov::element::f32, shape, "N...");++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);+ internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));+ inference_request = compiled_model.create_infer_request();+ input_tensor = inference_request.get_input_tensor();+ output_tensor = inference_request.get_output_tensor();+ input_data = input_tensor.data<float>();+ output_data = output_tensor.data<float>();+ }+ logs.clear();++ for (size_t i = 0; i < 10; ++i) {+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ inference_request.infer();+ }++ ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);+ ASSERT_EQ(logs.find("deallocate the tensor data"), std::string::npos);++ logs.clear();++ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)+ << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }+ }+}++TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameZeroHostTensorMultipleTimes) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";+ }++ ov::Core internal_core;+ auto context = internal_core.get_default_context(target_device);+ ov::InferRequest inference_request;+ std::string logs;+ std::mutex logs_mutex;+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(ov::element::f32, shape, "N...");++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ ov::Tensor input_tensor = context.create_host_tensor(ov::element::f32, shape);+ ov::Tensor output_tensor = context.create_host_tensor(ov::element::f32, shape);+ float* input_data = input_tensor.data<float>();+ float* output_data = output_tensor.data<float>();++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);+ internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));+ inference_request = compiled_model.create_infer_request();+ inference_request.set_input_tensor(input_tensor);+ inference_request.set_output_tensor(output_tensor);+ }+ logs.clear();++ for (size_t i = 0; i < 10; ++i) {+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ inference_request.infer();+ }++ ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);+ ASSERT_EQ(logs.find("deallocate the tensor data"), std::string::npos);++ logs.clear();++ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)+ << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }+ }+}++TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimesAllocatingRandomZeroMemoryInBetween) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";+ }++ ov::Core internal_core;+ auto context = internal_core.get_default_context(target_device);+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(ov::element::f32, shape, "N...");+ std::vector<ov::Tensor> input_tensor;++ float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));+ float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));++ ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);+ auto inference_request = compiled_model.create_infer_request();+ inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});+ inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});++ for (size_t i = 0; i < 5; ++i) {+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }++ input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));+ input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));+ input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));+ input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));++ OV_ASSERT_NO_THROW(inference_request.infer());++ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)+ << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]+ << " for index " << j;+ }+ }++ ::operator delete(input_data, std::align_val_t(4096));+ ::operator delete(output_data, std::align_val_t(4096));+}++class DynamicBoundsTests : public InferRequestRunTests {+public:+ void SetUp() override {+ InferRequestRunTests::SetUp();+ configuration.insert({ov::intel_npu::compilation_mode.name(), ov::Any("DefaultHW")});+ }+};++TEST_P(DynamicBoundsTests, ChangeShapeAfterTensorIsSet) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto model_shape = PartialShape{1, ov::Dimension(1, 10), 2, 2};+ auto model = createModel(element::f32, model_shape, "N...");++ auto compiled_model = core->compile_model(model, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ req = compiled_model.create_infer_request();++ auto shape = Shape{1, 4, 2, 2};+ auto shape_size = ov::shape_size(shape);+ auto input_tensor = ov::Tensor{ov::element::f32, shape};+ auto output_tensor = ov::Tensor{ov::element::f32, shape};++ ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(shape, input_tensor.get_shape());+ ASSERT_EQ(shape, output_tensor.get_shape());++ req.set_input_tensor(input_tensor);+ req.set_output_tensor(output_tensor);++ auto input_data = input_tensor.data<float>();+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 21.f;+ }++ req.infer(); // Adds '1' to each element++ auto expected = 22.f;+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ auto input_data_after_run = input_tensor.data<float>();+ auto output_data_after_run = output_tensor.data<float>();++ ASSERT_EQ(input_data, input_data_after_run);+ ASSERT_EQ(output_data, output_data_after_run);++ auto new_shape = Shape{1, 6, 2, 2};+ auto new_shape_size = ov::shape_size(new_shape);+ input_tensor.set_shape(new_shape);+ output_tensor.set_shape(new_shape);++ ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(new_shape, input_tensor.get_shape());+ ASSERT_EQ(new_shape, output_tensor.get_shape());++ input_data = input_tensor.data<float>();+ output_data = output_tensor.data<float>();++ for (size_t i = 0; i < new_shape_size; ++i) {+ input_data[i] = 25.f;+ }++ req.infer(); // Adds '1' to each element++ expected = 26.f;+ for (size_t i = 0; i < new_shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(new_shape, input_tensor.get_shape());+ ASSERT_EQ(new_shape, output_tensor.get_shape());++ input_data_after_run = input_tensor.data<float>();+ output_data_after_run = output_tensor.data<float>();++ ASSERT_EQ(input_data, input_data_after_run);+ ASSERT_EQ(output_data, output_data_after_run);+}++TEST_P(DynamicBoundsTests, ChangeShapeAfterTensorIsSetUsingAlignedExternalMemory) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};+ auto model = createModel(element::f32, model_shape, "N...");++ auto compiled_model = core->compile_model(model, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ req = compiled_model.create_infer_request();++ ov::Allocator allocator{ov::test::utils::DefaultAllocatorAligned{}};++ auto shape = Shape{1, 8, 4, 64};+ auto shape_size = ov::shape_size(shape);+ auto input_tensor = ov::Tensor{ov::element::f32, shape, allocator};+ auto output_tensor = ov::Tensor{ov::element::f32, shape, allocator};++ ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(shape, input_tensor.get_shape());+ ASSERT_EQ(shape, output_tensor.get_shape());++ req.set_input_tensor(input_tensor);+ req.set_output_tensor(output_tensor);++ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 21.f;+ }++ req.infer(); // Adds '1' to each element++ auto expected = 22.f;+ auto* output_data = output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ auto new_shape = Shape{1, 6, 4, 64};+ auto new_shape_size = ov::shape_size(new_shape);+ input_tensor.set_shape(new_shape);+ output_tensor.set_shape(new_shape);++ ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(new_shape, input_tensor.get_shape());+ ASSERT_EQ(new_shape, output_tensor.get_shape());++ input_data = input_tensor.data<float>();+ output_data = output_tensor.data<float>();++ for (size_t i = 0; i < new_shape_size; ++i) {+ input_data[i] = 25.f;+ }++ req.infer(); // Adds '1' to each element++ expected = 26.f;+ for (size_t i = 0; i < new_shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(new_shape, input_tensor.get_shape());+ ASSERT_EQ(new_shape, output_tensor.get_shape());+}++TEST_P(DynamicBoundsTests, RunningTwiceWithRemoteTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};+ auto model = createModel(element::f32, model_shape, "N...");++ auto compiled_model = core->compile_model(model, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ req = compiled_model.create_infer_request();++ auto context = core->get_default_context(target_device);++ auto shape = Shape{1, 8, 4, 64};+ auto shape_size = ov::shape_size(shape);+ auto input_tensor = context.create_host_tensor(ov::element::f32, shape);+ auto output_tensor = context.create_host_tensor(ov::element::f32, shape);++ ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(shape, input_tensor.get_shape());+ ASSERT_EQ(shape, output_tensor.get_shape());++ req.set_input_tensor(input_tensor);+ req.set_output_tensor(output_tensor);++ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 21.f;+ }++ req.infer(); // Adds '1' to each element++ auto expected = 22.f;+ auto* output_data = output_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = 25.f;+ }++ req.infer(); // Adds '1' to each element++ expected = 26.f;+ for (size_t i = 0; i < shape_size; ++i) {+ ASSERT_EQ(output_data[i], expected)+ << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;+ }++ ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());+ ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());+ ASSERT_EQ(shape, input_tensor.get_shape());+ ASSERT_EQ(shape, output_tensor.get_shape());+}++TEST_P(DynamicBoundsTests, ExpectErrorFromWrongTensorShape) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};+ auto model = createModel(element::f32, model_shape, "N...");++ auto compiled_model = core->compile_model(model, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ req = compiled_model.create_infer_request();++ auto context = core->get_default_context(target_device);+ auto input_tensor = context.create_host_tensor(ov::element::f32, Shape{1, 8, 2, 64});+ OV_EXPECT_THROW(req.set_input_tensor(input_tensor),+ ov::Exception,+ HasSubstr("The tensor shape is not compatible with the model input/output shape"));++ auto output_tensor = context.create_host_tensor(ov::element::f32, Shape{1, 8, 12, 64});+ OV_EXPECT_THROW(req.set_output_tensor(output_tensor),+ ov::Exception,+ HasSubstr("The tensor shape is not compatible with the model input/output shape"));+}++using NumStreamsTests = InferRequestRunTests;++TEST_P(NumStreamsTests, RunWithDifferentNumStreamsCheckResults) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ auto shape = Shape{1, 2, 64, 64};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ auto compiled_model = core->compile_model(model, target_device, configuration);+ const uint32_t inferences = 32;+ std::array<ov::InferRequest, inferences> inference_request;++ for (uint32_t i = 0; i < inferences; i++) {+ inference_request[i] = compiled_model.create_infer_request();++ auto input_tensor = inference_request[i].get_input_tensor();+ auto* input_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t j = 0; j < shape_size; ++j) {+ input_data[j] = static_cast<float>(i);+ }+ }++ for (uint32_t i = 0; i < inferences; i++) {+ OV_ASSERT_NO_THROW(inference_request[i].infer());+ }++ for (uint32_t i = 0; i < inferences; i++) {+ OV_ASSERT_NO_THROW(inference_request[i].start_async());+ }++ for (uint32_t i = 0; i < inferences; i++) {+ OV_ASSERT_NO_THROW(inference_request[i].wait());+ }++ for (uint32_t i = 0; i < inferences; i++) {+ float expected_result = static_cast<float>(i) + 1.f;+ auto output_tensor = inference_request[i].get_output_tensor();+ auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());+ for (size_t j = 0; j < shape_size; ++j) {+ ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Inference=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ }+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hppdeleted file mode 100644index d11bfd805c3..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/infer_request_run.hpp+++ /dev/null@@ -1,2865 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <thread>--#include "behavior/ov_infer_request/inference.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common/zero_init_mock.hpp"-#include "common_test_utils/ov_tensor_utils.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_types.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/log.hpp"-#include "openvino/core/node_vector.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class InferRequestRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;- ov::Output<const ov::Node> input;- ov::Output<const ov::Node> output;- std::string m_cache_dir;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration) = this->GetParam();- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555- }-- std::string generateCacheDirName(const std::string& test_name) {- using namespace std::chrono;- // Generate unique file names based on test name, thread id and timestamp- // This allows execution of tests in parallel (stress mode)- auto hash = std::to_string(std::hash<std::string>()(test_name));- std::stringstream ss;- auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());- ss << hash << "_" << "_" << ts.count();- return ss.str();- }-- void TearDown() override {- if (!m_cache_dir.empty()) {- core->set_property({ov::cache_dir()});- core.reset();- ov::test::utils::PluginCache::get().reset();- ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");- ov::test::utils::removeDir(m_cache_dir);- }-- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-- std::shared_ptr<ov::Model> createModel(element::Type type, const PartialShape& shape, const ov::Layout& layout) {- ResultVector res;- ParameterVector params;-- auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);- data1->set_friendly_name("input");- data1->get_output_tensor(0).set_names({"tensor_input"});- data1->set_layout(layout);- auto constant = opset8::Constant::create(type, {1}, {1});- auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);- op1->set_friendly_name("Add");- auto res1 = std::make_shared<ov::op::v0::Result>(op1);- res1->set_friendly_name("Result");- res1->get_output_tensor(0).set_names({"tensor_output"});- params.push_back(data1);- res.push_back(res1);-- return std::make_shared<Model>(res, params);- }-};--using BooleanPrecisionCompilationParams = std::tuple<std::string, // Device name- ov::AnyMap, // Config- bool, // With warmup infer()- bool>; // With reset Infer Request--class BooleanPrecisionInferRequestRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<BooleanPrecisionCompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;- bool withWarmUpInfer = false;- bool withResetInferRequest = false;-- std::shared_ptr<ov::Model> createTwoInputLessEqualModel(const PartialShape& shape = {2, 16, 16, 16}) {- auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);- param0->get_output_tensor(0).set_names({"tensor_input_0"});- param0->set_layout("N...");- auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);- param1->get_output_tensor(0).set_names({"tensor_input_1"});- param1->set_layout("N...");- auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);- auto result = std::make_shared<ov::op::v0::Result>(lessEqual);- result->get_output_tensor(0).set_names({"tensor_output"});-- auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});- model->set_friendly_name("TwoInputLessEqual");- return model;- }-- std::shared_ptr<ov::Model> createTwoInputNonZeroAddModel(const PartialShape& shape = {2, 16, 16, 16}) {- auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);- param0->get_output_tensor(0).set_names({"tensor_input_0"});- param0->set_layout("N...");- auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, shape);- param1->get_output_tensor(0).set_names({"tensor_input_1"});- param1->set_layout("N...");- auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);- auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);- // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input- // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf- auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);- auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);- auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);- auto result = std::make_shared<ov::op::v0::Result>(add);- result->get_output_tensor(0).set_names({"tensor_output"});-- auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});- model->set_friendly_name("TwoTwoInputNonZeroAddModel");- return model;- }--public:- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration, withWarmUpInfer, withResetInferRequest) = this->GetParam();- OVPluginTestBase::SetUp();- ov_model = createTwoInputNonZeroAddModel();- }-};--TEST_P(InferRequestRunTests, AllocatorCanDisposeBlobWhenOnlyInferRequestIsInScope) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- ov::InferRequest req;- ov::Tensor outputTensor;- {- core.reset();- ov::test::utils::PluginCache::get().reset();- }- }-}--TEST_P(InferRequestRunTests, MultipleExecutorStreamsTestsSyncInfers) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- ov::CompiledModel compiled_model;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(input = compiled_model.input());- OV_ASSERT_NO_THROW(output = compiled_model.output());-- const int inferReqNumber = 256;- std::array<ov::InferRequest, inferReqNumber> inferReqs;- std::array<std::thread, inferReqNumber> inferReqsThreads;- for (int i = 0; i < inferReqNumber; ++i) {- OV_ASSERT_NO_THROW(inferReqs[i] = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(input));- }-- for (int i = 0; i < inferReqNumber; ++i) {- ov::InferRequest& infReq = inferReqs[i];- inferReqsThreads[i] = std::thread([&infReq]() -> void {- OV_ASSERT_NO_THROW(infReq.infer());- });- }-- for (int i = 0; i < inferReqNumber; ++i) {- inferReqsThreads[i].join();- OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(output));- }-}--TEST_P(InferRequestRunTests, MultipleExecutorStreamsTestsAsyncInfers) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- ov::CompiledModel compiled_model;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(input = compiled_model.input());- OV_ASSERT_NO_THROW(output = compiled_model.output());-- const int inferReqNumber = 256;- std::array<ov::InferRequest, inferReqNumber> inferReqs;- for (int i = 0; i < inferReqNumber; ++i) {- OV_ASSERT_NO_THROW(inferReqs[i] = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(input));- }-- for (int i = 0; i < inferReqNumber; ++i) {- OV_ASSERT_NO_THROW(inferReqs[i].start_async());- }-- for (int i = 0; i < inferReqNumber; ++i) {- inferReqs[i].wait();- OV_ASSERT_NO_THROW(inferReqs[i].get_tensor(output));- }-}--TEST_P(BooleanPrecisionInferRequestRunTests, BooleanTensorDataTypesForBooleanModelsWork) {- // TODO: Also test createTwoInputLessEqualModel model when we have compiler support- SKIP_IF_CURRENT_TEST_IS_DISABLED();- ov::CompiledModel compiled_model_boolean, compiled_model_boolean_imported;- std::shared_ptr<ov::InferRequest> infer_request_boolean, infer_request_boolean_imported;-- try {- (void)core->get_property(target_device, ov::intel_npu::batch_mode);- } catch (...) {- configuration.erase(ov::intel_npu::batch_mode.name());- }-- bool isPVDriver = (core->get_property(target_device, ov::intel_npu::driver_version) == 1688);-- bool isDriverCompiler =- (configuration.find(ov::intel_npu::compiler_type.name()) != configuration.end() &&- configuration.find(ov::intel_npu::compiler_type.name())->second.as<ov::intel_npu::CompilerType>() ==- ov::intel_npu::CompilerType::DRIVER);- if (isPVDriver && isDriverCompiler) {- GTEST_SKIP() << "CID from PV driver cannot compile models with boolean inputs!";- }-- OV_ASSERT_NO_THROW(compiled_model_boolean = core->compile_model(ov_model, target_device, configuration));- OPENVINO_ASSERT(compiled_model_boolean.input(0).get_element_type() == ov::element::boolean);- OPENVINO_ASSERT(compiled_model_boolean.input(1).get_element_type() == ov::element::boolean);-- if (!isPVDriver) {- std::stringstream ss;- compiled_model_boolean.export_model(ss);- OV_ASSERT_NO_THROW(compiled_model_boolean_imported = core->import_model(ss, target_device, configuration));- infer_request_boolean_imported =- std::make_shared<ov::InferRequest>(compiled_model_boolean_imported.create_infer_request());- }- infer_request_boolean = std::make_shared<ov::InferRequest>(compiled_model_boolean.create_infer_request());-- const auto infer_requests =- (isPVDriver- ? std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean}- : std::vector<std::shared_ptr<ov::InferRequest>>{infer_request_boolean, infer_request_boolean_imported});-- auto [importMemoryBatchedTensor,- importMemoryTensor_1,- importMemoryTensor_2,- unalignedBatchedTensor,- unalignedTensor_1,- unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);-- ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());- ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());- importMemoryBatchedTensor.copy_to(ref_import_tensor);- unalignedBatchedTensor.copy_to(ref_tensor_unaligned);-- for (auto infer_request : infer_requests) {- auto reset_infer_request_cb = [&infer_request]() {- auto compiled_model = infer_request->get_compiled_model();- infer_request = std::make_shared<ov::InferRequest>(compiled_model.create_infer_request());- };-- if (withWarmUpInfer) {- infer_request->infer();- }-- const auto& compiled_model = infer_request->get_compiled_model();-- OV_ASSERT_NO_THROW(- ov::test::utils::set_tensors_and_infer(infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiled_model.input(0),- std::vector<ov::Tensor>{importMemoryTensor_1, unalignedTensor_2},- reset_infer_request_cb));- OV_ASSERT_NO_THROW(- ov::test::utils::set_tensors_and_infer(infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiled_model.input(1),- std::vector<ov::Tensor>{importMemoryTensor_2, unalignedTensor_1},- reset_infer_request_cb));-- OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiled_model.input(0),- importMemoryBatchedTensor,- reset_infer_request_cb));- OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiled_model.input(1),- unalignedBatchedTensor,- reset_infer_request_cb));-- OV_ASSERT_NO_THROW(- ov::test::utils::set_tensors_and_infer(infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiled_model.input(0),- std::vector<ov::Tensor>{unalignedTensor_1, importMemoryTensor_1},- reset_infer_request_cb));- OV_ASSERT_NO_THROW(- ov::test::utils::set_tensors_and_infer(infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiled_model.input(1),- std::vector<ov::Tensor>{unalignedTensor_2, importMemoryTensor_2},- reset_infer_request_cb));- } // for infer_request-- // ensure user tensors don't get altered during tests- OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));- OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));-}--using ProfilingBlob = InferRequestRunTests;--TEST_P(ProfilingBlob, NoProfilingCompileProfilingImport) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {- GTEST_SKIP() << "Skip since driver extension version is lower than expected";- }- ov::CompiledModel compiled_model;-- configuration[ov::enable_profiling.name()] = false;- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration[ov::enable_profiling.name()] = true;- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));-- ov::InferRequest inferReq;-- OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());-- if (configuration.find(ov::intel_npu::profiling_type.name())->second == ov::intel_npu::ProfilingType::MODEL) {- ASSERT_ANY_THROW(inferReq.infer());- } else {- OV_ASSERT_NO_THROW(inferReq.infer());- }-}--TEST_P(ProfilingBlob, ProfilingCompileNoProfilingImport) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {- GTEST_SKIP() << "Skip since driver extension version is lower than expected";- }- ov::CompiledModel compiled_model;-- configuration[ov::enable_profiling.name()] = true;- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration[ov::enable_profiling.name()] = false;- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));-- ov::InferRequest inferReq;-- OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());-- OV_ASSERT_NO_THROW(inferReq.infer());-}--TEST_P(ProfilingBlob, ProfilingCompileProfilingImport) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> initStructs = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (initStructs->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {- GTEST_SKIP() << "Skip since driver extension version is lower than expected";- }- ov::CompiledModel compiled_model;-- configuration[ov::enable_profiling.name()] = true;- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));-- ov::InferRequest inferReq;-- OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());-- OV_ASSERT_NO_THROW(inferReq.infer());-}--TEST_P(InferRequestRunTests, MultipleExecutorTestsSyncInfers) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- ov::CompiledModel compiled_model;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(input = compiled_model.input());- OV_ASSERT_NO_THROW(output = compiled_model.output());-- const int inferReqNumber = 256;- ov::InferRequest inferReq;- ov::Tensor input_tensor;- for (int i = 0; i < inferReqNumber; ++i) {- OV_ASSERT_NO_THROW(inferReq = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(input_tensor = inferReq.get_tensor(input));- OV_ASSERT_NO_THROW(inferReq.set_input_tensor(input_tensor));- OV_ASSERT_NO_THROW(inferReq.infer());- OV_ASSERT_NO_THROW(inferReq.get_tensor(output));- }-}--TEST_P(InferRequestRunTests, CheckOutputDataFromTwoRuns) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;- float* data;-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- const size_t byte_size = tensor.get_byte_size();- data = new float[byte_size / sizeof(float)];- memset(data, 1, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- }- first_output = inference_request.get_output_tensor(0);-- for (int i = 0; i < 10; i++) {- delete[] data;- compiled_model = {};- inference_request = {};-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- const size_t byte_size = tensor.get_byte_size();- data = new float[byte_size / sizeof(float)];- memset(data, 1, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- }- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);- }-}--TEST_P(InferRequestRunTests, CheckOutputDataFromMultipleRunsUsingSameL0Tensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;- ov::Tensor global_input;-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- global_input = inference_request.get_input_tensor();- const size_t byte_size = global_input.get_byte_size();- memset(global_input.data(), 1, byte_size);- OV_ASSERT_NO_THROW(inference_request.infer());- }- first_output = inference_request.get_output_tensor(0);-- for (int i = 0; i < 10; i++) {- compiled_model = {};- inference_request = {};-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));- OV_ASSERT_NO_THROW(inference_request.infer());- }- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);- }-}--TEST_P(InferRequestRunTests, RecreateL0TensorIfNeeded) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;- ov::Tensor global_input;- float* data;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- global_input = inference_request.get_input_tensor();- memset(global_input.data(), 1, global_input.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor(0);-- compiled_model = {};- inference_request = {};-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);-- for (int i = 0; i < 10; i++) {- {- const size_t byte_size = global_input.get_byte_size();- data = new float[byte_size / sizeof(float)];- memset(data, 1, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, global_input.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- }- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);-- delete[] data;- }-}--TEST_P(InferRequestRunTests, RunWithConstData) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- const auto tensor = inference_request.get_input_tensor();- const std::vector<float> data(tensor.get_byte_size() / sizeof(float));- OV_ASSERT_NO_THROW(inference_request.set_input_tensor({ov::element::f32, tensor.get_shape(), data.data()}));- OV_ASSERT_NO_THROW(inference_request.infer());-}--using RandomTensorOverZeroTensorRunTests = InferRequestRunTests;--TEST_P(RandomTensorOverZeroTensorRunTests, SetRandomTensorOverZeroTensor0) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;-- auto shape = Shape{1, 2, 2, 2};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input_zero_tensor = inference_request.get_input_tensor(0);- auto* input_zero_data = input_zero_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_zero_data[i] = 5.f;- }-- inference_request.infer(); // Adds '1' to each element-- auto output_tensor = inference_request.get_output_tensor(0);- auto* output_data = output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data[i] << " for index " << i;- }-- float* buffer = new float[shape_size];- ov::Tensor tensor{element::f32, shape, buffer};- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 9.f;- }-- inference_request.set_input_tensor(tensor);- inference_request.infer(); // Adds '1' to each element- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data[i], 10.f, 1e-5) << "Expected=10, actual=" << output_data[i] << " for index " << i;- }-- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(input_zero_data[i], 5.f, 1e-5) << "Expected=5, actual=" << input_zero_data[i] << " for index " << i;- }-- delete[] buffer;-}--TEST_P(RandomTensorOverZeroTensorRunTests, SetRandomTensorOverZeroTensor1) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;-- auto shape = Shape{1, 2, 2, 2};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request0, inference_request1;- inference_request0 = compiled_model.create_infer_request();- inference_request1 = compiled_model.create_infer_request();-- auto input_zero_tensor = inference_request0.get_input_tensor(0);- auto* input_zero_data = input_zero_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_zero_data[i] = 5.f;- }-- inference_request0.infer(); // Adds '1' to each element-- auto output_tensor0 = inference_request0.get_output_tensor(0);- auto* output_data0 = output_tensor0.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data0[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data0[i] << " for index " << i;- }-- inference_request1.set_input_tensor(output_tensor0);- inference_request1.infer(); // Adds '1' to each element-- auto output_tensor1 = inference_request1.get_output_tensor(0);- auto* output_data1 = output_tensor1.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data1[i], 7.f, 1e-5) << "Expected=7, actual=" << output_data1[i] << " for index " << i;- }-- float* buffer = new float[shape_size];- ov::Tensor tensor{element::f32, shape, buffer};- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 9.f;- }-- inference_request1.set_input_tensor(tensor);- inference_request1.infer(); // Adds '1' to each element-- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data1[i], 10.f, 1e-5) << "Expected=10, actual=" << output_data1[i] << " for index " << i;- }-- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(output_data0[i], 6.f, 1e-5) << "Expected=6, actual=" << output_data0[i] << " for index " << i;- }-- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(input_zero_data[i], 5.f, 1e-5) << "Expected=5, actual=" << input_zero_data[i] << " for index " << i;- }-- delete[] buffer;-}--using BatchingRunTests = InferRequestRunTests;--TEST_P(BatchingRunTests, CheckBatchingSupportInfer) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;-- ov::InferRequest inference_request;- auto batch_shape = Shape{4, 2, 32, 32};- std::shared_ptr<ov::Model> ov_model_batch = createModel(element::f32, batch_shape, "N...");-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model_batch, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(BatchingRunTests, CheckBatchingSupportAsync) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- auto batch_shape = Shape{4, 2, 32, 32};- std::shared_ptr<ov::Model> ov_model_batch = createModel(element::f32, batch_shape, "N...");-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model_batch, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.start_async());- inference_request.wait();-}--TEST_P(BatchingRunTests, UseCompilerBatchingErrorPluginBatching) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::CompiledModel compiled_model;-- ov::InferRequest inference_request;- std::shared_ptr<ov::Model> ov_model_batch = getDefaultNGraphFunctionForTheDeviceNPU({4, 2, 32, 32});-- auto batch_mode = configuration[ov::intel_npu::batch_mode.name()].as<std::string>();- try {- compiled_model = core->compile_model(ov_model_batch, target_device, configuration);- inference_request = compiled_model.create_infer_request();- inference_request.start_async();- inference_request.wait();- } catch (std::exception& ex) {- if (batch_mode != "PLUGIN") {- ASSERT_FALSE(true) << ex.what();- }- }-}--TEST_P(BatchingRunTests, SetInputTensorInfer) {- auto batch_shape = Shape{4, 2, 2, 2};- auto shape_size = ov::shape_size(batch_shape);- auto model = createModel(element::f32, batch_shape, "N...");- float* buffer = new float[shape_size];-- ov::CompiledModel compiled_model;-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- ov::Tensor tensor{element::f32, batch_shape, buffer};-- inference_request.set_input_tensor(tensor);- auto actual_tensor = inference_request.get_output_tensor(0);- auto* actual = actual_tensor.data<float>();- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }-- inference_request.infer(); // Adds '1' to each element- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-}--TEST_P(BatchingRunTests, SetInputTensorAsync) {- auto batch_shape = Shape{4, 2, 2, 2};- auto shape_size = ov::shape_size(batch_shape);- auto model = createModel(element::f32, batch_shape, "N...");- float* buffer = new float[shape_size];-- ov::CompiledModel compiled_model;-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- ov::Tensor tensor{element::f32, batch_shape, buffer};-- inference_request.set_input_tensor(tensor);- auto actual_tensor = inference_request.get_output_tensor(0);- auto* actual = actual_tensor.data<float>();- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }-- inference_request.start_async(); // Adds '1' to each element- inference_request.wait_for(std::chrono::milliseconds(1000));- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-}--TEST_P(BatchingRunTests, SetInputTensorInfer_Caching) {- auto batch_shape = Shape{4, 2, 2, 2};- auto shape_size = ov::shape_size(batch_shape);- auto model = createModel(element::f32, batch_shape, "N...");- float* buffer = new float[shape_size];-- ov::CompiledModel compiled_model;-- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});- auto compiled_model_no_cache = core->compile_model(model, target_device, configuration);- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- ov::Tensor tensor{element::f32, batch_shape, buffer};-- inference_request.set_input_tensor(tensor);- auto actual_tensor = inference_request.get_output_tensor(0);- auto* actual = actual_tensor.data<float>();- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }-- inference_request.infer(); // Adds '1' to each element- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-- delete[] buffer;-}--TEST_P(BatchingRunTests, CheckTwoRunsInfer) {- auto batch_shape = Shape{4, 2, 2, 2};- auto shape_size = ov::shape_size(batch_shape);- auto model = createModel(element::f32, batch_shape, "N...");- float* buffer = new float[shape_size];-- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device);-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- ov::Tensor tensor{element::f32, batch_shape, buffer};-- inference_request.set_input_tensor(tensor);- auto actual_tensor = inference_request.get_output_tensor(0);- auto* actual = actual_tensor.data<float>();- auto* input_data = tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }- inference_request.infer(); // Adds '1' to each element- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-- auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, batch_shape);- auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, actual_tensor.get_shape());-- auto* input_data_host_tensor = l0_host_input_tensor.data();- input_data = reinterpret_cast<float*>(input_data_host_tensor);- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }- inference_request.set_input_tensor(l0_host_input_tensor);- inference_request.set_output_tensor(l0_host_output_tensor);- inference_request.infer();-- auto* actual_host_tensor = l0_host_output_tensor.data();- actual = reinterpret_cast<float*>(actual_host_tensor);- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-- delete[] buffer;-}--using RunSeqTests = InferRequestRunTests;--TEST_P(RunSeqTests, CheckMultipleRunsSeq0) {- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device);-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const uint32_t inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);- for (uint32_t i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- inference_request[0].set_input_tensor(input_tensor);- inference_request[0].set_output_tensor(output_tensor[0]);-- const uint32_t runs = 10;- for (uint32_t z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request[0].start_async(); // Adds '1' to each element-- for (uint32_t i = 1; i < inferences; i++) {- inference_request[i].set_input_tensor(output_tensor[i - 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[inferences - 1].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (uint32_t i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }-}--TEST_P(RunSeqTests, CheckMultipleRunsSeq1) {- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device);-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);-- for (int i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- inference_request[inferences - 1].set_input_tensor(input_tensor);- inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);-- const int runs = 10;- for (int z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request[inferences - 1].start_async(); // Adds '1' to each element-- for (int i = inferences - 2; i >= 0; i--) {- inference_request[i].set_input_tensor(output_tensor[i + 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[0].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (int i = inferences - 1; i >= 0; i--) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }-}--TEST_P(RunSeqTests, CheckMultipleRunsSeq2) {- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device);-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);-- for (int i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- inference_request[inferences - 1].set_input_tensor(input_tensor);- inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);-- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 1.f;- }-- inference_request[inferences - 1].start_async();-- for (int i = inferences - 2; i >= 0; i--) {- inference_request[i].set_input_tensor(output_tensor[i + 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async();- }-- inference_request[0].wait();-- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();-- bool isRunInferencesSequentially =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == intel_npu::run_inferences_sequentially.name();- });-- if (::intel_npu::ZeroInitStructsHolder::getInstance()->getCommandQueueDdiTable().version() >=- ZE_MAKE_VERSION(1, 1)) {- ASSERT_TRUE(isRunInferencesSequentially);-- inference_request[5].start_async();- inference_request[5].wait();- } else {- ASSERT_TRUE(!isRunInferencesSequentially);- try {- inference_request[5].start_async();- inference_request[5].wait();- } catch (const std::exception& ex) {- ASSERT_FALSE(false) << ex.what();- return;- }-- ASSERT_FALSE(true) << "Exception is expected but it didn't throw any exception!";- }-}--TEST_P(RunSeqTests, CheckMultipleRunsSeq3) {- auto shape = Shape{1, 64, 64, 256};- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- OV_EXPECT_THROW(inference_request.infer(),- ov::Exception,- HasSubstr("Only start async is supported when RUN_INFERENCES_SEQUENTIALLY is enabled!"));-}--TEST_P(RunSeqTests, CheckMultipleRunsSeq4) {- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();-- ov::CompiledModel compiled_model;-- bool isRunInferencesSequentially =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const PropertyName& property) {- return property == intel_npu::run_inferences_sequentially.name();- });-- if (isRunInferencesSequentially) {- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- auto context = core->get_default_context(target_device);-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);-- for (int i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- const int runs = 10;- for (int z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- if (runs % 2) {- inference_request[inferences - 1].set_input_tensor(input_tensor);- inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);-- inference_request[inferences - 1].start_async(); // Adds '1' to each element-- for (int i = inferences - 2; i >= 0; i--) {- inference_request[i].set_input_tensor(output_tensor[i + 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[0].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (int i = inferences - 1; i >= 0; i--) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- } else {- inference_request[0].set_input_tensor(input_tensor);- inference_request[0].set_output_tensor(output_tensor[0]);-- inference_request[0].start_async(); // Adds '1' to each element-- for (uint32_t i = 1; i < inferences; i++) {- inference_request[i].set_input_tensor(output_tensor[i - 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[inferences - 1].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (uint32_t i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }- }- }-}--TEST_P(RunSeqTests, CheckTurboWithMultipleRunsSeq) {- auto supportedProperties = core->get_property("NPU", supported_properties.name()).as<std::vector<PropertyName>>();-- auto shape = Shape{1, 64, 64, 256};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model;-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[intel_npu::turbo.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);-- for (int i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- const int runs = 10;- for (int z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request[inferences - 1].set_input_tensor(input_tensor);- inference_request[inferences - 1].set_output_tensor(output_tensor[inferences - 1]);-- inference_request[inferences - 1].start_async(); // Adds '1' to each element-- for (int i = inferences - 2; i >= 0; i--) {- inference_request[i].set_input_tensor(output_tensor[i + 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[0].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (int i = inferences - 1; i >= 0; i--) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }-}--using BatchingRunSeqTests = InferRequestRunTests;--TEST_P(BatchingRunSeqTests, CheckMultipleBatchingRunsSeq) {- auto shape = Shape{4, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model;-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- compiled_model = core->compile_model(model, target_device, configuration);-- const uint32_t inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);- for (uint32_t i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- inference_request[0].set_input_tensor(input_tensor);- inference_request[0].set_output_tensor(output_tensor[0]);-- const uint32_t runs = 10;- for (uint32_t z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request[0].start_async(); // Adds '1' to each element-- for (uint32_t i = 1; i < inferences; i++) {- inference_request[i].set_input_tensor(output_tensor[i - 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[inferences - 1].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (uint32_t i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }-}--using DynamicBatchingTests = InferRequestRunTests;--TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun0) {- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 64, 64};- size_t batch_size = 1;- auto shape = Shape{batch_size, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, modelShape, "N...");-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- ov::InferRequest inference_request;- ov::Tensor input_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);-- inference_request = compiled_model.create_infer_request();-- inference_request.set_input_tensor(input_tensor);-- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(batch_size);- }-- inference_request.infer(); // Adds '1' to each element-- auto output_tensor = inference_request.get_output_tensor();-- float expected_result = static_cast<float>(batch_size) + 1.f;- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }-- for (auto z = batch_size + 1; z <= 10; z++) {- auto host_shape = Shape{z, 2, 64, 64};- auto input_host_tensor = context.create_host_tensor(ov::element::f32, host_shape);-- inference_request.set_input_tensor(input_host_tensor);-- auto* input_data = reinterpret_cast<float*>(input_host_tensor.data());- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request.infer(); // Adds '1' to each element-- auto output_test_tensor = inference_request.get_output_tensor();-- float expected_result = static_cast<float>(z) + 1.f;- auto* output_tensor_data = reinterpret_cast<float*>(output_test_tensor.data());-- EXPECT_EQ(output_test_tensor.get_size(), input_host_tensor.get_size());-- for (size_t j = 0; j < output_test_tensor.get_size(); ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- }-}--TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun1) {- auto modelShape = PartialShape{-1, 2, 64, 64};- size_t batch_size = 1;- auto shape = Shape{batch_size, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, modelShape, "N...");-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- ov::InferRequest inference_request;- ov::Tensor input_tensor;-- input_tensor = ov::Tensor(ov::element::f32, shape);-- inference_request = compiled_model.create_infer_request();-- inference_request.set_input_tensor(input_tensor);-- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(batch_size);- }-- inference_request.infer(); // Adds '1' to each element-- auto output_tensor = inference_request.get_output_tensor();-- float expected_result = static_cast<float>(batch_size) + 1.f;- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }-- for (auto z = batch_size + 1; z <= 10; z++) {- auto host_shape = Shape{z, 2, 64, 64};- auto input_host_tensor = ov::Tensor(ov::element::f32, host_shape);-- inference_request.set_input_tensor(input_host_tensor);-- auto* input_data = reinterpret_cast<float*>(input_host_tensor.data());- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request.infer(); // Adds '1' to each element-- auto output_test_tensor = inference_request.get_output_tensor();-- float expected_result = static_cast<float>(z) + 1.f;- auto* output_tensor_data = reinterpret_cast<float*>(output_test_tensor.data());-- EXPECT_EQ(output_test_tensor.get_size(), input_host_tensor.get_size());-- for (size_t j = 0; j < output_test_tensor.get_size(); ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- }-}--TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRun2) {- auto modelShape = PartialShape{-1, 2, 64, 64};- size_t batch_size = 3;- auto shape = Shape{batch_size, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, modelShape, "N...");-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- ov::InferRequest inference_request;- ov::Tensor input_tensor;-- input_tensor = ov::Tensor(ov::element::f32, shape);-- inference_request = compiled_model.create_infer_request();-- inference_request.set_input_tensor(input_tensor);-- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(batch_size);- }-- inference_request.infer(); // Adds '1' to each element-- auto output_tensor = inference_request.get_output_tensor();-- float expected_result = static_cast<float>(batch_size) + 1.f;- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << batch_size << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }-}--TEST_P(DynamicBatchingTests, DynamicCheckMultipleBatchingRunsSeq) {- auto modelShape = PartialShape{ov::Dimension(1, 10), 2, 64, 64};- auto shape = Shape{4, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, modelShape, "N...");-- auto context = core->get_default_context(target_device);-- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;- configuration[ov::intel_npu::tiles.name()] = 2;- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- const uint32_t inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = context.create_host_tensor(ov::element::f32, shape);- for (uint32_t i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- }-- inference_request[0].set_input_tensor(input_tensor);- inference_request[0].set_output_tensor(output_tensor[0]);-- const uint32_t runs = 10;- for (uint32_t z = 0; z < runs; z++) {- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(z);- }-- inference_request[0].start_async(); // Adds '1' to each element-- for (uint32_t i = 1; i < inferences; i++) {- inference_request[i].set_input_tensor(output_tensor[i - 1]);- inference_request[i].set_output_tensor(output_tensor[i]);-- inference_request[i].start_async(); // Adds '1' to each element- }-- inference_request[inferences - 1].wait();-- float expected_result = static_cast<float>(z) + 1.f;-- for (uint32_t i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Run=" << z << "Output=" << i << " Expected=" << expected_result- << ", actual=" << output_tensor_data[j] << " for index " << j;- }- expected_result++;- }- }-}--using ROITensorInference = OVInferRequestInferenceTests;--TEST_P(ROITensorInference, InferenceROITensor) {- auto model = OVInferRequestInferenceTests::create_n_inputs(1, ov::element::f32, m_param.m_shape);- auto compiled_model = ie->compile_model(model, target_device);-- ov::InferRequest req;- req = compiled_model.create_infer_request();- const std::string tensor_name = "tensor_input0";-- OV_EXPECT_THROW_HAS_SUBSTRING(req.set_tensor(tensor_name, m_param.m_input_tensor),- ov::Exception,- "tensor has a non-contiguous memory");-}--using SetShapeInferRunTests = InferRequestRunTests;--TEST_P(SetShapeInferRunTests, checkResultsAfterIOBlobReallocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto original_shape = Shape{1, 10, 10, 10};- auto dummy_shape = Shape{1, 50, 100, 100};- auto shape_size = ov::shape_size(original_shape);- auto model = createModel(element::f32, original_shape, "N...");-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- input = compiled_model.input();- output = compiled_model.output();-- ov::Tensor input_tensor, first_output_tensor, second_output_tensor;- auto in_shape = input.get_shape();- auto out_shape = output.get_shape();-- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 5.f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());- OV_ASSERT_NO_THROW(first_output_tensor = inference_request.get_tensor(output));- // create dummy Tensors to force the driver to allocate memory for the initial tensor somewhere else- [[maybe_unused]] auto l0_host_dummy_tensor_0 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_1 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_2 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_3 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_4 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_5 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_6 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_7 = context.create_host_tensor(ov::element::f32, dummy_shape);-- auto* actual = first_output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 6.f, 1e-5) << "Expected=6, actual=" << actual[i] << " for index " << i;- }-- // imitates blob reallocation- OV_ASSERT_NO_THROW(input_tensor.set_shape({1, 50, 20, 20}));- OV_ASSERT_NO_THROW(input_tensor.set_shape(in_shape));-- OV_ASSERT_NO_THROW(second_output_tensor = inference_request.get_tensor(output));- OV_ASSERT_NO_THROW(second_output_tensor.set_shape({1, 20, 20, 20}));- OV_ASSERT_NO_THROW(second_output_tensor.set_shape(out_shape));-- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 9.f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());- OV_ASSERT_NO_THROW(second_output_tensor = inference_request.get_tensor(output));-- actual = second_output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_NEAR(actual[i], 10.f, 1e-5) << "Expected=10, actual=" << actual[i] << " for index " << i;- }-}--TEST_P(SetShapeInferRunTests, checkResultsAfterStateTensorsReallocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- testing::internal::Random random(1);- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 10, 10, 10};- auto dummy_shape = Shape{1, 50, 100, 100};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- for (auto&& state : inference_request.query_state()) {- state.reset();- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- ASSERT_NEAR(0.5f, output_data[i], 1e-5);- }-- auto states = inference_request.query_state();- for (auto state : states) {- auto last_state = state.get_state();- auto last_state_size = last_state.get_size();- auto last_state_data = static_cast<float*>(last_state.data());-- ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";-- for (size_t i = 0; i < last_state_size; ++i) {- ASSERT_NEAR(0.0, last_state_data[i], 1e-5);- }- }-- // create dummy Tensors to force the driver to allocate memory for the initial tensor somewhere else- [[maybe_unused]] auto l0_host_dummy_tensor_0 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_1 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_2 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_3 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_4 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_5 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_6 = context.create_host_tensor(ov::element::f32, dummy_shape);- [[maybe_unused]] auto l0_host_dummy_tensor_7 = context.create_host_tensor(ov::element::f32, dummy_shape);-- for (auto item : inference_request.query_state()) {- auto tensor_state = item.get_state();- auto original_shape = tensor_state.get_shape();- OV_ASSERT_NO_THROW(tensor_state.set_shape({1, 50, 20, 20}));- OV_ASSERT_NO_THROW(tensor_state.set_shape(original_shape));- }-- for (auto&& state : inference_request.query_state()) {- state.reset();- }-- for (auto state : states) {- auto last_state = state.get_state();- auto last_state_size = last_state.get_size();- auto last_state_data = static_cast<float*>(last_state.data());-- ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";-- for (size_t i = 0; i < last_state_size; ++i) {- last_state_data[i] = 1.0f;- }- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- for (auto state : states) {- auto last_state = state.get_state();- auto last_state_size = last_state.get_size();- auto last_state_data = static_cast<float*>(last_state.data());-- ASSERT_TRUE(last_state_size != 0) << "State size should not be 0";-- for (size_t i = 0; i < last_state_size; ++i) {- ASSERT_NEAR(input_data[i], last_state_data[i], 1e-5);- }- }-}--using CpuVaTensorsTests = InferRequestRunTests;--TEST_P(CpuVaTensorsTests, DontDestroyImportedMemory) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;- ov::Tensor global_input;- float* data;- ov::CompiledModel compiled_model;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- global_input = inference_request.get_input_tensor();- memset(global_input.data(), 1, global_input.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor(0);-- compiled_model = {};- inference_request = {};-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(global_input));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);-- const size_t byte_size = global_input.get_byte_size();- data = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));- memset(data, 1, byte_size);-- for (int i = 0; i < 10; i++) {- {- ov::Tensor input_data_tensor{ov::element::f32, global_input.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- }- second_output = inference_request.get_output_tensor(0);-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);- }-- inference_request = {};-- ::operator delete(data, std::align_val_t(4096));-}--TEST_P(CpuVaTensorsTests, SetMultiplePageAllignedTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- ov::InferRequest inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- float* input_data;- float* output_data[inferences];-- const auto input_byte_size = shape_size * sizeof(float);- input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 0.f;- }- input_tensor = ov::Tensor{ov::element::f32, shape, input_data};-- inference_request = compiled_model.create_infer_request();-- for (int i = 0; i < inferences; i++) {- auto tensor = inference_request.get_output_tensor(0);- const auto byte_size = tensor.get_byte_size();-- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};- }-- inference_request.set_input_tensor(input_tensor);- inference_request.set_output_tensor(output_tensor[0]);-- inference_request.infer(); // Adds '1' to each element-- for (int i = 1; i < inferences; i++) {- inference_request.set_output_tensor(output_tensor[i]);- inference_request.set_input_tensor(output_tensor[i - 1]);-- inference_request.infer(); // Adds '1' to each element- }-- float expected_result = 1.f;-- for (int i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- EXPECT_EQ(output_tensor_data, output_data[i]);- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- expected_result++;- }-- inference_request = {};-- input_tensor = {};- ::operator delete(input_data, std::align_val_t(4096));- for (int i = 0; i < inferences; i++) {- output_tensor[i] = {};- ::operator delete(output_data[i], std::align_val_t(4096));- }-}--TEST_P(CpuVaTensorsTests, SetMultipleAllignedAndNotAllignedTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- ov::InferRequest inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- float* input_data;- float* output_data[inferences];-- const auto input_byte_size = shape_size * sizeof(float);- input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));- input_tensor = ov::Tensor{ov::element::f32, shape, input_data};-- inference_request = compiled_model.create_infer_request();- for (int i = 0; i < inferences; i++) {- auto tensor = inference_request.get_output_tensor(0);- const auto byte_size = tensor.get_byte_size();-- if (i % 2 == 0) {- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(16)));- } else {- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));- }- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};- }-- inference_request.set_input_tensor(input_tensor);- inference_request.set_output_tensor(output_tensor[0]);-- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 0.f;- }-- inference_request.infer(); // Adds '1' to each element-- for (int i = 1; i < inferences; i++) {- inference_request.set_output_tensor(output_tensor[i]);- inference_request.set_input_tensor(output_tensor[i - 1]);-- inference_request.infer(); // Adds '1' to each element- }-- float expected_result = 1.f;-- for (int i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- expected_result++;- }-- inference_request = {};-- input_tensor = {};- ::operator delete(input_data, std::align_val_t(4096));- for (int i = 0; i < inferences; i++) {- output_tensor[i] = {};- if (i % 2 == 0) {- ::operator delete(output_data[i], std::align_val_t(16));- } else {- ::operator delete(output_data[i], std::align_val_t(4096));- }- }-}--TEST_P(CpuVaTensorsTests, SetMultipleRemoteAllignedAndNotAllignedTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- auto context = core->get_default_context(target_device);- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- ov::InferRequest inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- float* input_data;- float* output_data[inferences];-- const auto input_byte_size = shape_size * sizeof(float);- input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(16)));- input_tensor = ov::Tensor{ov::element::f32, shape, input_data};-- inference_request = compiled_model.create_infer_request();- for (int i = 0; i < inferences; i++) {- auto tensor = inference_request.get_output_tensor(0);- const auto byte_size = tensor.get_byte_size();-- if (i % 4 == 0) {- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(16)));- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};- } else if (i % 4 == 1) {- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};- } else if (i % 4 == 2) {- output_tensor[i] = context.create_host_tensor(ov::element::f32, shape);- } else if (i % 4 == 3) {- output_data[i] = static_cast<float*>(::operator new(byte_size, std::align_val_t(4096)));- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape(), output_data[i]};- }- }-- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 0.f;- }-- inference_request.set_input_tensor(input_tensor);- inference_request.set_output_tensor(output_tensor[0]);-- inference_request.infer(); // Adds '1' to each element-- for (int i = 1; i < inferences; i++) {- inference_request.set_output_tensor(output_tensor[i]);- inference_request.set_input_tensor(output_tensor[i - 1]);-- inference_request.infer(); // Adds '1' to each element- }-- float expected_result = 1.f;-- for (int i = 0; i < inferences; i++) {- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- expected_result++;- }-- inference_request = {};-- input_tensor = {};- ::operator delete(input_data, std::align_val_t(16));- for (int i = 0; i < inferences; i++) {- output_tensor[i] = {};- if (i % 4 == 0) {- ::operator delete(output_data[i], std::align_val_t(16));- } else if (i % 4 == 1) {- ::operator delete(output_data[i], std::align_val_t(4096));- } else if (i % 4 == 3) {- ::operator delete(output_data[i], std::align_val_t(4096));- }- }-}--TEST_P(CpuVaTensorsTests, SetAndDestroyDifferentAlignedTensors) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request0, inference_request1;-- const auto input_byte_size = shape_size * sizeof(float);- auto input_data = static_cast<float*>(::operator new(input_byte_size, std::align_val_t(4096)));- // Create two tensors for the same buffer to mimic weights/data sharing among multiple inference requests- auto input_tensor0 = ov::Tensor{ov::element::f32, shape, input_data};- auto input_tensor1 = ov::Tensor{ov::element::f32, shape, input_data};-- inference_request0 = compiled_model.create_infer_request();- inference_request1 = compiled_model.create_infer_request();-- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 6.f;- }-- inference_request0.set_input_tensor(input_tensor0);- inference_request0.infer();- inference_request0.set_input_tensor(input_tensor1);- inference_request1.set_input_tensor(input_tensor1);- inference_request0.infer();-- auto output_tensor0 = inference_request0.get_output_tensor();- inference_request0 = {};-- inference_request1.infer();- inference_request1.set_input_tensor(input_tensor0);- inference_request1.infer();-- auto output_tensor1 = inference_request1.get_output_tensor();- inference_request1 = {};-- float expected_result = 7.f;-- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor0.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- output_tensor_data = reinterpret_cast<float*>(output_tensor1.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- inference_request0 = {};- inference_request1 = {};-- input_tensor0 = {};- input_tensor1 = {};- ::operator delete(input_data, std::align_val_t(4096));-}--TEST_P(CpuVaTensorsTests, checkResultsAfterStateTensorsUseImportCpuVa0) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- testing::internal::Random random(1);- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- float* state_data[3];- ov::Tensor state_tensor[3];-- auto states = inference_request.query_state();-- auto get_tensor_state = states[0].get_state();- auto tensor_state_shape = get_tensor_state.get_shape();- auto l0_host_tensor = context.create_host_tensor(ov::element::f32, tensor_state_shape);- states[0].set_state(l0_host_tensor);-- get_tensor_state = states[1].get_state();- tensor_state_shape = get_tensor_state.get_shape();- auto state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);- state_data[0] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));- state_tensor[0] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[0]};- states[1].set_state(state_tensor[0]);-- for (auto&& state : states) {- state.reset();- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- ASSERT_NEAR(0.5f, output_data[i], 1e-5);- }-- states = inference_request.query_state();-- get_tensor_state = states[0].get_state();- tensor_state_shape = get_tensor_state.get_shape();- state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);- state_data[1] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));- state_tensor[1] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[1]};- states[0].set_state(state_tensor[1]);-- get_tensor_state = states[1].get_state();- tensor_state_shape = get_tensor_state.get_shape();- state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);- state_data[2] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(64)));- state_tensor[2] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[2]};- states[1].set_state(state_tensor[2]);-- for (size_t i = 0; i < states[0].get_state().get_size(); ++i) {- state_data[1][i] = 1.0f;- }- for (size_t i = 0; i < states[1].get_state().get_size(); ++i) {- state_data[2][i] = 1.0f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto get_state_data = static_cast<float*>(l0_host_tensor.data());- for (size_t i = 0; i < get_tensor_state.get_size(); ++i) {- ASSERT_NEAR(0.0, get_state_data[i], 1e-5);- ASSERT_NEAR(0.0, state_data[0][i], 1e-5);-- ASSERT_NEAR(input_data[i], state_data[1][i], 1e-5);- ASSERT_NEAR(input_data[i], state_data[2][i], 1e-5);- }-- inference_request = {};-- state_tensor[0] = {};- state_tensor[1] = {};- state_tensor[2] = {};-- ::operator delete(state_data[0], std::align_val_t(4096));- ::operator delete(state_data[1], std::align_val_t(4096));- ::operator delete(state_data[2], std::align_val_t(64));-}--TEST_P(CpuVaTensorsTests, checkResultsAfterStateTensorsUseImportCpuVa1) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- testing::internal::Random random(1);- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device);-- ov::CompiledModel compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- float* state_data[3];- ov::Tensor state_tensor[3];-- auto states = inference_request.query_state();-- auto get_tensor_state = states[0].get_state();- auto tensor_state_shape = get_tensor_state.get_shape();- auto l0_host_tensor = context.create_host_tensor(ov::element::f32, tensor_state_shape);- states[0].set_state(l0_host_tensor);-- get_tensor_state = states[1].get_state();- tensor_state_shape = get_tensor_state.get_shape();- auto state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);-- state_data[0] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));- state_tensor[0] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[0]};- states[1].set_state(state_tensor[0]);-- for (auto&& state : states) {- state.reset();- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- ASSERT_NEAR(0.5f, output_data[i], 1e-5);- }-- states = inference_request.query_state();-- get_tensor_state = states[0].get_state();- tensor_state_shape = get_tensor_state.get_shape();- state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);- state_data[1] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(64)));- state_tensor[1] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[1]};- states[0].set_state(state_tensor[1]);-- get_tensor_state = states[1].get_state();- tensor_state_shape = get_tensor_state.get_shape();- state_byte_size = ov::shape_size(tensor_state_shape) * sizeof(float);- state_data[2] = static_cast<float*>(::operator new(state_byte_size, std::align_val_t(4096)));- state_tensor[2] = ov::Tensor{ov::element::f32, tensor_state_shape, state_data[2]};- states[1].set_state(state_tensor[2]);-- for (size_t i = 0; i < states[0].get_state().get_size(); ++i) {- state_data[1][i] = 1.0f;- }- for (size_t i = 0; i < states[1].get_state().get_size(); ++i) {- state_data[2][i] = 1.0f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto get_state_data = static_cast<float*>(l0_host_tensor.data());- for (size_t i = 0; i < get_tensor_state.get_size(); ++i) {- ASSERT_NEAR(0.0, get_state_data[i], 1e-5);- ASSERT_NEAR(0.0, state_data[0][i], 1e-5);-- ASSERT_NEAR(input_data[i], state_data[1][i], 1e-5);- ASSERT_NEAR(input_data[i], state_data[2][i], 1e-5);- }-- inference_request = {};-- state_tensor[0] = {};- state_tensor[1] = {};- state_tensor[2] = {};-- ::operator delete(state_data[0], std::align_val_t(4096));- ::operator delete(state_data[1], std::align_val_t(64));- ::operator delete(state_data[2], std::align_val_t(4096));-}--TEST_P(CpuVaTensorsTests, checkResultsAfterRawMemoryIsDestroyedAndReallocatedAfterEachRun) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";- }-- ov::Core internal_core;- ov::InferRequest inference_request;- std::string logs;- std::mutex logs_mutex;- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(ov::element::f32, shape, "N...");-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);- internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));- inference_request = compiled_model.create_infer_request();- }- logs.clear();-- for (size_t i = 0; i < 10; ++i) {- float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));- float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});- inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});- inference_request.infer();- }-- ASSERT_NE(logs.find("deallocate the tensor data"), std::string::npos);-- logs.clear();-- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)- << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }-- ::operator delete(input_data, std::align_val_t(4096));- ::operator delete(output_data, std::align_val_t(4096));- }-}--TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimes) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";- }-- ov::Core internal_core;- ov::InferRequest inference_request;- std::string logs;- std::mutex logs_mutex;- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(ov::element::f32, shape, "N...");-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));- float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);- internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));- inference_request = compiled_model.create_infer_request();- inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});- inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});- }- logs.clear();-- for (size_t i = 0; i < 10; ++i) {- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- inference_request.infer();- }-- if (i == 0) {- ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);- } else {- ASSERT_NE(logs.find("import the tensor data"), std::string::npos);- }- ASSERT_NE(logs.find("deallocate the tensor data"), std::string::npos);-- logs.clear();-- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)- << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }- }-- ::operator delete(input_data, std::align_val_t(4096));- ::operator delete(output_data, std::align_val_t(4096));-}--TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameZeroTensorMultipleTimes) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";- }-- ov::Core internal_core;- ov::InferRequest inference_request;- float *input_data, *output_data;- ov::Tensor input_tensor, output_tensor;- std::string logs;- std::mutex logs_mutex;- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(ov::element::f32, shape, "N...");-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);- internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));- inference_request = compiled_model.create_infer_request();- input_tensor = inference_request.get_input_tensor();- output_tensor = inference_request.get_output_tensor();- input_data = input_tensor.data<float>();- output_data = output_tensor.data<float>();- }- logs.clear();-- for (size_t i = 0; i < 10; ++i) {- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- inference_request.infer();- }-- ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);- ASSERT_EQ(logs.find("deallocate the tensor data"), std::string::npos);-- logs.clear();-- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)- << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }- }-}--TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameZeroHostTensorMultipleTimes) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";- }-- ov::Core internal_core;- auto context = internal_core.get_default_context(target_device);- ov::InferRequest inference_request;- std::string logs;- std::mutex logs_mutex;- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(ov::element::f32, shape, "N...");-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- ov::Tensor input_tensor = context.create_host_tensor(ov::element::f32, shape);- ov::Tensor output_tensor = context.create_host_tensor(ov::element::f32, shape);- float* input_data = input_tensor.data<float>();- float* output_data = output_tensor.data<float>();-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);- internal_core.set_property(target_device, ov::log::level(ov::log::Level::DEBUG));- inference_request = compiled_model.create_infer_request();- inference_request.set_input_tensor(input_tensor);- inference_request.set_output_tensor(output_tensor);- }- logs.clear();-- for (size_t i = 0; i < 10; ++i) {- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- inference_request.infer();- }-- ASSERT_EQ(logs.find("import the tensor data"), std::string::npos);- ASSERT_EQ(logs.find("deallocate the tensor data"), std::string::npos);-- logs.clear();-- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)- << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }- }-}--TEST_P(CpuVaTensorsTests, checkResultsAfterRunningWithSameRawMemoryMultipleTimesAllocatingRandomZeroMemoryInBetween) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (!zeroInit->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "External memory standard allocation is not supported on this platform.";- }-- ov::Core internal_core;- auto context = internal_core.get_default_context(target_device);- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(ov::element::f32, shape, "N...");- std::vector<ov::Tensor> input_tensor;-- float* input_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));- float* output_data = static_cast<float*>(::operator new(shape_size * sizeof(float), std::align_val_t(4096)));-- ov::CompiledModel compiled_model = internal_core.compile_model(model, target_device, configuration);- auto inference_request = compiled_model.create_infer_request();- inference_request.set_input_tensor(ov::Tensor{ov::element::f32, shape, input_data});- inference_request.set_output_tensor(ov::Tensor{ov::element::f32, shape, output_data});-- for (size_t i = 0; i < 5; ++i) {- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }-- input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));- input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));- input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));- input_tensor.push_back(context.create_host_tensor(ov::element::f32, shape));-- OV_ASSERT_NO_THROW(inference_request.infer());-- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_data[j], input_data[j] + 1.0f, 1e-5)- << "Run " << i << ": Expected=" << input_data[j] + 1.0f << ", actual=" << output_data[j]- << " for index " << j;- }- }-- ::operator delete(input_data, std::align_val_t(4096));- ::operator delete(output_data, std::align_val_t(4096));-}--class DynamicBoundsTests : public InferRequestRunTests {-public:- void SetUp() override {- InferRequestRunTests::SetUp();- configuration.insert({ov::intel_npu::compilation_mode.name(), ov::Any("DefaultHW")});- }-};--TEST_P(DynamicBoundsTests, ChangeShapeAfterTensorIsSet) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto model_shape = PartialShape{1, ov::Dimension(1, 10), 2, 2};- auto model = createModel(element::f32, model_shape, "N...");-- auto compiled_model = core->compile_model(model, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- req = compiled_model.create_infer_request();-- auto shape = Shape{1, 4, 2, 2};- auto shape_size = ov::shape_size(shape);- auto input_tensor = ov::Tensor{ov::element::f32, shape};- auto output_tensor = ov::Tensor{ov::element::f32, shape};-- ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(shape, input_tensor.get_shape());- ASSERT_EQ(shape, output_tensor.get_shape());-- req.set_input_tensor(input_tensor);- req.set_output_tensor(output_tensor);-- auto input_data = input_tensor.data<float>();- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 21.f;- }-- req.infer(); // Adds '1' to each element-- auto expected = 22.f;- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- auto input_data_after_run = input_tensor.data<float>();- auto output_data_after_run = output_tensor.data<float>();-- ASSERT_EQ(input_data, input_data_after_run);- ASSERT_EQ(output_data, output_data_after_run);-- auto new_shape = Shape{1, 6, 2, 2};- auto new_shape_size = ov::shape_size(new_shape);- input_tensor.set_shape(new_shape);- output_tensor.set_shape(new_shape);-- ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(new_shape, input_tensor.get_shape());- ASSERT_EQ(new_shape, output_tensor.get_shape());-- input_data = input_tensor.data<float>();- output_data = output_tensor.data<float>();-- for (size_t i = 0; i < new_shape_size; ++i) {- input_data[i] = 25.f;- }-- req.infer(); // Adds '1' to each element-- expected = 26.f;- for (size_t i = 0; i < new_shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(new_shape, input_tensor.get_shape());- ASSERT_EQ(new_shape, output_tensor.get_shape());-- input_data_after_run = input_tensor.data<float>();- output_data_after_run = output_tensor.data<float>();-- ASSERT_EQ(input_data, input_data_after_run);- ASSERT_EQ(output_data, output_data_after_run);-}--TEST_P(DynamicBoundsTests, ChangeShapeAfterTensorIsSetUsingAlignedExternalMemory) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};- auto model = createModel(element::f32, model_shape, "N...");-- auto compiled_model = core->compile_model(model, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- req = compiled_model.create_infer_request();-- ov::Allocator allocator{ov::test::utils::DefaultAllocatorAligned{}};-- auto shape = Shape{1, 8, 4, 64};- auto shape_size = ov::shape_size(shape);- auto input_tensor = ov::Tensor{ov::element::f32, shape, allocator};- auto output_tensor = ov::Tensor{ov::element::f32, shape, allocator};-- ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(shape, input_tensor.get_shape());- ASSERT_EQ(shape, output_tensor.get_shape());-- req.set_input_tensor(input_tensor);- req.set_output_tensor(output_tensor);-- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 21.f;- }-- req.infer(); // Adds '1' to each element-- auto expected = 22.f;- auto* output_data = output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- auto new_shape = Shape{1, 6, 4, 64};- auto new_shape_size = ov::shape_size(new_shape);- input_tensor.set_shape(new_shape);- output_tensor.set_shape(new_shape);-- ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(new_shape, input_tensor.get_shape());- ASSERT_EQ(new_shape, output_tensor.get_shape());-- input_data = input_tensor.data<float>();- output_data = output_tensor.data<float>();-- for (size_t i = 0; i < new_shape_size; ++i) {- input_data[i] = 25.f;- }-- req.infer(); // Adds '1' to each element-- expected = 26.f;- for (size_t i = 0; i < new_shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- ASSERT_EQ(new_shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(new_shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(new_shape, input_tensor.get_shape());- ASSERT_EQ(new_shape, output_tensor.get_shape());-}--TEST_P(DynamicBoundsTests, RunningTwiceWithRemoteTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};- auto model = createModel(element::f32, model_shape, "N...");-- auto compiled_model = core->compile_model(model, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- req = compiled_model.create_infer_request();-- auto context = core->get_default_context(target_device);-- auto shape = Shape{1, 8, 4, 64};- auto shape_size = ov::shape_size(shape);- auto input_tensor = context.create_host_tensor(ov::element::f32, shape);- auto output_tensor = context.create_host_tensor(ov::element::f32, shape);-- ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(shape, input_tensor.get_shape());- ASSERT_EQ(shape, output_tensor.get_shape());-- req.set_input_tensor(input_tensor);- req.set_output_tensor(output_tensor);-- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 21.f;- }-- req.infer(); // Adds '1' to each element-- auto expected = 22.f;- auto* output_data = output_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = 25.f;- }-- req.infer(); // Adds '1' to each element-- expected = 26.f;- for (size_t i = 0; i < shape_size; ++i) {- ASSERT_EQ(output_data[i], expected)- << ": Expected=" << expected << ", actual=" << output_data[i] << " for index " << i;- }-- ASSERT_EQ(shape_size * sizeof(float), input_tensor.get_byte_size());- ASSERT_EQ(shape_size * sizeof(float), output_tensor.get_byte_size());- ASSERT_EQ(shape, input_tensor.get_shape());- ASSERT_EQ(shape, output_tensor.get_shape());-}--TEST_P(DynamicBoundsTests, ExpectErrorFromWrongTensorShape) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- auto model_shape = PartialShape{1, ov::Dimension(1, 10), 4, 64};- auto model = createModel(element::f32, model_shape, "N...");-- auto compiled_model = core->compile_model(model, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- req = compiled_model.create_infer_request();-- auto context = core->get_default_context(target_device);- auto input_tensor = context.create_host_tensor(ov::element::f32, Shape{1, 8, 2, 64});- OV_EXPECT_THROW(req.set_input_tensor(input_tensor),- ov::Exception,- HasSubstr("The tensor shape is not compatible with the model input/output shape"));-- auto output_tensor = context.create_host_tensor(ov::element::f32, Shape{1, 8, 12, 64});- OV_EXPECT_THROW(req.set_output_tensor(output_tensor),- ov::Exception,- HasSubstr("The tensor shape is not compatible with the model input/output shape"));-}--using NumStreamsTests = InferRequestRunTests;--TEST_P(NumStreamsTests, RunWithDifferentNumStreamsCheckResults) {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- auto shape = Shape{1, 2, 64, 64};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- auto compiled_model = core->compile_model(model, target_device, configuration);- const uint32_t inferences = 32;- std::array<ov::InferRequest, inferences> inference_request;-- for (uint32_t i = 0; i < inferences; i++) {- inference_request[i] = compiled_model.create_infer_request();-- auto input_tensor = inference_request[i].get_input_tensor();- auto* input_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t j = 0; j < shape_size; ++j) {- input_data[j] = static_cast<float>(i);- }- }-- for (uint32_t i = 0; i < inferences; i++) {- OV_ASSERT_NO_THROW(inference_request[i].infer());- }-- for (uint32_t i = 0; i < inferences; i++) {- OV_ASSERT_NO_THROW(inference_request[i].start_async());- }-- for (uint32_t i = 0; i < inferences; i++) {- OV_ASSERT_NO_THROW(inference_request[i].wait());- }-- for (uint32_t i = 0; i < inferences; i++) {- float expected_result = static_cast<float>(i) + 1.f;- auto output_tensor = inference_request[i].get_output_tensor();- auto* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());- for (size_t j = 0; j < shape_size; ++j) {- ASSERT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Inference=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- }-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.cppindex 6dcc2e7f7bb..22150575681 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.cpp@@ -2,13 +2,264 @@// SPDX-License-Identifier: Apache-2.0//-#include "io_tensor.hpp"-+#include <behavior/ov_infer_request/io_tensor.hpp>+#include <common_test_utils/ov_tensor_utils.hpp>#include <vector>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+namespace ov {+namespace test {+namespace behavior {++struct OVInferRequestIOTensorTestNPU : public OVInferRequestIOTensorTest {+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration) = this->GetParam();+ APIBaseTest::SetUp();+ function = ov::test::behavior::getDefaultNGraphFunctionForTheDeviceNPU();+ ov::AnyMap params;+ for (auto&& v : configuration) {+ params.emplace(v.first, v.second);+ }+ execNet = core->compile_model(function, target_device, params);+ try {+ req = execNet.create_infer_request();+ } catch (const std::exception& ex) {+ FAIL() << "Can't create infer request\n" << ex.what() << "\n";+ }+ input = execNet.input();+ output = execNet.output();+ }+};++TEST_P(OVInferRequestIOTensorTestNPU, failToSetNullptrForInput) {+ ASSERT_THROW(req.set_tensor(input, {}), ov::Exception);+}++TEST_P(OVInferRequestIOTensorTestNPU, failToSetNullptrForOutput) {+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ ASSERT_THROW(req.set_tensor(output, {}), ov::Exception);+}++TEST_P(OVInferRequestIOTensorTestNPU, canSetAndGetInput) {+ auto tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());+ OV_ASSERT_NO_THROW(req.set_tensor(input, tensor));+ ov::Tensor actual_tensor;+ OV_ASSERT_NO_THROW(actual_tensor = req.get_tensor(input));++ ASSERT_TRUE(actual_tensor);+ ASSERT_NE(nullptr, actual_tensor.data());+ ASSERT_EQ(tensor.data(), actual_tensor.data());+ ASSERT_EQ(input.get_element_type(), actual_tensor.get_element_type());+ ASSERT_EQ(input.get_shape(), actual_tensor.get_shape());+}++TEST_P(OVInferRequestIOTensorTestNPU, canSetAndGetOutput) {+ auto tensor = utils::create_and_fill_tensor(output.get_element_type(), output.get_shape());+ req.set_tensor(output, tensor);+ auto actual_tensor = req.get_tensor(output);++ ASSERT_TRUE(actual_tensor);+ ASSERT_FALSE(actual_tensor.data() == nullptr);+ ASSERT_EQ(actual_tensor.data(), tensor.data());+ ASSERT_EQ(output.get_element_type(), actual_tensor.get_element_type());+ ASSERT_EQ(output.get_shape(), actual_tensor.get_shape());+}++TEST_P(OVInferRequestIOTensorTestNPU, failToSetTensorWithIncorrectName) {+ auto tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());+ ASSERT_THROW(req.set_tensor("incorrect_input", tensor), ov::Exception);+}++TEST_P(OVInferRequestIOTensorTestNPU, failToSetInputWithIncorrectSizes) {+ auto shape = input.get_shape();+ shape[0] *= 2;+ auto tensor = utils::create_and_fill_tensor(input.get_element_type(), shape);+ ASSERT_THROW(req.set_tensor(input, tensor), ov::Exception);+}++TEST_P(OVInferRequestIOTensorTestNPU, failToSetOutputWithIncorrectSizes) {+ auto shape = output.get_shape();+ shape[0] *= 2;+ auto tensor = utils::create_and_fill_tensor(output.get_element_type(), shape);+ ASSERT_THROW(req.set_tensor(output, tensor), ov::Exception);+}++TEST_P(OVInferRequestIOTensorTestNPU, canInferWithoutSetAndGetInOutSync) {+ OV_ASSERT_NO_THROW(req.infer());+}++TEST_P(OVInferRequestIOTensorTestNPU, canInferWithoutSetAndGetInOutAsync) {+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+}++TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetInputDoNotReAllocateData) {+ ov::Tensor tensor1, tensor2;+ OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(input));+ OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(input));+ ASSERT_EQ(tensor1.data(), tensor2.data());+}++TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetOutputDoNotReAllocateData) {+ ov::Tensor tensor1, tensor2;+ OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(output));+ OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(output));+ ASSERT_EQ(tensor1.data(), tensor2.data());+}++TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetInputAfterInferSync) {+ ov::Tensor tensor1, tensor2;+ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(input));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(input));+ ASSERT_EQ(tensor1.data(), tensor2.data());+}++TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetOutputAfterInferSync) {+ ov::Tensor tensor1, tensor2;+ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(output));+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(output));+ ASSERT_EQ(tensor1.data(), tensor2.data());+}++TEST_P(OVInferRequestIOTensorTestNPU, canInferWithSetInOutBlobs) {+ auto input_tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());+ OV_ASSERT_NO_THROW(req.set_tensor(input, input_tensor));+ auto output_tensor = utils::create_and_fill_tensor(output.get_element_type(), output.get_shape());+ OV_ASSERT_NO_THROW(req.set_tensor(output, output_tensor));+ OV_ASSERT_NO_THROW(req.infer());++ auto actual_input_tensor = req.get_tensor(input);+ ASSERT_EQ(actual_input_tensor.data(), input_tensor.data());+ auto actual_output_tensor = req.get_tensor(output);+ ASSERT_EQ(actual_output_tensor.data(), output_tensor.data());+}++TEST_P(OVInferRequestIOTensorTestNPU, canInferWithGetIn) {+ ov::Tensor input_tensor;+ OV_ASSERT_NO_THROW(input_tensor = req.get_tensor(input));+ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ OV_ASSERT_NO_THROW(req.get_tensor(output));+}++TEST_P(OVInferRequestIOTensorTestNPU, canInferAfterIOBlobReallocation) {+ ov::Tensor input_tensor, output_tensor;+ auto in_shape = input.get_shape();+ auto out_shape = output.get_shape();++ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());++ // imitates blob reallocation+ OV_ASSERT_NO_THROW(input_tensor = req.get_tensor(input));+ OV_ASSERT_NO_THROW(input_tensor.set_shape({5, 5, 5, 5}));+ OV_ASSERT_NO_THROW(input_tensor.set_shape(in_shape));++ OV_ASSERT_NO_THROW(output_tensor = req.get_tensor(output));+ OV_ASSERT_NO_THROW(output_tensor.set_shape({20, 20, 20, 20}));+ OV_ASSERT_NO_THROW(output_tensor.set_shape(out_shape));++ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(req.start_async());+ OV_ASSERT_NO_THROW(req.wait());+ OV_ASSERT_NO_THROW(req.get_tensor(output));+}++TEST_P(OVInferRequestIOTensorTestNPU, InferStaticNetworkSetChangedInputTensorThrow) {+ const ov::Shape shape1 = {1, 2, 32, 32};+ const ov::Shape shape2 = {1, 2, 40, 40};+ std::map<std::string, ov::PartialShape> shapes;+ shapes[function->inputs().back().get_any_name()] = shape1;+ OV_ASSERT_NO_THROW(function->reshape(shapes));+ // Load ov::Model to target plugins+ std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();+ auto execNet = ie->compile_model(function, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());+ // Get input_tensor+ ov::Tensor tensor;+ OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->inputs().back().get_any_name()));+ // Set shape+ OV_ASSERT_NO_THROW(tensor.set_shape(shape2));+ ASSERT_ANY_THROW(req.infer());+}++TEST_P(OVInferRequestIOTensorTestNPU, InferStaticNetworkSetChangedOutputTensorThrow) {+ const ov::Shape shape1 = {1, 2, 32, 32};+ ov::Shape shape2;+ shape2 = ov::Shape{1, 20};++ std::map<std::string, ov::PartialShape> shapes;+ shapes[function->inputs().back().get_any_name()] = shape1;+ OV_ASSERT_NO_THROW(function->reshape(shapes));+ // Load ov::Model to target plugins+ std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();+ auto execNet = ie->compile_model(function, target_device, configuration);+ // Create InferRequest+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());+ // Get output_tensor+ ov::Tensor tensor;+ OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->outputs().back().get_any_name()););+ // Set shape+ OV_ASSERT_NO_THROW(tensor.set_shape(shape2));+ ASSERT_ANY_THROW(req.infer());+}++struct OVInferRequestIOTensorSetPrecisionTestNPU : OVInferRequestIOTensorSetPrecisionTest {+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ const ov::Shape shape = {1, 2, 32, 32};+ std::tie(element_type, target_device, config) = this->GetParam();+ APIBaseTest::SetUp();+ function = ov::test::utils::make_split_concat(shape, element_type);+ execNet = core->compile_model(function, target_device, config);+ req = execNet.create_infer_request();+ }+};++TEST_P(OVInferRequestIOTensorSetPrecisionTestNPU, CanSetOutBlobWithDifferentPrecision) {+ for (auto&& output : execNet.outputs()) {+ auto output_tensor = utils::create_and_fill_tensor(element_type, output.get_shape());+ if (output.get_element_type() == element_type) {+ OV_ASSERT_NO_THROW(req.set_tensor(output, output_tensor));+ } else {+ ASSERT_THROW(req.set_tensor(output, output_tensor), ov::Exception);+ }+ }+}++TEST_P(OVInferRequestIOTensorSetPrecisionTestNPU, CanSetInBlobWithDifferentPrecision) {+ for (auto&& input : execNet.inputs()) {+ auto input_tensor = utils::create_and_fill_tensor(element_type, input.get_shape());+ if (input.get_element_type() == element_type) {+ OV_ASSERT_NO_THROW(req.set_tensor(input, input_tensor));+ } else {+ ASSERT_THROW(req.set_tensor(input, input_tensor), ov::Exception);+ }+ }+}++} // namespace behavior+} // namespace test+} // namespace ov+namespace {const std::vector<ov::AnyMap> configs = {{}};diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.hppdeleted file mode 100644index 239c2d0bf76..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/io_tensor.hpp+++ /dev/null@@ -1,261 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <behavior/ov_infer_request/io_tensor.hpp>-#include <common_test_utils/ov_tensor_utils.hpp>--#include "common/utils.hpp"--namespace ov {-namespace test {-namespace behavior {--struct OVInferRequestIOTensorTestNPU : public OVInferRequestIOTensorTest {- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration) = this->GetParam();- APIBaseTest::SetUp();- function = ov::test::behavior::getDefaultNGraphFunctionForTheDeviceNPU();- ov::AnyMap params;- for (auto&& v : configuration) {- params.emplace(v.first, v.second);- }- execNet = core->compile_model(function, target_device, params);- try {- req = execNet.create_infer_request();- } catch (const std::exception& ex) {- FAIL() << "Can't create infer request\n" << ex.what() << "\n";- }- input = execNet.input();- output = execNet.output();- }-};--TEST_P(OVInferRequestIOTensorTestNPU, failToSetNullptrForInput) {- ASSERT_THROW(req.set_tensor(input, {}), ov::Exception);-}--TEST_P(OVInferRequestIOTensorTestNPU, failToSetNullptrForOutput) {- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- ASSERT_THROW(req.set_tensor(output, {}), ov::Exception);-}--TEST_P(OVInferRequestIOTensorTestNPU, canSetAndGetInput) {- auto tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());- OV_ASSERT_NO_THROW(req.set_tensor(input, tensor));- ov::Tensor actual_tensor;- OV_ASSERT_NO_THROW(actual_tensor = req.get_tensor(input));-- ASSERT_TRUE(actual_tensor);- ASSERT_NE(nullptr, actual_tensor.data());- ASSERT_EQ(tensor.data(), actual_tensor.data());- ASSERT_EQ(input.get_element_type(), actual_tensor.get_element_type());- ASSERT_EQ(input.get_shape(), actual_tensor.get_shape());-}--TEST_P(OVInferRequestIOTensorTestNPU, canSetAndGetOutput) {- auto tensor = utils::create_and_fill_tensor(output.get_element_type(), output.get_shape());- req.set_tensor(output, tensor);- auto actual_tensor = req.get_tensor(output);-- ASSERT_TRUE(actual_tensor);- ASSERT_FALSE(actual_tensor.data() == nullptr);- ASSERT_EQ(actual_tensor.data(), tensor.data());- ASSERT_EQ(output.get_element_type(), actual_tensor.get_element_type());- ASSERT_EQ(output.get_shape(), actual_tensor.get_shape());-}--TEST_P(OVInferRequestIOTensorTestNPU, failToSetTensorWithIncorrectName) {- auto tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());- ASSERT_THROW(req.set_tensor("incorrect_input", tensor), ov::Exception);-}--TEST_P(OVInferRequestIOTensorTestNPU, failToSetInputWithIncorrectSizes) {- auto shape = input.get_shape();- shape[0] *= 2;- auto tensor = utils::create_and_fill_tensor(input.get_element_type(), shape);- ASSERT_THROW(req.set_tensor(input, tensor), ov::Exception);-}--TEST_P(OVInferRequestIOTensorTestNPU, failToSetOutputWithIncorrectSizes) {- auto shape = output.get_shape();- shape[0] *= 2;- auto tensor = utils::create_and_fill_tensor(output.get_element_type(), shape);- ASSERT_THROW(req.set_tensor(output, tensor), ov::Exception);-}--TEST_P(OVInferRequestIOTensorTestNPU, canInferWithoutSetAndGetInOutSync) {- OV_ASSERT_NO_THROW(req.infer());-}--TEST_P(OVInferRequestIOTensorTestNPU, canInferWithoutSetAndGetInOutAsync) {- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());-}--TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetInputDoNotReAllocateData) {- ov::Tensor tensor1, tensor2;- OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(input));- OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(input));- ASSERT_EQ(tensor1.data(), tensor2.data());-}--TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetOutputDoNotReAllocateData) {- ov::Tensor tensor1, tensor2;- OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(output));- OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(output));- ASSERT_EQ(tensor1.data(), tensor2.data());-}--TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetInputAfterInferSync) {- ov::Tensor tensor1, tensor2;- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(input));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(input));- ASSERT_EQ(tensor1.data(), tensor2.data());-}--TEST_P(OVInferRequestIOTensorTestNPU, secondCallGetOutputAfterInferSync) {- ov::Tensor tensor1, tensor2;- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(tensor1 = req.get_tensor(output));- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- OV_ASSERT_NO_THROW(tensor2 = req.get_tensor(output));- ASSERT_EQ(tensor1.data(), tensor2.data());-}--TEST_P(OVInferRequestIOTensorTestNPU, canInferWithSetInOutBlobs) {- auto input_tensor = utils::create_and_fill_tensor(input.get_element_type(), input.get_shape());- OV_ASSERT_NO_THROW(req.set_tensor(input, input_tensor));- auto output_tensor = utils::create_and_fill_tensor(output.get_element_type(), output.get_shape());- OV_ASSERT_NO_THROW(req.set_tensor(output, output_tensor));- OV_ASSERT_NO_THROW(req.infer());-- auto actual_input_tensor = req.get_tensor(input);- ASSERT_EQ(actual_input_tensor.data(), input_tensor.data());- auto actual_output_tensor = req.get_tensor(output);- ASSERT_EQ(actual_output_tensor.data(), output_tensor.data());-}--TEST_P(OVInferRequestIOTensorTestNPU, canInferWithGetIn) {- ov::Tensor input_tensor;- OV_ASSERT_NO_THROW(input_tensor = req.get_tensor(input));- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- OV_ASSERT_NO_THROW(req.get_tensor(output));-}--TEST_P(OVInferRequestIOTensorTestNPU, canInferAfterIOBlobReallocation) {- ov::Tensor input_tensor, output_tensor;- auto in_shape = input.get_shape();- auto out_shape = output.get_shape();-- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());-- // imitates blob reallocation- OV_ASSERT_NO_THROW(input_tensor = req.get_tensor(input));- OV_ASSERT_NO_THROW(input_tensor.set_shape({5, 5, 5, 5}));- OV_ASSERT_NO_THROW(input_tensor.set_shape(in_shape));-- OV_ASSERT_NO_THROW(output_tensor = req.get_tensor(output));- OV_ASSERT_NO_THROW(output_tensor.set_shape({20, 20, 20, 20}));- OV_ASSERT_NO_THROW(output_tensor.set_shape(out_shape));-- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(req.start_async());- OV_ASSERT_NO_THROW(req.wait());- OV_ASSERT_NO_THROW(req.get_tensor(output));-}--TEST_P(OVInferRequestIOTensorTestNPU, InferStaticNetworkSetChangedInputTensorThrow) {- const ov::Shape shape1 = {1, 2, 32, 32};- const ov::Shape shape2 = {1, 2, 40, 40};- std::map<std::string, ov::PartialShape> shapes;- shapes[function->inputs().back().get_any_name()] = shape1;- OV_ASSERT_NO_THROW(function->reshape(shapes));- // Load ov::Model to target plugins- std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();- auto execNet = ie->compile_model(function, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());- // Get input_tensor- ov::Tensor tensor;- OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->inputs().back().get_any_name()));- // Set shape- OV_ASSERT_NO_THROW(tensor.set_shape(shape2));- ASSERT_ANY_THROW(req.infer());-}--TEST_P(OVInferRequestIOTensorTestNPU, InferStaticNetworkSetChangedOutputTensorThrow) {- const ov::Shape shape1 = {1, 2, 32, 32};- ov::Shape shape2;- shape2 = ov::Shape{1, 20};-- std::map<std::string, ov::PartialShape> shapes;- shapes[function->inputs().back().get_any_name()] = shape1;- OV_ASSERT_NO_THROW(function->reshape(shapes));- // Load ov::Model to target plugins- std::shared_ptr<ov::Core> ie = utils::PluginCache::get().core();- auto execNet = ie->compile_model(function, target_device, configuration);- // Create InferRequest- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());- // Get output_tensor- ov::Tensor tensor;- OV_ASSERT_NO_THROW(tensor = req.get_tensor(function->outputs().back().get_any_name()););- // Set shape- OV_ASSERT_NO_THROW(tensor.set_shape(shape2));- ASSERT_ANY_THROW(req.infer());-}--struct OVInferRequestIOTensorSetPrecisionTestNPU : OVInferRequestIOTensorSetPrecisionTest {- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- const ov::Shape shape = {1, 2, 32, 32};- std::tie(element_type, target_device, config) = this->GetParam();- APIBaseTest::SetUp();- function = ov::test::utils::make_split_concat(shape, element_type);- execNet = core->compile_model(function, target_device, config);- req = execNet.create_infer_request();- }-};--TEST_P(OVInferRequestIOTensorSetPrecisionTestNPU, CanSetOutBlobWithDifferentPrecision) {- for (auto&& output : execNet.outputs()) {- auto output_tensor = utils::create_and_fill_tensor(element_type, output.get_shape());- if (output.get_element_type() == element_type) {- OV_ASSERT_NO_THROW(req.set_tensor(output, output_tensor));- } else {- ASSERT_THROW(req.set_tensor(output, output_tensor), ov::Exception);- }- }-}--TEST_P(OVInferRequestIOTensorSetPrecisionTestNPU, CanSetInBlobWithDifferentPrecision) {- for (auto&& input : execNet.inputs()) {- auto input_tensor = utils::create_and_fill_tensor(element_type, input.get_shape());- if (input.get_element_type() == element_type) {- OV_ASSERT_NO_THROW(req.set_tensor(input, input_tensor));- } else {- ASSERT_THROW(req.set_tensor(input, input_tensor), ov::Exception);- }- }-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.cppindex ff707838a30..4ecd2d77732 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.cpp@@ -2,9 +2,103 @@// SPDX-License-Identifier: Apache-2.0//-#include "multithreading.hpp"+#include <future>#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"++namespace ov {+namespace test {+namespace behavior {+using OVInferRequestMultithreadingTestsNPU = OVInferRequestTestsNPU;++TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3SyncRequestsConsistentlyFromThreads) {+ ov::InferRequest req1, req2, req3;+ OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());++ auto f1 = std::async(std::launch::async, [&] {+ req1.infer();+ });+ auto f2 = std::async(std::launch::async, [&] {+ req2.infer();+ });+ auto f3 = std::async(std::launch::async, [&] {+ req3.infer();+ });++ f1.wait();+ f2.wait();+ f3.wait();++ OV_ASSERT_NO_THROW(f1.get());+ OV_ASSERT_NO_THROW(f2.get());+ OV_ASSERT_NO_THROW(f3.get());+}++TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsConsistentlyFromThreadsWithoutWait) {+ ov::InferRequest req1, req2, req3;+ OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());++ OV_ASSERT_NO_THROW(req1.infer());+ OV_ASSERT_NO_THROW(req2.infer());+ OV_ASSERT_NO_THROW(req3.infer());++ auto f1 = std::async(std::launch::async, [&] {+ req1.start_async();+ });+ auto f2 = std::async(std::launch::async, [&] {+ req2.start_async();+ });+ auto f3 = std::async(std::launch::async, [&] {+ req3.start_async();+ });++ f1.wait();+ f2.wait();+ f3.wait();++ OV_ASSERT_NO_THROW(f1.get());+ OV_ASSERT_NO_THROW(f2.get());+ OV_ASSERT_NO_THROW(f3.get());+}++TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsConsistentlyWithWait) {+ ov::InferRequest req1, req2, req3;+ OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());++ req1.start_async();+ OV_ASSERT_NO_THROW(req1.wait());++ req2.start_async();+ OV_ASSERT_NO_THROW(req2.wait());++ req3.start_async();+ OV_ASSERT_NO_THROW(req3.wait());+}++TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsParallelWithWait) {+ ov::InferRequest req1, req2, req3;+ OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());+ OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());++ req1.start_async();+ req2.start_async();+ req3.start_async();++ OV_ASSERT_NO_THROW(req2.wait());+ OV_ASSERT_NO_THROW(req1.wait());+ OV_ASSERT_NO_THROW(req3.wait());+}+} // namespace behavior+} // namespace test+} // namespace ovnamespace {const std::vector<ov::AnyMap> configs = {{}};diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.hppdeleted file mode 100644index 6b20a1eb6c3..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_infer_request/multithreading.hpp+++ /dev/null@@ -1,102 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <future>--#include "common/utils.hpp"--namespace ov {-namespace test {-namespace behavior {-using OVInferRequestMultithreadingTestsNPU = OVInferRequestTestsNPU;--TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3SyncRequestsConsistentlyFromThreads) {- ov::InferRequest req1, req2, req3;- OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());-- auto f1 = std::async(std::launch::async, [&] {- req1.infer();- });- auto f2 = std::async(std::launch::async, [&] {- req2.infer();- });- auto f3 = std::async(std::launch::async, [&] {- req3.infer();- });-- f1.wait();- f2.wait();- f3.wait();-- OV_ASSERT_NO_THROW(f1.get());- OV_ASSERT_NO_THROW(f2.get());- OV_ASSERT_NO_THROW(f3.get());-}--TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsConsistentlyFromThreadsWithoutWait) {- ov::InferRequest req1, req2, req3;- OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());-- OV_ASSERT_NO_THROW(req1.infer());- OV_ASSERT_NO_THROW(req2.infer());- OV_ASSERT_NO_THROW(req3.infer());-- auto f1 = std::async(std::launch::async, [&] {- req1.start_async();- });- auto f2 = std::async(std::launch::async, [&] {- req2.start_async();- });- auto f3 = std::async(std::launch::async, [&] {- req3.start_async();- });-- f1.wait();- f2.wait();- f3.wait();-- OV_ASSERT_NO_THROW(f1.get());- OV_ASSERT_NO_THROW(f2.get());- OV_ASSERT_NO_THROW(f3.get());-}--TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsConsistentlyWithWait) {- ov::InferRequest req1, req2, req3;- OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());-- req1.start_async();- OV_ASSERT_NO_THROW(req1.wait());-- req2.start_async();- OV_ASSERT_NO_THROW(req2.wait());-- req3.start_async();- OV_ASSERT_NO_THROW(req3.wait());-}--TEST_P(OVInferRequestMultithreadingTestsNPU, canRun3AsyncRequestsParallelWithWait) {- ov::InferRequest req1, req2, req3;- OV_ASSERT_NO_THROW(req1 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req2 = execNet.create_infer_request());- OV_ASSERT_NO_THROW(req3 = execNet.create_infer_request());-- req1.start_async();- req2.start_async();- req3.start_async();-- OV_ASSERT_NO_THROW(req2.wait());- OV_ASSERT_NO_THROW(req1.wait());- OV_ASSERT_NO_THROW(req3.wait());-}-} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cppindex 6aa6d6d669f..a8d5c7fe70f 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp@@ -2,11 +2,53 @@// SPDX-License-Identifier: Apache-2.0//-#include "caching_tests.hpp"-+#include <behavior/ov_plugin/caching_tests.hpp>#include <vector>#include "common/utils.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "openvino/core/log_util.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"++namespace ov {+namespace test {+namespace behavior {++using OVCompileModelLoadFromFileTestBaseNPU = CompileModelLoadFromFileTestBase;++TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImported) {+ core->set_property(ov::cache_dir(m_cacheFolderName));++ if (!::intel_npu::ZeroInitStructsHolder::getInstance()->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "Standard allocation is not supported by the current configuration.";+ }++ std::stringstream custom_logger;+ ov::util::LogCallback custom_log_callback =+ [&](std::string_view s) { // switch to query allocation info for import flag when possible+ custom_logger << s << std::endl;+ };+ ov::util::set_log_callback(custom_log_callback);+ struct ResetLogCallbackGuard {+ ~ResetLogCallbackGuard() {+ ov::util::reset_log_callback();+ }+ } reset_log_callback_guard;++ for (size_t i = 0; i < 2; ++i) {+ if (i != 0) {+ configuration.emplace(ov::log::level(ov::log::Level::DEBUG));+ }+ std::ignore = core->compile_model(m_modelName, targetDevice, configuration);+ configuration.erase(ov::log::level.name());+ }+ EXPECT_THAT(custom_logger.str(),+ ::testing::HasSubstr("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"));+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hppdeleted file mode 100644index c37574412a2..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp+++ /dev/null@@ -1,51 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <behavior/ov_plugin/caching_tests.hpp>--#include "intel_npu/utils/zero/zero_init.hpp"-#include "openvino/core/log_util.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"--namespace ov {-namespace test {-namespace behavior {--using OVCompileModelLoadFromFileTestBaseNPU = CompileModelLoadFromFileTestBase;--TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImported) {- core->set_property(ov::cache_dir(m_cacheFolderName));-- if (!::intel_npu::ZeroInitStructsHolder::getInstance()->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "Standard allocation is not supported by the current configuration.";- }-- std::stringstream custom_logger;- ov::util::LogCallback custom_log_callback =- [&](std::string_view s) { // switch to query allocation info for import flag when possible- custom_logger << s << std::endl;- };- ov::util::set_log_callback(custom_log_callback);- struct ResetLogCallbackGuard {- ~ResetLogCallbackGuard() {- ov::util::reset_log_callback();- }- } reset_log_callback_guard;-- for (size_t i = 0; i < 2; ++i) {- if (i != 0) {- configuration.emplace(ov::log::level(ov::log::Level::DEBUG));- }- std::ignore = core->compile_model(m_modelName, targetDevice, configuration);- configuration.erase(ov::log::level.name());- }- EXPECT_THAT(custom_logger.str(),- ::testing::HasSubstr("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"));-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.cppindex e22c5ac8c22..7ea6bc7650e 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.cpp@@ -2,7 +2,558 @@// SPDX-License-Identifier: Apache-2.0//-#include "core_integration.hpp"+#include <filesystem>++#include "behavior/ov_plugin/properties_tests.hpp"+#include "common/functions.hpp"+#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "common_test_utils/data_utils.hpp"+#include "common_test_utils/subgraph_builders/concat_with_params.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "common_test_utils/subgraph_builders/kso_func.hpp"+#include "common_test_utils/subgraph_builders/single_concat_with_constant.hpp"+#include "common_test_utils/subgraph_builders/split_conv_concat.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT+# include <iostream>+# define GTEST_COUT std::cerr << "[ ] [ INFO ] "+# include <codecvt>+# include <functional_test_utils/skip_tests_config.hpp>++# include "openvino/pass/manager.hpp"++#endif++namespace ov {+namespace test {+namespace behavior {++class OVClassBaseTestPNPU : public OVClassNetworkTest,+ public testing::WithParamInterface<CompilationParams>,+ public OVPluginTestBase {+protected:+ ov::AnyMap configuration;+ std::string deathTestStyle;+ std::shared_ptr<ov::Model> function;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ std::tie(target_device, configuration) = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '.');++ std::ostringstream result;+ result << "OVClassNetworkTestName_" << target_device;+ result << "_targetDevice=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)+ << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ APIBaseTest::SetUp();+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ // Generic network+ actualNetwork = ov::test::utils::make_split_conv_concat();+ // Quite simple network+ simpleNetwork = ov::test::utils::make_single_concat_with_constant();+ // Multinput to substruct network+ multinputNetwork = ov::test::utils::make_concat_with_params();+ // Network with KSO+ ksoNetwork = ov::test::utils::make_kso_function();++ ov::AnyMap params;+ for (auto&& v : configuration) {+ params.emplace(v.first, v.second);+ }+ }++ void TearDown() override {+ ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }+};++class OVClassBasicTestPNPU : public OVBasicPropertiesTestsP {+public:+ void TearDown() override {+ for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) {+ std::wstring postfix = ov::test::utils::test_unicode_postfix_vector[testIndex];+ std::wstring unicode_path =+ ov::test::utils::stringToWString(ov::util::path_to_string(ov::util::get_ov_lib_path()) + "/") + postfix;+#ifndef _WIN32+ removeDirFilesRecursive(ov::util::wstring_to_string(unicode_path));+#else+ removeDirFilesRecursive(unicode_path);+#endif+ }+ }+};++using OVClassNetworkTestPNPU = OVClassBaseTestPNPU;+using OVClassLoadNetworkTestNPU = OVClassBaseTestPNPU;++TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualNoThrow) {+ ov::Core ie = ov::test::utils::create_core();+ OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, target_device, configuration));+}++TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDeviceNoThrow) {+ ov::Core ie = ov::test::utils::create_core();+ OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,+ ov::test::utils::DEVICE_HETERO + std::string(":") + target_device,+ configuration));+}++TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDevice2NoThrow) {+ ov::Core ie = ov::test::utils::create_core();++ OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,+ ov::test::utils::DEVICE_HETERO,+ ov::device::priorities(target_device),+ ov::device::properties(target_device, configuration)));+}++TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDeviceUsingDevicePropertiesNoThrow) {+ ov::Core ie = ov::test::utils::create_core();+ configuration.emplace(ov::enable_profiling(true));++ OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,+ ov::test::utils::DEVICE_HETERO,+ ov::device::priorities(target_device),+ ov::device::properties(target_device, configuration)));+}++TEST_P(OVClassLoadNetworkTestNPU, LoadNetworkHETEROWithDeviceIDNoThrow) {+ ov::Core ie = ov::test::utils::create_core();++ auto supported_properties = ie.get_property(target_device, ov::supported_properties);++ if (supported_properties.end() !=+ std::find(std::begin(supported_properties), std::end(supported_properties), ov::device::id)) {+ auto deviceIDs = ie.get_property(target_device, ov::available_devices);+ if (deviceIDs.empty())+ GTEST_FAIL();+ std::string heteroDevice = ov::test::utils::DEVICE_HETERO + std::string(":") + target_device + "." ++ deviceIDs[0] + "," + target_device;+ OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, heteroDevice, configuration));+ } else {+ GTEST_FAIL() << "Device does not support DeviceID property" << std::endl;+ }+}++TEST(compatibility_OVClassBasicPropsTestNPU, smoke_SetConfigDevicePropertiesThrows) {+ ov::Core core;+ ASSERT_THROW(core.set_property("", ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),+ ov::Exception);+ ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_NPU,+ ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),+ ov::Exception);+ ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_AUTO,+ ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),+ ov::Exception);+ ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_AUTO,+ ov::device::properties(ov::test::utils::DEVICE_NPU, ov::num_streams(4))),+ ov::Exception);+}++//+// NPU specific metrics+//++using OVClassGetMetricAndPrintNoThrow = OVClassBaseTestP;+TEST_P(OVClassGetMetricAndPrintNoThrow, DeviceAllocMemSizeLesserThanTotalMemSizeNPU) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core ie;+ ov::Any p;++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_total_mem_size.name()));+ uint64_t t = p.as<uint64_t>();+ ASSERT_NE(t, 0);++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t a = p.as<uint64_t>();++ ASSERT_LT(a, t);++ std::cout << "OV NPU device alloc/total memory size: " << a << "/" << t << std::endl;+}++TEST_P(OVClassGetMetricAndPrintNoThrow, DeviceAllocMemSizeLesserAfterModelIsLoadedNPU) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core ie;+ ov::Any p;++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t a1 = p.as<uint64_t>();++ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ auto model = ov::test::utils::make_conv_pool_relu();+ OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {}));+ }++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t a2 = p.as<uint64_t>();++ std::cout << "OV NPU device {alloc before load network/alloc after load network} memory size: {" << a1 << "/" << a2+ << "}" << std::endl;++ // after the network is loaded onto device, allocated memory value should increase+ ASSERT_LE(a1, a2);+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeLesserAfterModelIsLoaded) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core ie;+ ov::Any p;++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t a1 = p.as<uint64_t>();++ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ auto model = ov::test::utils::make_conv_pool_relu();+ OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, ov::AnyMap{ov::log::level(ov::log::Level::ERR)}));+ }++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t a2 = p.as<uint64_t>();++ std::cout << "OV NPU device {alloc before load network/alloc after load network} memory size: {" << a1 << "/" << a2+ << "}" << std::endl;++ // after the network is loaded onto device, allocated memory value should increase+ ASSERT_LE(a1, a2);+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyCompiledModel) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core core;+ ov::Any deviceAllocMemSizeAny;++ auto model = createModelWithLargeSize();++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();+ uint64_t deviceAllocMemSizeFinal;++ for (size_t i = 0; i < 10; ++i) {+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));++ compiledModel = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;+ }+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyCompiledModelWithTurboAndSeqRun) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() >+ ZE_MAKE_VERSION(1, 0)) {+ ov::Core core;+ ov::Any deviceAllocMemSizeAny;+ ov::AnyMap configuration;++ configuration[intel_npu::turbo.name()] = true;+ configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;++ auto model = createModelWithLargeSize();++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();+ uint64_t deviceAllocMemSizeFinal;++ for (size_t i = 0; i < 10; ++i) {+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device, configuration));++ compiledModel = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;+ }+ } else {+ GTEST_SKIP() << "Test is skipped due to driver version";+ }+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequest) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core core;+ ov::Any deviceAllocMemSizeAny;++ ov::CompiledModel compiledModel;+ auto model = createModelWithLargeSize();++ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));++ // After memory consumption updates, need to run first inference before measurements+ auto inferRequest = compiledModel.create_infer_request();+ inferRequest.infer();+ inferRequest = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();+ uint64_t deviceAllocMemSizeFinal;++ for (size_t i = 0; i < 10; ++i) {+ inferRequest = compiledModel.create_infer_request();+ inferRequest.infer();++ inferRequest = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;+ }+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequestSetTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core core;+ ov::Any deviceAllocMemSizeAny;++ ov::CompiledModel compiledModel;+ auto model = createModelWithLargeSize();++ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));++ // After memory consumption updates, need to run first inference before measurements+ auto inferRequest = compiledModel.create_infer_request();+ inferRequest.infer();+ inferRequest = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();+ uint64_t deviceAllocMemSizeFinal;++ auto tensor = ov::Tensor(model->input(0).get_element_type(), model->input(0).get_shape());+ ov::test::utils::fill_data_random(static_cast<ov::float16*>(tensor.data()), tensor.get_size());++ for (size_t i = 0; i < 10; ++i) {+ auto inferRequest = compiledModel.create_infer_request();+ inferRequest.set_input_tensor(tensor);+ inferRequest.infer();++ inferRequest = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;+ }+}++TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequestGetTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core core;+ ov::Any deviceAllocMemSizeAny;++ ov::CompiledModel compiledModel;+ auto model = createModelWithLargeSize();++ // Warm up inference to initialize driver scratch buffers+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));+ auto inferRequest = compiledModel.create_infer_request();+ inferRequest.infer();+ inferRequest = {};+ compiledModel = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();+ uint64_t deviceAllocMemSizeFinal;++ for (size_t i = 0; i < 10; ++i) {+ OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));++ auto inferRequest = compiledModel.create_infer_request();+ auto tensor = inferRequest.get_output_tensor();+ inferRequest.infer();++ inferRequest = {};+ compiledModel = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_LT(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;++ tensor = {};++ OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =+ core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));+ deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();+ ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;+ }+}++TEST_P(OVClassGetMetricAndPrintNoThrow, DriverVersionNPU) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core ie;+ ov::Any p;++ OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::driver_version.name()));+ uint32_t t = p.as<uint32_t>();++ std::cout << "NPU driver version is " << t << std::endl;++ OV_ASSERT_PROPERTY_SUPPORTED(ov::intel_npu::driver_version.name());+}++using OVClassCompileModel = OVClassBaseTestP;+TEST_P(OVClassCompileModel, CompileModelWithDifferentThreadNumbers) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core ie;+ ov::Any p;++ auto model = ov::test::utils::make_conv_pool_relu();+ OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(1)}}));++ OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(2)}}));++ OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(4)}}));++ EXPECT_ANY_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(-1)}}));+ OV_EXPECT_THROW(+ std::ignore = ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(-1)}}),+ ::ov::Exception,+ testing::HasSubstr("ov::compilation_num_threads must be positive int32 value"));+}++#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT++TEST_P(OVClassBasicTestPNPU, smoke_registerPluginsLibrariesUnicodePath) {+ ov::Core core = ov::test::utils::create_core();++ const std::vector<std::string> libs = {pluginName};++ for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) {+ GTEST_COUT << testIndex;+ std::string unicode_target_device = target_device + "_UNICODE_" + std::to_string(testIndex);+ std::wstring postfix = ov::test::utils::test_unicode_postfix_vector[testIndex];+ std::wstring unicode_path =+ ov::test::utils::stringToWString(ov::test::utils::getOpenvinoLibDirectory() + "/") + postfix;+ try {+# ifndef _WIN32+ std::filesystem::create_directory(ov::util::wstring_to_string(unicode_path));+# else+ std::filesystem::create_directory(unicode_path);+# endif+ std::string pluginNamePath =+ ov::util::make_plugin_library_name(ov::util::wstring_to_string(unicode_path), pluginName);++ for (auto&& lib : libs) {+ auto&& libPath = ov::test::utils::stringToWString(+ ov::util::make_plugin_library_name(ov::test::utils::getOpenvinoLibDirectory(), lib));+ auto&& libPathNew = ov::test::utils::stringToWString(+ ov::util::make_plugin_library_name(::ov::util::wstring_to_string(unicode_path), lib));+ bool is_copy_successfully = ov::test::utils::copyFile(libPath, libPathNew);+ if (!is_copy_successfully) {+ FAIL() << "Unable to copy from '" << libPath.c_str() << "' to '" << libPathNew.c_str() << "'";+ }+ }++ OV_ASSERT_NO_THROW(core.register_plugin(pluginNamePath, unicode_target_device));+ OV_ASSERT_NO_THROW(core.get_versions(unicode_target_device));+ auto devices = core.get_available_devices();+ if (std::find_if(devices.begin(), devices.end(), [&unicode_target_device](std::string device) {+ return device.find(unicode_target_device) != std::string::npos;+ }) == devices.end()) {+ FAIL() << unicode_target_device << " was not found within registered plugins.";+ }+ core.unload_plugin(unicode_target_device);+ } catch (const ov::Exception& e_next) {+ FAIL() << e_next.what();+ }+ }+}+#endif++static void checkLibrariesInProcessMemoryMap(bool checkExist) {+#ifdef __linux__+ std::unordered_map<const char*, bool> librariesFound = {+ /*+ TODO: uncomment when unloading driver and loader is fixed+ {"libnpu_driver_compiler.so", false},+ {"libze_intel_npu.so", false},+ {"libze_loader.so", false},+ */+ {"libopenvino_intel_npu_plugin.so", false},+ };+ std::ifstream file("/proc/self/maps");+ std::string line;+ while (!file.eof()) {+ std::getline(file, line);+ for (auto [library, _] : librariesFound) {+ if (strstr(line.c_str(), library)) {+ librariesFound[library] = true;+ break;+ }+ }+ }+ for (auto [library, found] : librariesFound) {+ if (checkExist) {+ EXPECT_TRUE(found) << "NPU related library (" << library << ") is not loaded";+ } else {+ EXPECT_FALSE(found) << "NPU related library (" << library << ") is still loaded";+ }+ }+#endif+}++TEST(OVClassBaseTestNPU, UnloadPlugin) {+ auto core = ov::test::utils::PluginCache::get().core();+ {+ auto model = ov::test::utils::make_conv_pool_relu();+ auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_NPU);+ auto req = compiled_model.create_infer_request();+ req.infer();+ }++ checkLibrariesInProcessMemoryMap(true);+ core->unload_plugin(ov::test::utils::DEVICE_NPU);+ checkLibrariesInProcessMemoryMap(false);++ // check if Core can load the plugin again and run the inference+ auto model = ov::test::utils::make_conv_pool_relu();+ auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_NPU);+ auto req = compiled_model.create_infer_request();+ req.infer();+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.hppdeleted file mode 100644index 6bd66687c92..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/core_integration.hpp+++ /dev/null@@ -1,558 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <filesystem>--#include "behavior/ov_plugin/properties_tests.hpp"-#include "common/functions.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/data_utils.hpp"-#include "common_test_utils/subgraph_builders/concat_with_params.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "common_test_utils/subgraph_builders/kso_func.hpp"-#include "common_test_utils/subgraph_builders/single_concat_with_constant.hpp"-#include "common_test_utils/subgraph_builders/split_conv_concat.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT-# include <iostream>-# define GTEST_COUT std::cerr << "[ ] [ INFO ] "-# include <codecvt>-# include <functional_test_utils/skip_tests_config.hpp>--# include "openvino/pass/manager.hpp"--#endif--namespace ov {-namespace test {-namespace behavior {--class OVClassBaseTestPNPU : public OVClassNetworkTest,- public testing::WithParamInterface<CompilationParams>,- public OVPluginTestBase {-protected:- ov::AnyMap configuration;- std::string deathTestStyle;- std::shared_ptr<ov::Model> function;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- std::tie(target_device, configuration) = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '.');-- std::ostringstream result;- result << "OVClassNetworkTestName_" << target_device;- result << "_targetDevice=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)- << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();- SKIP_IF_CURRENT_TEST_IS_DISABLED();- APIBaseTest::SetUp();- SKIP_IF_CURRENT_TEST_IS_DISABLED();- // Generic network- actualNetwork = ov::test::utils::make_split_conv_concat();- // Quite simple network- simpleNetwork = ov::test::utils::make_single_concat_with_constant();- // Multinput to substruct network- multinputNetwork = ov::test::utils::make_concat_with_params();- // Network with KSO- ksoNetwork = ov::test::utils::make_kso_function();-- ov::AnyMap params;- for (auto&& v : configuration) {- params.emplace(v.first, v.second);- }- }-- void TearDown() override {- ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }-};--class OVClassBasicTestPNPU : public OVBasicPropertiesTestsP {-public:- void TearDown() override {- for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) {- std::wstring postfix = ov::test::utils::test_unicode_postfix_vector[testIndex];- std::wstring unicode_path =- ov::test::utils::stringToWString(ov::util::path_to_string(ov::util::get_ov_lib_path()) + "/") + postfix;-#ifndef _WIN32- removeDirFilesRecursive(ov::util::wstring_to_string(unicode_path));-#else- removeDirFilesRecursive(unicode_path);-#endif- }- }-};--using OVClassNetworkTestPNPU = OVClassBaseTestPNPU;-using OVClassLoadNetworkTestNPU = OVClassBaseTestPNPU;--TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualNoThrow) {- ov::Core ie = ov::test::utils::create_core();- OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, target_device, configuration));-}--TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDeviceNoThrow) {- ov::Core ie = ov::test::utils::create_core();- OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,- ov::test::utils::DEVICE_HETERO + std::string(":") + target_device,- configuration));-}--TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDevice2NoThrow) {- ov::Core ie = ov::test::utils::create_core();-- OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,- ov::test::utils::DEVICE_HETERO,- ov::device::priorities(target_device),- ov::device::properties(target_device, configuration)));-}--TEST_P(OVClassNetworkTestPNPU, LoadNetworkActualHeteroDeviceUsingDevicePropertiesNoThrow) {- ov::Core ie = ov::test::utils::create_core();- configuration.emplace(ov::enable_profiling(true));-- OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork,- ov::test::utils::DEVICE_HETERO,- ov::device::priorities(target_device),- ov::device::properties(target_device, configuration)));-}--TEST_P(OVClassLoadNetworkTestNPU, LoadNetworkHETEROWithDeviceIDNoThrow) {- ov::Core ie = ov::test::utils::create_core();-- auto supported_properties = ie.get_property(target_device, ov::supported_properties);-- if (supported_properties.end() !=- std::find(std::begin(supported_properties), std::end(supported_properties), ov::device::id)) {- auto deviceIDs = ie.get_property(target_device, ov::available_devices);- if (deviceIDs.empty())- GTEST_FAIL();- std::string heteroDevice = ov::test::utils::DEVICE_HETERO + std::string(":") + target_device + "." +- deviceIDs[0] + "," + target_device;- OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, heteroDevice, configuration));- } else {- GTEST_FAIL() << "Device does not support DeviceID property" << std::endl;- }-}--TEST(compatibility_OVClassBasicPropsTestNPU, smoke_SetConfigDevicePropertiesThrows) {- ov::Core core;- ASSERT_THROW(core.set_property("", ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),- ov::Exception);- ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_NPU,- ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),- ov::Exception);- ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_AUTO,- ov::device::properties(ov::test::utils::DEVICE_NPU, ov::enable_profiling(true))),- ov::Exception);- ASSERT_THROW(core.set_property(ov::test::utils::DEVICE_AUTO,- ov::device::properties(ov::test::utils::DEVICE_NPU, ov::num_streams(4))),- ov::Exception);-}--//-// NPU specific metrics-//--using OVClassGetMetricAndPrintNoThrow = OVClassBaseTestP;-TEST_P(OVClassGetMetricAndPrintNoThrow, DeviceAllocMemSizeLesserThanTotalMemSizeNPU) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core ie;- ov::Any p;-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_total_mem_size.name()));- uint64_t t = p.as<uint64_t>();- ASSERT_NE(t, 0);-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t a = p.as<uint64_t>();-- ASSERT_LT(a, t);-- std::cout << "OV NPU device alloc/total memory size: " << a << "/" << t << std::endl;-}--TEST_P(OVClassGetMetricAndPrintNoThrow, DeviceAllocMemSizeLesserAfterModelIsLoadedNPU) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core ie;- ov::Any p;-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t a1 = p.as<uint64_t>();-- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- auto model = ov::test::utils::make_conv_pool_relu();- OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {}));- }-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t a2 = p.as<uint64_t>();-- std::cout << "OV NPU device {alloc before load network/alloc after load network} memory size: {" << a1 << "/" << a2- << "}" << std::endl;-- // after the network is loaded onto device, allocated memory value should increase- ASSERT_LE(a1, a2);-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeLesserAfterModelIsLoaded) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core ie;- ov::Any p;-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t a1 = p.as<uint64_t>();-- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- auto model = ov::test::utils::make_conv_pool_relu();- OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, ov::AnyMap{ov::log::level(ov::log::Level::ERR)}));- }-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t a2 = p.as<uint64_t>();-- std::cout << "OV NPU device {alloc before load network/alloc after load network} memory size: {" << a1 << "/" << a2- << "}" << std::endl;-- // after the network is loaded onto device, allocated memory value should increase- ASSERT_LE(a1, a2);-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyCompiledModel) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core core;- ov::Any deviceAllocMemSizeAny;-- auto model = createModelWithLargeSize();-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();- uint64_t deviceAllocMemSizeFinal;-- for (size_t i = 0; i < 10; ++i) {- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));-- compiledModel = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;- }-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyCompiledModelWithTurboAndSeqRun) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getCommandQueueDdiTable().version() >- ZE_MAKE_VERSION(1, 0)) {- ov::Core core;- ov::Any deviceAllocMemSizeAny;- ov::AnyMap configuration;-- configuration[intel_npu::turbo.name()] = true;- configuration[ov::intel_npu::run_inferences_sequentially.name()] = true;-- auto model = createModelWithLargeSize();-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();- uint64_t deviceAllocMemSizeFinal;-- for (size_t i = 0; i < 10; ++i) {- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device, configuration));-- compiledModel = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;- }- } else {- GTEST_SKIP() << "Test is skipped due to driver version";- }-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequest) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core core;- ov::Any deviceAllocMemSizeAny;-- ov::CompiledModel compiledModel;- auto model = createModelWithLargeSize();-- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));-- // After memory consumption updates, need to run first inference before measurements- auto inferRequest = compiledModel.create_infer_request();- inferRequest.infer();- inferRequest = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();- uint64_t deviceAllocMemSizeFinal;-- for (size_t i = 0; i < 10; ++i) {- inferRequest = compiledModel.create_infer_request();- inferRequest.infer();-- inferRequest = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;- }-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequestSetTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core core;- ov::Any deviceAllocMemSizeAny;-- ov::CompiledModel compiledModel;- auto model = createModelWithLargeSize();-- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));-- // After memory consumption updates, need to run first inference before measurements- auto inferRequest = compiledModel.create_infer_request();- inferRequest.infer();- inferRequest = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();- uint64_t deviceAllocMemSizeFinal;-- auto tensor = ov::Tensor(model->input(0).get_element_type(), model->input(0).get_shape());- ov::test::utils::fill_data_random(static_cast<ov::float16*>(tensor.data()), tensor.get_size());-- for (size_t i = 0; i < 10; ++i) {- auto inferRequest = compiledModel.create_infer_request();- inferRequest.set_input_tensor(tensor);- inferRequest.infer();-- inferRequest = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;- }-}--TEST_P(OVClassGetMetricAndPrintNoThrow, NpuDeviceAllocMemSizeSameAfterDestroyInferRequestGetTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core core;- ov::Any deviceAllocMemSizeAny;-- ov::CompiledModel compiledModel;- auto model = createModelWithLargeSize();-- // Warm up inference to initialize driver scratch buffers- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));- auto inferRequest = compiledModel.create_infer_request();- inferRequest.infer();- inferRequest = {};- compiledModel = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- uint64_t deviceAllocMemSize = deviceAllocMemSizeAny.as<uint64_t>();- uint64_t deviceAllocMemSizeFinal;-- for (size_t i = 0; i < 10; ++i) {- OV_ASSERT_NO_THROW(compiledModel = core.compile_model(model, target_device));-- auto inferRequest = compiledModel.create_infer_request();- auto tensor = inferRequest.get_output_tensor();- inferRequest.infer();-- inferRequest = {};- compiledModel = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_LT(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;-- tensor = {};-- OV_ASSERT_NO_THROW(deviceAllocMemSizeAny =- core.get_property(target_device, ov::intel_npu::device_alloc_mem_size.name()));- deviceAllocMemSizeFinal = deviceAllocMemSizeAny.as<uint64_t>();- ASSERT_EQ(deviceAllocMemSize, deviceAllocMemSizeFinal) << " at iteration " << i;- }-}--TEST_P(OVClassGetMetricAndPrintNoThrow, DriverVersionNPU) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core ie;- ov::Any p;-- OV_ASSERT_NO_THROW(p = ie.get_property(target_device, ov::intel_npu::driver_version.name()));- uint32_t t = p.as<uint32_t>();-- std::cout << "NPU driver version is " << t << std::endl;-- OV_ASSERT_PROPERTY_SUPPORTED(ov::intel_npu::driver_version.name());-}--using OVClassCompileModel = OVClassBaseTestP;-TEST_P(OVClassCompileModel, CompileModelWithDifferentThreadNumbers) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core ie;- ov::Any p;-- auto model = ov::test::utils::make_conv_pool_relu();- OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(1)}}));-- OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(2)}}));-- OV_ASSERT_NO_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(4)}}));-- EXPECT_ANY_THROW(ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(-1)}}));- OV_EXPECT_THROW(- std::ignore = ie.compile_model(model, target_device, {{ov::compilation_num_threads.name(), ov::Any(-1)}}),- ::ov::Exception,- testing::HasSubstr("ov::compilation_num_threads must be positive int32 value"));-}--#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT--TEST_P(OVClassBasicTestPNPU, smoke_registerPluginsLibrariesUnicodePath) {- ov::Core core = ov::test::utils::create_core();-- const std::vector<std::string> libs = {pluginName};-- for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) {- GTEST_COUT << testIndex;- std::string unicode_target_device = target_device + "_UNICODE_" + std::to_string(testIndex);- std::wstring postfix = ov::test::utils::test_unicode_postfix_vector[testIndex];- std::wstring unicode_path =- ov::test::utils::stringToWString(ov::test::utils::getOpenvinoLibDirectory() + "/") + postfix;- try {-# ifndef _WIN32- std::filesystem::create_directory(ov::util::wstring_to_string(unicode_path));-# else- std::filesystem::create_directory(unicode_path);-# endif- std::string pluginNamePath =- ov::util::make_plugin_library_name(ov::util::wstring_to_string(unicode_path), pluginName);-- for (auto&& lib : libs) {- auto&& libPath = ov::test::utils::stringToWString(- ov::util::make_plugin_library_name(ov::test::utils::getOpenvinoLibDirectory(), lib));- auto&& libPathNew = ov::test::utils::stringToWString(- ov::util::make_plugin_library_name(::ov::util::wstring_to_string(unicode_path), lib));- bool is_copy_successfully = ov::test::utils::copyFile(libPath, libPathNew);- if (!is_copy_successfully) {- FAIL() << "Unable to copy from '" << libPath.c_str() << "' to '" << libPathNew.c_str() << "'";- }- }-- OV_ASSERT_NO_THROW(core.register_plugin(pluginNamePath, unicode_target_device));- OV_ASSERT_NO_THROW(core.get_versions(unicode_target_device));- auto devices = core.get_available_devices();- if (std::find_if(devices.begin(), devices.end(), [&unicode_target_device](std::string device) {- return device.find(unicode_target_device) != std::string::npos;- }) == devices.end()) {- FAIL() << unicode_target_device << " was not found within registered plugins.";- }- core.unload_plugin(unicode_target_device);- } catch (const ov::Exception& e_next) {- FAIL() << e_next.what();- }- }-}-#endif--static void checkLibrariesInProcessMemoryMap(bool checkExist) {-#ifdef __linux__- std::unordered_map<const char*, bool> librariesFound = {- /*- TODO: uncomment when unloading driver and loader is fixed- {"libnpu_driver_compiler.so", false},- {"libze_intel_npu.so", false},- {"libze_loader.so", false},- */- {"libopenvino_intel_npu_plugin.so", false},- };- std::ifstream file("/proc/self/maps");- std::string line;- while (!file.eof()) {- std::getline(file, line);- for (auto [library, _] : librariesFound) {- if (strstr(line.c_str(), library)) {- librariesFound[library] = true;- break;- }- }- }- for (auto [library, found] : librariesFound) {- if (checkExist) {- EXPECT_TRUE(found) << "NPU related library (" << library << ") is not loaded";- } else {- EXPECT_FALSE(found) << "NPU related library (" << library << ") is still loaded";- }- }-#endif-}--TEST(OVClassBaseTestNPU, UnloadPlugin) {- auto core = ov::test::utils::PluginCache::get().core();- {- auto model = ov::test::utils::make_conv_pool_relu();- auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_NPU);- auto req = compiled_model.create_infer_request();- req.infer();- }-- checkLibrariesInProcessMemoryMap(true);- core->unload_plugin(ov::test::utils::DEVICE_NPU);- checkLibrariesInProcessMemoryMap(false);-- // check if Core can load the plugin again and run the inference- auto model = ov::test::utils::make_conv_pool_relu();- auto compiled_model = core->compile_model(model, ov::test::utils::DEVICE_NPU);- auto req = compiled_model.create_infer_request();- req.infer();-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.cppindex e15ca823ab6..1e4f470a6fd 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.cpp@@ -2,14 +2,53 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal_properties_tests.hpp"-#include <cstdlib>+#include "behavior/ov_plugin/properties_tests.hpp"#include "common/utils.hpp"+#include "common_test_utils/file_utils.hpp"+#include "common_test_utils/test_assertions.hpp"+#include "common_test_utils/unicode_utils.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "openvino/runtime/properties.hpp"#include "openvino/util/common_util.hpp"+#include "openvino/util/container_util.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov::test::behavior {++using PropertiesParamsNPU = std::tuple<std::string, AnyMap>;++class OVPropertiesTestsNPU : public testing::WithParamInterface<PropertiesParamsNPU>, public OVPropertiesBase {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<PropertiesParamsNPU>& obj);++ void SetUp() override;++ void TearDown() override;+};++using OVPropertiesIncorrectTestsNPU = OVPropertiesTestsNPU;++using OVPropertiesEnvVarTestsNPU = OVPropertiesTestsNPU;++using CompileModelPropertiesParamsNPU = std::tuple<std::string, AnyMap>;++class OVPropertiesTestsWithCompileModelPropsNPU : public testing::WithParamInterface<PropertiesParamsNPU>,+ public OVPropertiesBase {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<PropertiesParamsNPU>& obj);++ void SetUp() override;++ void TearDown() override;++ AnyMap compileModelProperties;+};++using OVCheckSetSupportedRWMetricsPropsTestsNPU = OVPropertiesTestsWithCompileModelPropsNPU;+} // namespace ov::test::behaviornamespace {diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.hppdeleted file mode 100644index da621424fba..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/internal_properties_tests.hpp+++ /dev/null@@ -1,47 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include "behavior/ov_plugin/properties_tests.hpp"-#include "common_test_utils/file_utils.hpp"-#include "common_test_utils/test_assertions.hpp"-#include "common_test_utils/unicode_utils.hpp"-#include "openvino/runtime/properties.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "openvino/util/container_util.hpp"--namespace ov::test::behavior {--using PropertiesParamsNPU = std::tuple<std::string, AnyMap>;--class OVPropertiesTestsNPU : public testing::WithParamInterface<PropertiesParamsNPU>, public OVPropertiesBase {-public:- static std::string getTestCaseName(const testing::TestParamInfo<PropertiesParamsNPU>& obj);-- void SetUp() override;-- void TearDown() override;-};--using OVPropertiesIncorrectTestsNPU = OVPropertiesTestsNPU;--using OVPropertiesEnvVarTestsNPU = OVPropertiesTestsNPU;--using CompileModelPropertiesParamsNPU = std::tuple<std::string, AnyMap>;--class OVPropertiesTestsWithCompileModelPropsNPU : public testing::WithParamInterface<PropertiesParamsNPU>,- public OVPropertiesBase {-public:- static std::string getTestCaseName(const testing::TestParamInfo<PropertiesParamsNPU>& obj);-- void SetUp() override;-- void TearDown() override;-- AnyMap compileModelProperties;-};--using OVCheckSetSupportedRWMetricsPropsTestsNPU = OVPropertiesTestsWithCompileModelPropsNPU;-} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.cppindex aa82197e0c2..a7b635e31bd 100644--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.cpp@@ -2,9 +2,289 @@// SPDX-License-Identifier: Apache-2.0//-#include "life_time.hpp"-+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "openvino/util/codec_xor.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {++class OVHoldersTestNPU : public OVPluginTestBase, public testing::WithParamInterface<CompilationParams> {+protected:+ ov::AnyMap configuration;+ std::string deathTestStyle;+ std::shared_ptr<ov::Model> function;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ std::tie(target_device, configuration) = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '.');++ std::ostringstream result;+ result << "target_device=" << target_device << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)+ << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();+ APIBaseTest::SetUp();+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ deathTestStyle = ::testing::GTEST_FLAG(death_test_style);+ if (deathTestStyle == "fast") {+ ::testing::GTEST_FLAG(death_test_style) = "threadsafe";+ }+ function = ov::test::utils::make_conv_pool_relu();+ }++ void TearDown() override {+ ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }+};++#define EXPECT_NO_CRASH(_statement) EXPECT_EXIT(_statement; exit(0), testing::ExitedWithCode(0), "")++static void release_order_test(std::vector<std::size_t> order,+ const std::string& deviceName,+ std::shared_ptr<ov::Model> function,+ ov::AnyMap configuration) {+ ov::AnyVector objects;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, deviceName, configuration);+ auto request = compiled_model.create_infer_request();++ objects = {core, compiled_model, request};+ }+ for (auto&& i : order) {+ objects.at(i) = {};+ }+}++#ifndef __EMSCRIPTEN__++TEST_P(OVHoldersTestNPU, Orders) {+ std::vector<std::string> objects{"core", "compiled_model", "request"};+ std::vector<std::size_t> order(objects.size());+ std::iota(order.begin(), order.end(), 0);+ do {+ std::stringstream order_str;+ for (auto&& i : order) {+ order_str << objects.at(i) << " ";+ }+ EXPECT_NO_CRASH(release_order_test(order, target_device, function, configuration))+ << "for order: " << order_str.str();+ } while (std::next_permutation(order.begin(), order.end()));+}++#endif // __EMSCRIPTEN__++TEST_P(OVHoldersTestNPU, LoadedState) {+ std::vector<ov::VariableState> states;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, target_device, configuration);+ auto request = compiled_model.create_infer_request();+ try {+ states = request.query_state();+ } catch (...) {+ }+ }+}++TEST_P(OVHoldersTestNPU, LoadedInferRequest) {+ ov::InferRequest inferRequest;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, target_device, configuration);+ inferRequest = compiled_model.create_infer_request();+ }+}++TEST_P(OVHoldersTestNPU, LoadedTensor) {+ ov::Tensor tensor;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, target_device, configuration);+ auto request = compiled_model.create_infer_request();+ tensor = request.get_input_tensor();+ }+}++TEST_P(OVHoldersTestNPU, LoadedAny) {+ ov::Any any;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, target_device, configuration);+ any = compiled_model.get_property(ov::supported_properties.name());+ }+}++TEST_P(OVHoldersTestNPU, LoadedRemoteContext) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::RemoteContext ctx;+ {+ ov::Core core = ov::test::utils::create_core();+ auto compiled_model = core.compile_model(function, target_device, configuration);+ try {+ ctx = compiled_model.get_context();+ } catch (...) {+ }+ }+}++TEST_P(OVHoldersTestNPU, CompileModelWithEncryptionWorksAfterConfigDeallocate) {+ // Encryption callbacks require L0 graph ext version >= 1.17+ NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);++ ov::CompiledModel compiled_model;+ {+ ov::AnyMap copy_configuration = configuration;+ copy_configuration.insert(+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));+ ov::Core core = ov::test::utils::create_core();+ compiled_model = core.compile_model(function, target_device, copy_configuration);+ }+ std::stringstream str;+ OV_ASSERT_NO_THROW(compiled_model.export_model(str));+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));+ OV_ASSERT_NO_THROW(ov::Core().import_model(str, target_device, configuration));+}++class OVHoldersTestOnImportedNetworkNPU : public OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ ov::AnyMap configuration;+ std::string deathTestStyle;+ std::shared_ptr<ov::Model> function;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ std::tie(target_device, configuration) = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '.');++ std::ostringstream result;+ result << "target_device=" << target_device << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)+ << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }+ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();+ APIBaseTest::SetUp();+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ deathTestStyle = ::testing::GTEST_FLAG(death_test_style);+ if (deathTestStyle == "fast") {+ ::testing::GTEST_FLAG(death_test_style) = "threadsafe";+ }+ function = ov::test::utils::make_conv_pool_relu();+ }+ void TearDown() override {+ ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }+ APIBaseTest::TearDown();+ }+};++TEST_P(OVHoldersTestOnImportedNetworkNPU, LoadedTensor) {+ ov::Core core = ov::test::utils::create_core();+ std::stringstream stream;+ {+ auto compiled_model = core.compile_model(function, target_device, configuration);+ compiled_model.export_model(stream);+ }+ auto compiled_model = core.import_model(stream, target_device, configuration);+ auto request = compiled_model.create_infer_request();+ ov::Tensor tensor = request.get_input_tensor();+}++TEST_P(OVHoldersTestOnImportedNetworkNPU, CreateRequestWithCoreRemoved) {+ ov::Core core = ov::test::utils::create_core();+ std::stringstream stream;+ {+ auto compiled_model = core.compile_model(function, target_device, configuration);+ compiled_model.export_model(stream);+ }+ auto compiled_model = core.import_model(stream, target_device, configuration);+ core = ov::Core{};+ auto request = compiled_model.create_infer_request();+}++TEST_P(OVHoldersTestOnImportedNetworkNPU, CanInferAfterTensorIsDestroyed) {+ ov::Core core = ov::test::utils::create_core();++ for (size_t i = 0; i < 2; ++i) {+ ov::CompiledModel compiled_model;+ if (i != 0) {+ configuration.emplace(ov::intel_npu::defer_weights_load(true));+ }+ {+ std::stringstream sstream;+ core.compile_model(function, target_device, configuration).export_model(sstream);++ const std::string& str = sstream.str();+ size_t size = str.size();+ ov::test::utils::DefaultAllocatorNotAligned default_allocator_not_aligned;+ auto tensor = ov::Tensor(ov::element::u8, ov::Shape{size}, default_allocator_not_aligned);+ std::memcpy(tensor.data(), str.data(), size);++ compiled_model = core.import_model(tensor, target_device, configuration);+ }++ // check if the shared object (strSO destroyed above) persists in compiled_model+ {+ std::ostringstream sstream;+ ov::InferRequest infer_request;+ if (i == 0 && std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getGraphDdiTable().version() >=+ ZE_MAKE_VERSION(1, 8)) { // older drivers will own the blob and not deallocate+ ASSERT_THROW(compiled_model.export_model(sstream), ov::Exception); // model was imported, not compiled+ } else {+ OV_ASSERT_NO_THROW(+ compiled_model.export_model(sstream)); // weights load deferred, blob still accessible+ EXPECT_TRUE(sstream.tellp() > 0);+ }+ OV_ASSERT_NO_THROW(infer_request = compiled_model.create_infer_request());+ compiled_model = {}; // dtor of compiled model won't affect created infer request+ OV_ASSERT_NO_THROW(infer_request.infer());+ }+ }+ configuration.erase(ov::intel_npu::defer_weights_load.name()); // cleanup+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hppdeleted file mode 100644index 97c7c1a20ba..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp+++ /dev/null@@ -1,290 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "life_time.hpp"-#include "openvino/util/codec_xor.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {--class OVHoldersTestNPU : public OVPluginTestBase, public testing::WithParamInterface<CompilationParams> {-protected:- ov::AnyMap configuration;- std::string deathTestStyle;- std::shared_ptr<ov::Model> function;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- std::tie(target_device, configuration) = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '.');-- std::ostringstream result;- result << "target_device=" << target_device << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)- << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();- APIBaseTest::SetUp();- SKIP_IF_CURRENT_TEST_IS_DISABLED();- deathTestStyle = ::testing::GTEST_FLAG(death_test_style);- if (deathTestStyle == "fast") {- ::testing::GTEST_FLAG(death_test_style) = "threadsafe";- }- function = ov::test::utils::make_conv_pool_relu();- }-- void TearDown() override {- ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }-};--#define EXPECT_NO_CRASH(_statement) EXPECT_EXIT(_statement; exit(0), testing::ExitedWithCode(0), "")--static void release_order_test(std::vector<std::size_t> order,- const std::string& deviceName,- std::shared_ptr<ov::Model> function,- ov::AnyMap configuration) {- ov::AnyVector objects;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, deviceName, configuration);- auto request = compiled_model.create_infer_request();-- objects = {core, compiled_model, request};- }- for (auto&& i : order) {- objects.at(i) = {};- }-}--#ifndef __EMSCRIPTEN__--TEST_P(OVHoldersTestNPU, Orders) {- std::vector<std::string> objects{"core", "compiled_model", "request"};- std::vector<std::size_t> order(objects.size());- std::iota(order.begin(), order.end(), 0);- do {- std::stringstream order_str;- for (auto&& i : order) {- order_str << objects.at(i) << " ";- }- EXPECT_NO_CRASH(release_order_test(order, target_device, function, configuration))- << "for order: " << order_str.str();- } while (std::next_permutation(order.begin(), order.end()));-}--#endif // __EMSCRIPTEN__--TEST_P(OVHoldersTestNPU, LoadedState) {- std::vector<ov::VariableState> states;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, target_device, configuration);- auto request = compiled_model.create_infer_request();- try {- states = request.query_state();- } catch (...) {- }- }-}--TEST_P(OVHoldersTestNPU, LoadedInferRequest) {- ov::InferRequest inferRequest;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, target_device, configuration);- inferRequest = compiled_model.create_infer_request();- }-}--TEST_P(OVHoldersTestNPU, LoadedTensor) {- ov::Tensor tensor;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, target_device, configuration);- auto request = compiled_model.create_infer_request();- tensor = request.get_input_tensor();- }-}--TEST_P(OVHoldersTestNPU, LoadedAny) {- ov::Any any;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, target_device, configuration);- any = compiled_model.get_property(ov::supported_properties.name());- }-}--TEST_P(OVHoldersTestNPU, LoadedRemoteContext) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::RemoteContext ctx;- {- ov::Core core = ov::test::utils::create_core();- auto compiled_model = core.compile_model(function, target_device, configuration);- try {- ctx = compiled_model.get_context();- } catch (...) {- }- }-}--TEST_P(OVHoldersTestNPU, CompileModelWithEncryptionWorksAfterConfigDeallocate) {- // Encryption callbacks require L0 graph ext version >= 1.17- NPU_SKIP_IF_GRAPH_EXT_LOWER_THAN(1, 17);-- ov::CompiledModel compiled_model;- {- ov::AnyMap copy_configuration = configuration;- copy_configuration.insert(- ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));- ov::Core core = ov::test::utils::create_core();- compiled_model = core.compile_model(function, target_device, copy_configuration);- }- std::stringstream str;- OV_ASSERT_NO_THROW(compiled_model.export_model(str));- configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));- OV_ASSERT_NO_THROW(ov::Core().import_model(str, target_device, configuration));-}--class OVHoldersTestOnImportedNetworkNPU : public OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- ov::AnyMap configuration;- std::string deathTestStyle;- std::shared_ptr<ov::Model> function;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- std::tie(target_device, configuration) = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '.');-- std::ostringstream result;- result << "target_device=" << target_device << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)- << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();- APIBaseTest::SetUp();- SKIP_IF_CURRENT_TEST_IS_DISABLED();- deathTestStyle = ::testing::GTEST_FLAG(death_test_style);- if (deathTestStyle == "fast") {- ::testing::GTEST_FLAG(death_test_style) = "threadsafe";- }- function = ov::test::utils::make_conv_pool_relu();- }- void TearDown() override {- ::testing::GTEST_FLAG(death_test_style) = deathTestStyle;- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }- APIBaseTest::TearDown();- }-};--TEST_P(OVHoldersTestOnImportedNetworkNPU, LoadedTensor) {- ov::Core core = ov::test::utils::create_core();- std::stringstream stream;- {- auto compiled_model = core.compile_model(function, target_device, configuration);- compiled_model.export_model(stream);- }- auto compiled_model = core.import_model(stream, target_device, configuration);- auto request = compiled_model.create_infer_request();- ov::Tensor tensor = request.get_input_tensor();-}--TEST_P(OVHoldersTestOnImportedNetworkNPU, CreateRequestWithCoreRemoved) {- ov::Core core = ov::test::utils::create_core();- std::stringstream stream;- {- auto compiled_model = core.compile_model(function, target_device, configuration);- compiled_model.export_model(stream);- }- auto compiled_model = core.import_model(stream, target_device, configuration);- core = ov::Core{};- auto request = compiled_model.create_infer_request();-}--TEST_P(OVHoldersTestOnImportedNetworkNPU, CanInferAfterTensorIsDestroyed) {- ov::Core core = ov::test::utils::create_core();-- for (size_t i = 0; i < 2; ++i) {- ov::CompiledModel compiled_model;- if (i != 0) {- configuration.emplace(ov::intel_npu::defer_weights_load(true));- }- {- std::stringstream sstream;- core.compile_model(function, target_device, configuration).export_model(sstream);-- const std::string& str = sstream.str();- size_t size = str.size();- ov::test::utils::DefaultAllocatorNotAligned default_allocator_not_aligned;- auto tensor = ov::Tensor(ov::element::u8, ov::Shape{size}, default_allocator_not_aligned);- std::memcpy(tensor.data(), str.data(), size);-- compiled_model = core.import_model(tensor, target_device, configuration);- }-- // check if the shared object (strSO destroyed above) persists in compiled_model- {- std::ostringstream sstream;- ov::InferRequest infer_request;- if (i == 0 && std::make_shared<::intel_npu::ZeroInitStructsHolder>()->getGraphDdiTable().version() >=- ZE_MAKE_VERSION(1, 8)) { // older drivers will own the blob and not deallocate- ASSERT_THROW(compiled_model.export_model(sstream), ov::Exception); // model was imported, not compiled- } else {- OV_ASSERT_NO_THROW(- compiled_model.export_model(sstream)); // weights load deferred, blob still accessible- EXPECT_TRUE(sstream.tellp() > 0);- }- OV_ASSERT_NO_THROW(infer_request = compiled_model.create_infer_request());- compiled_model = {}; // dtor of compiled model won't affect created infer request- OV_ASSERT_NO_THROW(infer_request.infer());- }- }- configuration.erase(ov::intel_npu::defer_weights_load.name()); // cleanup-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.cpp b/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.cppindex 363aa15fa59..798e1cb0258 100644--- a/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.cpp@@ -2,14 +2,60 @@// SPDX-License-Identifier: Apache-2.0//-#include "behavior/plugin_compiler_compile.hpp"+#include <cstring>+#include <string>+#include <vector>+#include "common/functions.hpp"+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"namespace {+class TestPluginCompilerCompilationNPU : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<std::tuple<std::string, ov::AnyMap>> {+public:+ void SetUp() override {+ std::tie(target_device, configuration) = GetParam();+ OVPluginTestBase::SetUp();+ }++ static std::string getTestCaseName(const testing::TestParamInfo<std::tuple<std::string, ov::AnyMap>>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');+ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ using namespace ov::test::utils;+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++protected:+ ov::AnyMap configuration;+ std::shared_ptr<ov::Core> core = ov::test::utils::PluginCache::get().core();+};++TEST_P(TestPluginCompilerCompilationNPU, compileWithDefaultCompilerConfig) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ const auto& model = buildSingleLayerSoftMaxNetwork();+ ov::CompiledModel compiledModel;+ OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));+ std::stringstream modelStream;+ OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));+ }+}+const std::vector<ov::AnyMap> configs = {{{"NPU_COMPILER_TYPE", "PLUGIN"}, {"NPU_PLATFORM", "NPU4000"}, {"NPU_CREATE_EXECUTOR", "0"}},{{"NPU_COMPILER_TYPE", "PLUGIN"}, {"NPU_PLATFORM", "NPU5010"}, {"NPU_CREATE_EXECUTOR", "0"}},diff --git a/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.hpp b/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.hppdeleted file mode 100644index ebb767c2a62..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/plugin_compiler_compile.hpp+++ /dev/null@@ -1,58 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <cstring>-#include <string>-#include <vector>--#include "common/functions.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace {--class TestPluginCompilerCompilationNPU : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<std::tuple<std::string, ov::AnyMap>> {-public:- void SetUp() override {- std::tie(target_device, configuration) = GetParam();- OVPluginTestBase::SetUp();- }-- static std::string getTestCaseName(const testing::TestParamInfo<std::tuple<std::string, ov::AnyMap>>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- using namespace ov::test::utils;- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }--protected:- ov::AnyMap configuration;- std::shared_ptr<ov::Core> core = ov::test::utils::PluginCache::get().core();-};--TEST_P(TestPluginCompilerCompilationNPU, compileWithDefaultCompilerConfig) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- const auto& model = buildSingleLayerSoftMaxNetwork();- ov::CompiledModel compiledModel;- OV_ASSERT_NO_THROW(compiledModel = core->compile_model(model, target_device, configuration));- std::stringstream modelStream;- OV_ASSERT_NO_THROW(compiledModel.export_model(modelStream));- }-}--} // namespacediff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.cppindex e8456902957..be9d8c000f7 100644--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.cpp@@ -2,11 +2,321 @@// SPDX-License-Identifier: Apache-2.0//-#include "dma_buf_remote_run.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"#include "intel_npu/config/options.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/memory_util.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"+#include "ov_infer_request/infer_request_dynamic_utils.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++#ifdef __linux__+# include <linux/version.h>+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)+# include <fcntl.h>+# include <linux/dma-heap.h>+# include <sys/ioctl.h>+# include <sys/mman.h>+# include <unistd.h>++# include <cstdint>+# include <cstring>+# include <filesystem>+# include <map>+# include <string>+# include <vector>++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {++// RAII owner of a DMA-BUF system-heap allocation: the heap device fd, the exported buffer fd and the+// mmap-ed CPU view of it. Construction either yields a fully mapped buffer or throws, so the object is+// never observable half-initialized.+class DmaHeapBuffer {+public:+ explicit DmaHeapBuffer(const size_t byte_size) : _byte_size(roundUpToPageSize(byte_size)) {+ if (!std::filesystem::exists(DEVICE_PATH)) {+ OPENVINO_THROW("Cannot open ", DEVICE_PATH, " file.");+ }++ _fd_dma_heap = open(DEVICE_PATH, O_RDWR);+ if (_fd_dma_heap == -1) {+ OPENVINO_THROW("Cannot open ", DEVICE_PATH, ".");+ }++ dma_heap_allocation_data heap_alloc = {+ .len = _byte_size, // the DMA heap only accepts page-aligned allocations+ .fd = 0,+ .fd_flags = O_RDWR | O_CLOEXEC,+ .heap_flags = 0,+ };+ if (ioctl(_fd_dma_heap, DMA_HEAP_IOCTL_ALLOC, &heap_alloc) != 0) {+ close(_fd_dma_heap);+ OPENVINO_THROW("Cannot initialize DMA heap.");+ }+ _fd = static_cast<int32_t>(heap_alloc.fd);++ _data = mmap(nullptr, _byte_size, PROT_WRITE | PROT_READ, MAP_SHARED, _fd, 0);+ if (_data == MAP_FAILED) {+ close(_fd);+ close(_fd_dma_heap);+ OPENVINO_THROW("mmap failed.");+ }+ }++ DmaHeapBuffer(const DmaHeapBuffer&) = delete;+ DmaHeapBuffer& operator=(const DmaHeapBuffer&) = delete;++ ~DmaHeapBuffer() {+ munmap(_data, _byte_size);+ close(_fd);+ close(_fd_dma_heap);+ }++ int32_t fd() const {+ return _fd;+ }++ void* data() const {+ return _data;+ }++private:+ static constexpr const char* DEVICE_PATH = "/dev/dma_heap/system";+ static constexpr size_t PAGE_ALIGNMENT = 4096;++ static size_t roundUpToPageSize(const size_t byte_size) {+ return (byte_size + PAGE_ALIGNMENT - 1) & ~(PAGE_ALIGNMENT - 1);+ }++ size_t _byte_size;+ int _fd_dma_heap = -1;+ int32_t _fd = -1;+ void* _data = nullptr;+};++class DmaBufRemoteRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDeviceNPU();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }+};++TEST_P(DmaBufRemoteRunTests, CheckRemoteTensorSharedBuf) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ DmaHeapBuffer buffer(byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), buffer.fd());++ ov::Tensor check_remote_tensor;+ ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(DmaBufRemoteRunTests, CheckRemoteTensorSharedBufChangingTensors) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ DmaHeapBuffer buffer(byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), buffer.fd());++ ov::Tensor check_remote_tensor;+ ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random input tensor+ std::vector<float> random_buffer_tensor(byte_size / sizeof(float));+ memset(random_buffer_tensor.data(), 1, byte_size);+ ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape(), random_buffer_tensor.data()};++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random output tensor+ auto output_tensor = inference_request.get_output_tensor();+ const auto output_byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(output_tensor.get_shape()));++ std::vector<float> output_random_buffer_tensor(output_byte_size / sizeof(float));+ memset(output_random_buffer_tensor.data(), 1, output_byte_size);+ ov::Tensor output_random_tensor_input{ov::element::f32,+ output_tensor.get_shape(),+ output_random_buffer_tensor.data()};++ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_random_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(DmaBufRemoteRunTests, CheckOutputDataFromMultipleRuns) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ const auto shape = tensor.get_shape();+ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));+ tensor = {};++ DmaHeapBuffer buffer(byte_size);+ memset(buffer.data(), 99, byte_size);++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ auto output_tensor = inference_request.get_output_tensor();+ const auto output_byte_size = output_tensor.get_byte_size();+ std::vector<float> output_data_one(output_byte_size / sizeof(float));+ ov::Tensor output_data_tensor_one{ov::element::f32, output_tensor.get_shape(), output_data_one.data()};++ auto remote_tensor = context.create_tensor(ov::element::f32, shape, buffer.fd());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_one));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // the same input data, this time passed through a host tensor, must yield the same output+ std::vector<float> output_data_two(output_byte_size / sizeof(float));+ ov::Tensor output_data_tensor_two{ov::element::f32, output_tensor.get_shape(), output_data_two.data()};++ std::vector<float> data(byte_size / sizeof(float));+ memset(data.data(), 99, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, shape, data.data()};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_two));+ OV_ASSERT_NO_THROW(inference_request.infer());++ EXPECT_NE(output_data_one.data(), output_data_two.data());+ EXPECT_EQ(memcmp(output_data_one.data(), output_data_two.data(), output_byte_size), 0);+}++// Runs a dynamically-shaped model with a DMA-BUF backed remote tensor as input. A distinct type -- not an+// alias -- so that gtest registers it as its own suite and it can be instantiated independently.+class DmaBufRemoteRunDynamicTests : public InferRequestDynamicTests {};++TEST_P(DmaBufRemoteRunDynamicTests, InferDynamicNetworkRemoteTensor) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ const std::string inputName = "Parameter_1";+ const std::string outputName = "Relu_2";++ std::map<std::string, ov::PartialShape> shapes;+ shapes[inputName] = {ov::Dimension(1, inOutShapes[1].first[0]),+ ov::Dimension(1, inOutShapes[1].first[1]),+ ov::Dimension(1, inOutShapes[1].first[2])};+ OV_ASSERT_NO_THROW(function->reshape(shapes));++ auto context = ie->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto compiled_model = ie->compile_model(function, target_device, configuration);++ // infer the same shape twice to exercise reuse of the compiled model across remote tensors+ const std::vector<ov::Shape> vectorShapes{inOutShapes[0].first, inOutShapes[0].first};+ for (auto& shape : vectorShapes) {+ ov::Tensor in_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));++ DmaHeapBuffer buffer(byte_size);+ memcpy(buffer.data(), in_tensor.data(), byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, shape, buffer.fd());++ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(req.set_tensor(inputName, remote_tensor));+ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(checkOutputFP16(in_tensor, req.get_tensor(outputName)));+ }+}++} // namespace behavior+} // namespace test+} // namespace ov++# endif+#endif#ifdef __linux__# include <linux/version.h>diff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.hppdeleted file mode 100644index 72c80931a5b..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dma_buf_remote_run.hpp+++ /dev/null@@ -1,320 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/ov_tensor_utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/memory_util.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"-#include "ov_infer_request/infer_request_dynamic_utils.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--#ifdef __linux__-# include <linux/version.h>-# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)-# include <fcntl.h>-# include <linux/dma-heap.h>-# include <sys/ioctl.h>-# include <sys/mman.h>-# include <unistd.h>--# include <cstdint>-# include <cstring>-# include <filesystem>-# include <map>-# include <string>-# include <vector>--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {--// RAII owner of a DMA-BUF system-heap allocation: the heap device fd, the exported buffer fd and the-// mmap-ed CPU view of it. Construction either yields a fully mapped buffer or throws, so the object is-// never observable half-initialized.-class DmaHeapBuffer {-public:- explicit DmaHeapBuffer(const size_t byte_size) : _byte_size(roundUpToPageSize(byte_size)) {- if (!std::filesystem::exists(DEVICE_PATH)) {- OPENVINO_THROW("Cannot open ", DEVICE_PATH, " file.");- }-- _fd_dma_heap = open(DEVICE_PATH, O_RDWR);- if (_fd_dma_heap == -1) {- OPENVINO_THROW("Cannot open ", DEVICE_PATH, ".");- }-- dma_heap_allocation_data heap_alloc = {- .len = _byte_size, // the DMA heap only accepts page-aligned allocations- .fd = 0,- .fd_flags = O_RDWR | O_CLOEXEC,- .heap_flags = 0,- };- if (ioctl(_fd_dma_heap, DMA_HEAP_IOCTL_ALLOC, &heap_alloc) != 0) {- close(_fd_dma_heap);- OPENVINO_THROW("Cannot initialize DMA heap.");- }- _fd = static_cast<int32_t>(heap_alloc.fd);-- _data = mmap(nullptr, _byte_size, PROT_WRITE | PROT_READ, MAP_SHARED, _fd, 0);- if (_data == MAP_FAILED) {- close(_fd);- close(_fd_dma_heap);- OPENVINO_THROW("mmap failed.");- }- }-- DmaHeapBuffer(const DmaHeapBuffer&) = delete;- DmaHeapBuffer& operator=(const DmaHeapBuffer&) = delete;-- ~DmaHeapBuffer() {- munmap(_data, _byte_size);- close(_fd);- close(_fd_dma_heap);- }-- int32_t fd() const {- return _fd;- }-- void* data() const {- return _data;- }--private:- static constexpr const char* DEVICE_PATH = "/dev/dma_heap/system";- static constexpr size_t PAGE_ALIGNMENT = 4096;-- static size_t roundUpToPageSize(const size_t byte_size) {- return (byte_size + PAGE_ALIGNMENT - 1) & ~(PAGE_ALIGNMENT - 1);- }-- size_t _byte_size;- int _fd_dma_heap = -1;- int32_t _fd = -1;- void* _data = nullptr;-};--class DmaBufRemoteRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDeviceNPU();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-};--TEST_P(DmaBufRemoteRunTests, CheckRemoteTensorSharedBuf) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- DmaHeapBuffer buffer(byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), buffer.fd());-- ov::Tensor check_remote_tensor;- ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(DmaBufRemoteRunTests, CheckRemoteTensorSharedBufChangingTensors) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- DmaHeapBuffer buffer(byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), buffer.fd());-- ov::Tensor check_remote_tensor;- ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random input tensor- std::vector<float> random_buffer_tensor(byte_size / sizeof(float));- memset(random_buffer_tensor.data(), 1, byte_size);- ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape(), random_buffer_tensor.data()};-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random output tensor- auto output_tensor = inference_request.get_output_tensor();- const auto output_byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(output_tensor.get_shape()));-- std::vector<float> output_random_buffer_tensor(output_byte_size / sizeof(float));- memset(output_random_buffer_tensor.data(), 1, output_byte_size);- ov::Tensor output_random_tensor_input{ov::element::f32,- output_tensor.get_shape(),- output_random_buffer_tensor.data()};-- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_random_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(DmaBufRemoteRunTests, CheckOutputDataFromMultipleRuns) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- const auto shape = tensor.get_shape();- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));- tensor = {};-- DmaHeapBuffer buffer(byte_size);- memset(buffer.data(), 99, byte_size);-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- auto output_tensor = inference_request.get_output_tensor();- const auto output_byte_size = output_tensor.get_byte_size();- std::vector<float> output_data_one(output_byte_size / sizeof(float));- ov::Tensor output_data_tensor_one{ov::element::f32, output_tensor.get_shape(), output_data_one.data()};-- auto remote_tensor = context.create_tensor(ov::element::f32, shape, buffer.fd());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_one));- OV_ASSERT_NO_THROW(inference_request.infer());-- // the same input data, this time passed through a host tensor, must yield the same output- std::vector<float> output_data_two(output_byte_size / sizeof(float));- ov::Tensor output_data_tensor_two{ov::element::f32, output_tensor.get_shape(), output_data_two.data()};-- std::vector<float> data(byte_size / sizeof(float));- memset(data.data(), 99, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, shape, data.data()};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_two));- OV_ASSERT_NO_THROW(inference_request.infer());-- EXPECT_NE(output_data_one.data(), output_data_two.data());- EXPECT_EQ(memcmp(output_data_one.data(), output_data_two.data(), output_byte_size), 0);-}--// Runs a dynamically-shaped model with a DMA-BUF backed remote tensor as input. A distinct type -- not an-// alias -- so that gtest registers it as its own suite and it can be instantiated independently.-class DmaBufRemoteRunDynamicTests : public InferRequestDynamicTests {};--TEST_P(DmaBufRemoteRunDynamicTests, InferDynamicNetworkRemoteTensor) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- const std::string inputName = "Parameter_1";- const std::string outputName = "Relu_2";-- std::map<std::string, ov::PartialShape> shapes;- shapes[inputName] = {ov::Dimension(1, inOutShapes[1].first[0]),- ov::Dimension(1, inOutShapes[1].first[1]),- ov::Dimension(1, inOutShapes[1].first[2])};- OV_ASSERT_NO_THROW(function->reshape(shapes));-- auto context = ie->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto compiled_model = ie->compile_model(function, target_device, configuration);-- // infer the same shape twice to exercise reuse of the compiled model across remote tensors- const std::vector<ov::Shape> vectorShapes{inOutShapes[0].first, inOutShapes[0].first};- for (auto& shape : vectorShapes) {- ov::Tensor in_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));-- DmaHeapBuffer buffer(byte_size);- memcpy(buffer.data(), in_tensor.data(), byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, shape, buffer.fd());-- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(req.set_tensor(inputName, remote_tensor));- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(checkOutputFP16(in_tensor, req.get_tensor(outputName)));- }-}--} // namespace behavior-} // namespace test-} // namespace ov--# endif-#endifdiff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.cppindex 64d129440d8..96bbb6eb55d 100644--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.cpp@@ -2,11 +2,389 @@// SPDX-License-Identifier: Apache-2.0//-#include "dx12_remote_run.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"#include "intel_npu/config/options.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/memory_util.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"+#include "ov_infer_request/infer_request_dynamic_utils.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++#ifdef _WIN32++# include <d3d12.h>+# include <wrl.h>++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {+class DX12SharedHeapHelper {+protected:+ Microsoft::WRL::ComPtr<ID3D12Device> device;+ Microsoft::WRL::ComPtr<ID3D12Heap> heap = nullptr;+ Microsoft::WRL::ComPtr<ID3D12Resource> placed_resources = nullptr;+ Microsoft::WRL::ComPtr<ID3D12Resource> comitted_resource;++ HANDLE shared_mem = nullptr;++ void createDevice() {+ auto res = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS(device.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "D3D12CreateDevice failed.";+ }++ void createHeap(const size_t byte_size) {+ const size_t size = (byte_size + (static_cast<size_t>(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) - 1)) &+ ~(static_cast<size_t>(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) - 1);++ D3D12_HEAP_DESC desc_heap{};+ desc_heap.SizeInBytes = size;+ desc_heap.Properties.Type = D3D12_HEAP_TYPE_CUSTOM;+ desc_heap.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE;+ desc_heap.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;+ desc_heap.Properties.CreationNodeMask = 1;+ desc_heap.Properties.VisibleNodeMask = 1;+ desc_heap.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;+ desc_heap.Flags = D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER | D3D12_HEAP_FLAG_SHARED;+ auto res = device->CreateHeap(&desc_heap, IID_PPV_ARGS(heap.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateHeap failed.";++ res = device->CreateSharedHandle(heap.Get(), nullptr, GENERIC_ALL, nullptr, &shared_mem);+ ASSERT_FALSE(FAILED(res)) << "CreateSharedHandle failed.";+ }++ void createPlacedResources(const size_t byte_size) {+ D3D12_RESOURCE_DESC desc_resource{};+ desc_resource.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;+ desc_resource.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;+ desc_resource.Width = byte_size;+ desc_resource.Height = 1;+ desc_resource.DepthOrArraySize = 1;+ desc_resource.MipLevels = 1;+ desc_resource.Format = DXGI_FORMAT_UNKNOWN;+ desc_resource.SampleDesc.Count = 1;+ desc_resource.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;+ desc_resource.Flags = D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;+ auto res = device->CreatePlacedResource(heap.Get(),+ 0,+ &desc_resource,+ D3D12_RESOURCE_STATE_UNORDERED_ACCESS,+ nullptr,+ IID_PPV_ARGS(placed_resources.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreatePlacedResource failed.";+ }++ void createComittedResources(const size_t byte_size) {+ D3D12_HEAP_PROPERTIES heap_properties{};+ heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD;+ heap_properties.CreationNodeMask = 1;+ heap_properties.VisibleNodeMask = 1;++ D3D12_RESOURCE_DESC resource_desc{};+ resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;+ resource_desc.Width = byte_size;+ resource_desc.Height = 1;+ resource_desc.DepthOrArraySize = 1;+ resource_desc.MipLevels = 1;+ resource_desc.SampleDesc.Count = 1;+ resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;++ auto res = device->CreateCommittedResource(&heap_properties,+ D3D12_HEAP_FLAG_NONE,+ &resource_desc,+ D3D12_RESOURCE_STATE_GENERIC_READ,+ nullptr,+ IID_PPV_ARGS(comitted_resource.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateCommittedResource failed.";+ }++ void createResources(const size_t byte_size) {+ createHeap(byte_size);+ createPlacedResources(byte_size);+ createComittedResources(byte_size);+ }++ void copyResources(const size_t byte_size) {+ Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue;+ Microsoft::WRL::ComPtr<ID3D12CommandAllocator> command_allocator;+ Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList4> command_list;+ Microsoft::WRL::ComPtr<ID3D12Fence> fence;+ uint32_t fence_value = 0;++ D3D12_COMMAND_QUEUE_DESC desc{};+ desc.Type = D3D12_COMMAND_LIST_TYPE_COMPUTE;+ desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;+ desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;+ desc.NodeMask = 0;+ auto res = device->CreateCommandQueue(&desc, IID_PPV_ARGS(command_queue.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateCommandQueue failed.";++ res = device->CreateFence(0, D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(fence.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateFence failed.";++ res = device.Get()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COMPUTE,+ IID_PPV_ARGS(command_allocator.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateCommandAllocator failed.";++ res = device->CreateCommandList(0,+ D3D12_COMMAND_LIST_TYPE_COMPUTE,+ command_allocator.Get(),+ nullptr,+ IID_PPV_ARGS(command_list.ReleaseAndGetAddressOf()));+ ASSERT_FALSE(FAILED(res)) << "CreateCommandList failed.";++ command_list->CopyBufferRegion(placed_resources.Get(), 0, comitted_resource.Get(), 0, byte_size);+ res = command_list->Close();+ ASSERT_FALSE(FAILED(res)) << "Close command list failed.";++ ID3D12CommandList* command_lists[] = {command_list.Get()};+ command_queue->ExecuteCommandLists(ARRAYSIZE(command_lists), command_lists);+ res = command_queue->Signal(fence.Get(), ++fence_value);+ ASSERT_FALSE(FAILED(res)) << "Signal command queue failed.";++ volatile auto event = CreateEvent(nullptr, FALSE, FALSE, nullptr);+ res = fence->SetEventOnCompletion(fence_value, event);+ ASSERT_FALSE(FAILED(res)) << "SetEventOnCompletion failed.";+ WaitForSingleObject(event, INFINITE);+ }+};++class DX12RemoteRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams>,+ protected DX12SharedHeapHelper {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ std::tie(target_device, configuration) = this->GetParam();++ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDeviceNPU();++ createDevice();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }+};++TEST_P(DX12RemoteRunTests, CheckRemoteTensorSharedBuf) {+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ createHeap(byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), shared_mem);++ ov::Tensor check_remote_tensor;+ ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(DX12RemoteRunTests, CheckRemoteTensorSharedBufChangingTensors) {+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ createHeap(byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), shared_mem);++ ov::Tensor check_remote_tensor;+ ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random input tensor+ float* random_buffer_tensor = new float[byte_size / sizeof(float)];+ memset(random_buffer_tensor, 1, byte_size);+ ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape(), random_buffer_tensor};++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random output tensor+ auto output_tensor = inference_request.get_output_tensor();+ const auto output_byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(output_tensor.get_shape()));++ float* output_random_buffer_tensor = new float[output_byte_size / sizeof(float)];+ memset(output_random_buffer_tensor, 1, output_byte_size);+ ov::Tensor outputrandom_tensor_input{ov::element::f32, output_tensor.get_shape(), output_random_buffer_tensor};++ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(outputrandom_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ delete[] random_buffer_tensor;+ delete[] output_random_buffer_tensor;+}++TEST_P(DX12RemoteRunTests, CheckOutputDataFromMultipleRuns) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ float* data;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ auto shape = tensor.get_shape();+ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));+ tensor = {};++ createResources(byte_size);+ void* mem;+ comitted_resource.Get()->Map(0, nullptr, &mem);+ memset(mem, 99, byte_size);+ comitted_resource.Get()->Unmap(0, nullptr);+ copyResources(byte_size);++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ auto output_tensor = inference_request.get_output_tensor();+ const auto output_byte_size = output_tensor.get_byte_size();+ float* output_data_one = new float[output_byte_size / sizeof(float)];+ ov::Tensor output_data_tensor_one{ov::element::f32, output_tensor.get_shape(), output_data_one};++ auto remote_tensor = context.create_tensor(ov::element::f32, shape, shared_mem);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_one));+ OV_ASSERT_NO_THROW(inference_request.infer());++ float* output_data_two = new float[output_byte_size / sizeof(float)];+ ov::Tensor output_data_tensor_two{ov::element::f32, output_tensor.get_shape(), output_data_two};++ data = new float[byte_size / sizeof(float)];+ memset(data, 99, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, shape, data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_two));+ OV_ASSERT_NO_THROW(inference_request.infer());++ delete[] data;++ EXPECT_NE(output_data_one, output_data_two);+ EXPECT_EQ(memcmp(output_data_one, output_data_two, output_byte_size), 0);++ delete[] output_data_one;+ delete[] output_data_two;+}++// Runs a dynamically-shaped model with a DX12-shared-heap backed remote tensor as input.+class DX12RemoteRunDynamicTests : public InferRequestDynamicTests, protected DX12SharedHeapHelper {+protected:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ InferRequestDynamicTests::SetUp();+ createDevice();+ }+};++TEST_P(DX12RemoteRunDynamicTests, InferDynamicNetworkRemoteTensor) {+ const std::string inputName = "Parameter_1";+ const std::string outputName = "Relu_2";++ std::map<std::string, ov::PartialShape> shapes;+ shapes[inputName] = {ov::Dimension(1, inOutShapes[1].first[0]),+ ov::Dimension(1, inOutShapes[1].first[1]),+ ov::Dimension(1, inOutShapes[1].first[2])};+ OV_ASSERT_NO_THROW(function->reshape(shapes));++ auto context = ie->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto compiled_model = ie->compile_model(function, target_device, configuration);++ // infer the same shape twice to exercise reuse of the compiled model across remote tensors+ const std::vector<ov::Shape> vectorShapes{inOutShapes[0].first, inOutShapes[0].first};+ for (auto& shape : vectorShapes) {+ ov::Tensor in_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);++ const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));++ createResources(byte_size);+ void* mem = nullptr;+ auto res = comitted_resource->Map(0, nullptr, &mem);+ ASSERT_FALSE(FAILED(res)) << "Map failed.";+ memcpy(mem, in_tensor.data(), byte_size);+ comitted_resource->Unmap(0, nullptr);+ copyResources(byte_size);++ auto remote_tensor = context.create_tensor(ov::element::f32, shape, shared_mem);++ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(req.set_tensor(inputName, remote_tensor));+ OV_ASSERT_NO_THROW(req.infer());+ OV_ASSERT_NO_THROW(checkOutputFP16(in_tensor, req.get_tensor(outputName)));+ }+}++} // namespace behavior+} // namespace test+} // namespace ov++#endif#ifdef _WIN32diff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.hppdeleted file mode 100644index 3df8f6daf1e..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/dx12_remote_run.hpp+++ /dev/null@@ -1,388 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common_test_utils/ov_tensor_utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/memory_util.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"-#include "ov_infer_request/infer_request_dynamic_utils.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--#ifdef _WIN32--# include <d3d12.h>-# include <wrl.h>--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {-class DX12SharedHeapHelper {-protected:- Microsoft::WRL::ComPtr<ID3D12Device> device;- Microsoft::WRL::ComPtr<ID3D12Heap> heap = nullptr;- Microsoft::WRL::ComPtr<ID3D12Resource> placed_resources = nullptr;- Microsoft::WRL::ComPtr<ID3D12Resource> comitted_resource;-- HANDLE shared_mem = nullptr;-- void createDevice() {- auto res = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS(device.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "D3D12CreateDevice failed.";- }-- void createHeap(const size_t byte_size) {- const size_t size = (byte_size + (static_cast<size_t>(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) - 1)) &- ~(static_cast<size_t>(D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) - 1);-- D3D12_HEAP_DESC desc_heap{};- desc_heap.SizeInBytes = size;- desc_heap.Properties.Type = D3D12_HEAP_TYPE_CUSTOM;- desc_heap.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE;- desc_heap.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_L0;- desc_heap.Properties.CreationNodeMask = 1;- desc_heap.Properties.VisibleNodeMask = 1;- desc_heap.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;- desc_heap.Flags = D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER | D3D12_HEAP_FLAG_SHARED;- auto res = device->CreateHeap(&desc_heap, IID_PPV_ARGS(heap.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateHeap failed.";-- res = device->CreateSharedHandle(heap.Get(), nullptr, GENERIC_ALL, nullptr, &shared_mem);- ASSERT_FALSE(FAILED(res)) << "CreateSharedHandle failed.";- }-- void createPlacedResources(const size_t byte_size) {- D3D12_RESOURCE_DESC desc_resource{};- desc_resource.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;- desc_resource.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT;- desc_resource.Width = byte_size;- desc_resource.Height = 1;- desc_resource.DepthOrArraySize = 1;- desc_resource.MipLevels = 1;- desc_resource.Format = DXGI_FORMAT_UNKNOWN;- desc_resource.SampleDesc.Count = 1;- desc_resource.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;- desc_resource.Flags = D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER | D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;- auto res = device->CreatePlacedResource(heap.Get(),- 0,- &desc_resource,- D3D12_RESOURCE_STATE_UNORDERED_ACCESS,- nullptr,- IID_PPV_ARGS(placed_resources.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreatePlacedResource failed.";- }-- void createComittedResources(const size_t byte_size) {- D3D12_HEAP_PROPERTIES heap_properties{};- heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD;- heap_properties.CreationNodeMask = 1;- heap_properties.VisibleNodeMask = 1;-- D3D12_RESOURCE_DESC resource_desc{};- resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;- resource_desc.Width = byte_size;- resource_desc.Height = 1;- resource_desc.DepthOrArraySize = 1;- resource_desc.MipLevels = 1;- resource_desc.SampleDesc.Count = 1;- resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;-- auto res = device->CreateCommittedResource(&heap_properties,- D3D12_HEAP_FLAG_NONE,- &resource_desc,- D3D12_RESOURCE_STATE_GENERIC_READ,- nullptr,- IID_PPV_ARGS(comitted_resource.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateCommittedResource failed.";- }-- void createResources(const size_t byte_size) {- createHeap(byte_size);- createPlacedResources(byte_size);- createComittedResources(byte_size);- }-- void copyResources(const size_t byte_size) {- Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue;- Microsoft::WRL::ComPtr<ID3D12CommandAllocator> command_allocator;- Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList4> command_list;- Microsoft::WRL::ComPtr<ID3D12Fence> fence;- uint32_t fence_value = 0;-- D3D12_COMMAND_QUEUE_DESC desc{};- desc.Type = D3D12_COMMAND_LIST_TYPE_COMPUTE;- desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;- desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;- desc.NodeMask = 0;- auto res = device->CreateCommandQueue(&desc, IID_PPV_ARGS(command_queue.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateCommandQueue failed.";-- res = device->CreateFence(0, D3D12_FENCE_FLAG_SHARED, IID_PPV_ARGS(fence.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateFence failed.";-- res = device.Get()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_COMPUTE,- IID_PPV_ARGS(command_allocator.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateCommandAllocator failed.";-- res = device->CreateCommandList(0,- D3D12_COMMAND_LIST_TYPE_COMPUTE,- command_allocator.Get(),- nullptr,- IID_PPV_ARGS(command_list.ReleaseAndGetAddressOf()));- ASSERT_FALSE(FAILED(res)) << "CreateCommandList failed.";-- command_list->CopyBufferRegion(placed_resources.Get(), 0, comitted_resource.Get(), 0, byte_size);- res = command_list->Close();- ASSERT_FALSE(FAILED(res)) << "Close command list failed.";-- ID3D12CommandList* command_lists[] = {command_list.Get()};- command_queue->ExecuteCommandLists(ARRAYSIZE(command_lists), command_lists);- res = command_queue->Signal(fence.Get(), ++fence_value);- ASSERT_FALSE(FAILED(res)) << "Signal command queue failed.";-- volatile auto event = CreateEvent(nullptr, FALSE, FALSE, nullptr);- res = fence->SetEventOnCompletion(fence_value, event);- ASSERT_FALSE(FAILED(res)) << "SetEventOnCompletion failed.";- WaitForSingleObject(event, INFINITE);- }-};--class DX12RemoteRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams>,- protected DX12SharedHeapHelper {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- std::tie(target_device, configuration) = this->GetParam();-- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDeviceNPU();-- createDevice();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-};--TEST_P(DX12RemoteRunTests, CheckRemoteTensorSharedBuf) {- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- createHeap(byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), shared_mem);-- ov::Tensor check_remote_tensor;- ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(DX12RemoteRunTests, CheckRemoteTensorSharedBufChangingTensors) {- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(tensor.get_shape()));-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- createHeap(byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), shared_mem);-- ov::Tensor check_remote_tensor;- ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random input tensor- float* random_buffer_tensor = new float[byte_size / sizeof(float)];- memset(random_buffer_tensor, 1, byte_size);- ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape(), random_buffer_tensor};-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random output tensor- auto output_tensor = inference_request.get_output_tensor();- const auto output_byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(output_tensor.get_shape()));-- float* output_random_buffer_tensor = new float[output_byte_size / sizeof(float)];- memset(output_random_buffer_tensor, 1, output_byte_size);- ov::Tensor outputrandom_tensor_input{ov::element::f32, output_tensor.get_shape(), output_random_buffer_tensor};-- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(outputrandom_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-- delete[] random_buffer_tensor;- delete[] output_random_buffer_tensor;-}--TEST_P(DX12RemoteRunTests, CheckOutputDataFromMultipleRuns) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- float* data;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- auto shape = tensor.get_shape();- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));- tensor = {};-- createResources(byte_size);- void* mem;- comitted_resource.Get()->Map(0, nullptr, &mem);- memset(mem, 99, byte_size);- comitted_resource.Get()->Unmap(0, nullptr);- copyResources(byte_size);-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- auto output_tensor = inference_request.get_output_tensor();- const auto output_byte_size = output_tensor.get_byte_size();- float* output_data_one = new float[output_byte_size / sizeof(float)];- ov::Tensor output_data_tensor_one{ov::element::f32, output_tensor.get_shape(), output_data_one};-- auto remote_tensor = context.create_tensor(ov::element::f32, shape, shared_mem);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_one));- OV_ASSERT_NO_THROW(inference_request.infer());-- float* output_data_two = new float[output_byte_size / sizeof(float)];- ov::Tensor output_data_tensor_two{ov::element::f32, output_tensor.get_shape(), output_data_two};-- data = new float[byte_size / sizeof(float)];- memset(data, 99, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, shape, data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_data_tensor_two));- OV_ASSERT_NO_THROW(inference_request.infer());-- delete[] data;-- EXPECT_NE(output_data_one, output_data_two);- EXPECT_EQ(memcmp(output_data_one, output_data_two, output_byte_size), 0);-- delete[] output_data_one;- delete[] output_data_two;-}--// Runs a dynamically-shaped model with a DX12-shared-heap backed remote tensor as input.-class DX12RemoteRunDynamicTests : public InferRequestDynamicTests, protected DX12SharedHeapHelper {-protected:- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- InferRequestDynamicTests::SetUp();- createDevice();- }-};--TEST_P(DX12RemoteRunDynamicTests, InferDynamicNetworkRemoteTensor) {- const std::string inputName = "Parameter_1";- const std::string outputName = "Relu_2";-- std::map<std::string, ov::PartialShape> shapes;- shapes[inputName] = {ov::Dimension(1, inOutShapes[1].first[0]),- ov::Dimension(1, inOutShapes[1].first[1]),- ov::Dimension(1, inOutShapes[1].first[2])};- OV_ASSERT_NO_THROW(function->reshape(shapes));-- auto context = ie->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto compiled_model = ie->compile_model(function, target_device, configuration);-- // infer the same shape twice to exercise reuse of the compiled model across remote tensors- const std::vector<ov::Shape> vectorShapes{inOutShapes[0].first, inOutShapes[0].first};- for (auto& shape : vectorShapes) {- ov::Tensor in_tensor = ov::test::utils::create_and_fill_tensor(ov::element::f32, shape, 100, 0);-- const auto byte_size = ov::util::get_memory_size(ov::element::f32, shape_size(shape));-- createResources(byte_size);- void* mem = nullptr;- auto res = comitted_resource->Map(0, nullptr, &mem);- ASSERT_FALSE(FAILED(res)) << "Map failed.";- memcpy(mem, in_tensor.data(), byte_size);- comitted_resource->Unmap(0, nullptr);- copyResources(byte_size);-- auto remote_tensor = context.create_tensor(ov::element::f32, shape, shared_mem);-- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(req.set_tensor(inputName, remote_tensor));- OV_ASSERT_NO_THROW(req.infer());- OV_ASSERT_NO_THROW(checkOutputFP16(in_tensor, req.get_tensor(outputName)));- }-}--} // namespace behavior-} // namespace test-} // namespace ov--#endifdiff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.cpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.cppindex ad0807e60aa..067916b5a01 100644--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.cpp@@ -2,7 +2,1575 @@// SPDX-License-Identifier: Apache-2.0//-#include "remote_run.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>++#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_remote_tensor.hpp"+#include "openvino/core/any.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "remote_context.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "zero_backend.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++namespace ov {+namespace test {+namespace behavior {+class RemoteRunTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> ov_model;++ std::string m_cache_dir;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555+ }++ std::string generateCacheDirName(const std::string& test_name) {+ using namespace std::chrono;+ // Generate unique file names based on test name, thread id and timestamp+ // This allows execution of tests in parallel (stress mode)+ auto hash = std::to_string(std::hash<std::string>()(test_name));+ std::stringstream ss;+ auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());+ ss << hash << "_" << "_" << ts.count();+ return ss.str();+ }++ void TearDown() override {+ if (!m_cache_dir.empty()) {+ core->set_property({ov::cache_dir()});+ core.reset();+ ov::test::utils::PluginCache::get().reset();+ ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");+ ov::test::utils::removeDir(m_cache_dir);+ }++ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }++ std::shared_ptr<ov::Model> createModel(element::Type type, const PartialShape& shape, const ov::Layout& layout) {+ ResultVector res;+ ParameterVector params;++ auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);+ data1->set_friendly_name("input");+ data1->get_output_tensor(0).set_names({"tensor_input"});+ data1->set_layout(layout);+ auto constant = opset8::Constant::create(type, {1}, {1});+ auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);+ op1->set_friendly_name("Add");+ auto res1 = std::make_shared<ov::op::v0::Result>(op1);+ res1->set_friendly_name("Result");+ res1->get_output_tensor(0).set_names({"tensor_output"});+ params.push_back(data1);+ res.push_back(res1);++ return std::make_shared<Model>(res, params);+ }+};++TEST_P(RemoteRunTests, CheckIsContinuousHostTensorScalar) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_context = core->get_default_context(target_device);++ auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{});+ auto data = host_tensor.data();+ auto strides = host_tensor.get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(ov::element::f32, ov::Shape{}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(RemoteRunTests, CheckIsContinuousHostTensor1Dimension) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_context = core->get_default_context(target_device);++ auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{128});+ auto data = host_tensor.data();+ auto strides = host_tensor.get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(ov::element::f32, ov::Shape{128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, ov::Shape{16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(RemoteRunTests, CheckIsContinuousHostTensor2Dimensions) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_context = core->get_default_context(target_device);++ auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{32, 128});+ auto data = host_tensor.data();+ auto strides = host_tensor.get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(ov::element::f32, Shape{16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);+}++TEST_P(RemoteRunTests, CheckIsContinuousHostTensor3Dimensions) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_context = core->get_default_context(target_device);++ auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{5, 32, 128});+ auto data = host_tensor.data();+ auto strides = host_tensor.get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 64}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(RemoteRunTests, CheckIsContinuousHostTensor4Dimensions) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_context = core->get_default_context(target_device);++ auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 5, 32, 128});+ auto data = host_tensor.data();+ auto strides = host_tensor.get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 5, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 2, 5, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(ov::element::f32, Shape{3, 5, 32, 64}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{2, 1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 1, 32}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(RemoteRunTests, CheckRemoteTensorInternalBuf) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::InferRequest inference_request;+ ov::CompiledModel compiled_model;++ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, zero_context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto tensor = inference_request.get_input_tensor();++ auto remote_tensor =+ zero_context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);+ tensor = {};++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(RemoteRunTests, CheckRemoteTensorImportFile0) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ const std::string filename = "CheckRemoteTensorImportFile0.bin";+ std::vector<float> data(shape_size, 5.0f);++ {+ std::ofstream out(filename, std::ios::binary);+ out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));+ out.close();+ }++ ov::InferRequest inference_request;+ ov::CompiledModel compiled_model;++ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, zero_context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto remote_tensor = zero_context.create_tensor(ov::element::f32, shape, ov::intel_npu::FileDescriptor{filename});++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_output_tensor();+ float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ // destroy inference request and remote tensor to ensure that the file is closed+ inference_request = {};+ check_remote_tensor = {};+ remote_tensor = {};++ std::filesystem::remove(filename);+}++TEST_P(RemoteRunTests, CheckRemoteTensorImportFile1) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ const std::string filename = "CheckRemoteTensorImportFile1.bin";+ std::vector<float> data(shape_size, 5.0f);++ {+ std::ofstream out(filename, std::ios::binary);+ out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));+ out.close();+ }++ ov::InferRequest inference_request;+ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},+ {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto remote_tensor = context.create_tensor(ov::element::f32, shape, params);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_output_tensor();+ float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ // destroy inference request and remote tensor to ensure that the file is closed+ inference_request = {};+ remote_tensor = {};++ std::filesystem::remove(filename);+}++TEST_P(RemoteRunTests, CheckRemoteTensorImportFile2) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ const std::string filename = "CheckRemoteTensorImportFile2.bin";+ std::vector<float> data(shape_size, 5.0f);++ {+ std::ofstream out(filename, std::ios::binary);+ out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));+ out.close();+ }++ ov::InferRequest inference_request;+ ov::CompiledModel compiled_model;++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},+ {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, params);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto remote_tensor = context.create_tensor(ov::element::f32, shape);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_output_tensor();+ float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ // destroy inference request and remote tensor to ensure that the file is closed+ inference_request = {};+ remote_tensor = {};++ std::filesystem::remove(filename);+}++TEST_P(RemoteRunTests, CheckRemoteTensorImportFile3) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 5, 5, 5};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ const std::string filename = "CheckRemoteTensorImportFile3.bin";+ std::vector<float> data(shape_size, 5.0f);++ {+ std::ofstream out(filename, std::ios::binary);+ out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));+ out.close();+ }++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},+ {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, params);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto remote_tensor = context.create_tensor(ov::element::f32, shape);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_output_tensor();+ float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ // destroy inference request and remote tensor to ensure that the file is closed+ inference_request = {};+ remote_tensor = {};++ std::filesystem::remove(filename);+}++TEST_P(RemoteRunTests, TryImportCpuVAExpectedErrorUnalignedSize) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 64};+ auto shape_size = ov::shape_size(shape);++ auto data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));+ for (size_t i = 0; i < shape_size; ++i) {+ static_cast<float*>(data)[i] = 5.f;+ }++ auto context = core->get_default_context(target_device);++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},+ {ov::intel_npu::mem_handle.name(), data}};+ ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, shape, params), std::exception);++ ::operator delete(data, std::align_val_t(4096));+ } else {+ GTEST_SKIP() << "Standard allocation is not supported by the driver";+ }+}++TEST_P(RemoteRunTests, TryImportCpuVAExpectedErrorUnalignedAddress) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 1024};+ auto shape_size = ov::shape_size(shape);++ auto data = ::operator new(shape_size * sizeof(float) + 64, std::align_val_t(4096));+ auto unaligned_data = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(data) + 64);+ for (size_t i = 0; i < shape_size; ++i) {+ static_cast<float*>(unaligned_data)[i] = 5.f;+ }++ auto context = core->get_default_context(target_device);++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},+ {ov::intel_npu::mem_handle.name(), unaligned_data}};+ ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, shape, params), std::exception);++ ::operator delete(data, std::align_val_t(4096));+ } else {+ GTEST_SKIP() << "Standard allocation is not supported by the driver";+ }+}++TEST_P(RemoteRunTests, ImportCpuVAUsingNpuRemoteTensorAPI) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 1024};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ auto input_data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));+ auto output_data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));+ for (size_t i = 0; i < shape_size; ++i) {+ static_cast<float*>(input_data)[i] = 5.f;+ }++ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ ov::intel_npu::level_zero::ZeroBufferTensor input_remote_tensor, output_remote_tensor;+ OV_ASSERT_NO_THROW(input_remote_tensor = zero_context.create_tensor(ov::element::f32,+ shape,+ input_data,+ ov::intel_npu::MemType::CPU_VA,+ ov::intel_npu::TensorType::INPUT));++ OV_ASSERT_NO_THROW(output_remote_tensor = zero_context.create_tensor(ov::element::f32,+ shape,+ output_data,+ ov::intel_npu::MemType::CPU_VA,+ ov::intel_npu::TensorType::OUTPUT));++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ float* output_tensor_data = reinterpret_cast<float*>(output_remote_tensor.get());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_remote_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ inference_request = {};+ input_remote_tensor = {};+ output_remote_tensor = {};++ ::operator delete(input_data, std::align_val_t(4096));+ ::operator delete(output_data, std::align_val_t(4096));+ } else {+ GTEST_SKIP() << "Standard allocation is not supported by the driver";+ }+}++TEST_P(RemoteRunTests, ImportCpuVAUwithoutSettingBufferExpectedError) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ auto shape = Shape{1, 1024};++ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ ov::intel_npu::level_zero::ZeroBufferTensor remote_tensor;+ ASSERT_THROW(+ remote_tensor = zero_context.create_tensor(ov::element::f32, shape, nullptr, ov::intel_npu::MemType::CPU_VA),+ std::exception);+}++TEST_P(RemoteRunTests, ImportCpuVAUsingStandardRemoteTensorAPI) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 1024};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ auto data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));+ for (size_t i = 0; i < shape_size; ++i) {+ static_cast<float*>(data)[i] = 5.f;+ }++ auto context = core->get_default_context(target_device);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},+ {ov::intel_npu::mem_handle.name(), data}};+ ov::RemoteTensor remote_tensor;+ OV_ASSERT_NO_THROW(remote_tensor = context.create_tensor(ov::element::f32, shape, params));++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_output_tensor();+ float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());++ float expected_result = 6.0f;+ for (size_t j = 0; j < output_tensor.get_size(); ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;+ }++ // destroy inference request and remote tensor to ensure that the file is closed+ inference_request = {};+ remote_tensor = {};++ ::operator delete(data, std::align_val_t(4096));+ } else {+ GTEST_SKIP() << "Standard allocation is not supported by the driver";+ }+}++TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContext) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::InferRequest inference_request;++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, params);+ ov::CompiledModel compiled_model;+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto tensor = inference_request.get_input_tensor();+ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape());+ tensor = {};++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(RemoteRunTests, CheckRemoteTensorSetOnlyTensorType) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ ov::AnyMap params = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, params);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto tensor = inference_request.get_input_tensor();+ ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape()), ov::Exception);+}++TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContextandChangedInTensor) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ ov::AnyMap paramsContext = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, paramsContext);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ ov::AnyMap paramsTensor = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::BINDED}}};++ auto tensor = inference_request.get_input_tensor();+ auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), paramsTensor);+ tensor = {};++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContextandChangedInTensorExpectToFail) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ ov::AnyMap paramsContext = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, paramsContext);+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ ov::AnyMap paramsTensor = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::BINDED}}};++ auto tensor = inference_request.get_input_tensor();+ ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), paramsTensor),+ ov::Exception);+}++TEST_P(RemoteRunTests, CheckImportModelPath) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});+ auto compiled_model_no_cache = core->compile_model(ov_model, zero_context, configuration);+ compiled_model = core->compile_model(ov_model, zero_context, configuration);++ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ auto tensor = inference_request.get_input_tensor();++ auto remote_tensor =+ zero_context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);+ tensor = {};++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufChangingTensors) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());++ // set input remote tensor+ auto tensor = inference_request.get_input_tensor();+ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto remote_tensor =+ context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);++ ov::Tensor check_remote_tensor;+ OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);+ ASSERT_THROW(check_remote_tensor.data(), ov::Exception);++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random input tensor+ ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape()};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set random output tensor+ auto output_tensor = inference_request.get_output_tensor();+ ov::Tensor outputrandom_tensor_input{ov::element::f32, output_tensor.get_shape()};+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(outputrandom_tensor_input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ // set output remote tensor+ auto remote_output_tensor = inference_request.get_output_tensor();+ auto output_remote_tensor = context.create_tensor(ov::element::f32, remote_output_tensor.get_shape());+ remote_output_tensor = {};++ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRuns) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;++ {+ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ auto remote_tensor =+ context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);+ memset(remote_tensor.get(), 1, tensor.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor(0);+ }++ compiled_model = {};+ inference_request = {};++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ float* data = new float[tensor.get_byte_size() / sizeof(float)];+ memset(data, 1, tensor.get_byte_size());+ ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = inference_request.get_output_tensor(0);++ delete[] data;+ }++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);+}++TEST_P(RemoteRunTests, CheckOutputDataFromRemoteTensorFromDifferentContext) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ ov::Tensor second_output;++ {+ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend =+ std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto remote_tensor_impl = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ tensor.get_shape());+ ov::Tensor remote_tensor = make_tensor(remote_tensor_impl);++ memset(remote_tensor_impl->get_original_memory(), 1, remote_tensor_impl->get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor(0);+ }++ compiled_model = {};+ inference_request = {};++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ float* data = new float[tensor.get_byte_size() / sizeof(float)];+ memset(data, 1, tensor.get_byte_size());+ ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = inference_request.get_output_tensor(0);++ delete[] data;+ }++ EXPECT_NE(first_output.data(), second_output.data());+ EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors1) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ void* first_output = nullptr;+ ov::intel_npu::level_zero::ZeroBufferTensor remote_output_tensor;+ ov::Tensor second_output;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto input_tensor = inference_request.get_input_tensor();+ auto output_tensor = inference_request.get_output_tensor();+ const auto byte_size = input_tensor.get_byte_size();+ auto input_shape = input_tensor.get_shape();+ auto output_shape = output_tensor.get_shape();+ input_tensor = {};+ output_tensor = {};++ auto remote_input_tensor =+ context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);+ remote_output_tensor = context.create_l0_host_tensor(ov::element::f32, output_shape);++ memset(remote_input_tensor.get(), 99, byte_size);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ first_output = remote_output_tensor.get();+ }++ compiled_model = {};+ inference_request = {};++ {+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ memset(tensor.data(), 99, tensor.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.infer());++ second_output = inference_request.get_output_tensor(0);+ }++ EXPECT_NE(first_output, second_output.data());+ EXPECT_EQ(memcmp(first_output, second_output.data(), second_output.get_byte_size()), 0);+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors2) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ void* first_output = NULL;+ void* second_output;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto input_tensor = inference_request.get_input_tensor();+ auto output_tensor = inference_request.get_output_tensor();+ const auto byte_size = input_tensor.get_byte_size();+ auto input_shape = input_tensor.get_shape();+ auto output_shape = output_tensor.get_shape();+ input_tensor = {};+ output_tensor = {};++ auto remote_input_tensor =+ context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);+ auto remote_output_tensor1 =+ context.create_tensor(ov::element::f32, output_shape).as<ov::intel_npu::level_zero::ZeroBufferTensor>();++ memset(remote_input_tensor.get(), 99, byte_size);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor1));+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = remote_output_tensor1.get();++ float* data = new float[byte_size / sizeof(float)];+ memset(data, 99, byte_size);+ ov::Tensor input_data_tensor{ov::element::f32, input_shape, data};+ auto remote_output_tensor2 =+ context.create_tensor(ov::element::f32, output_shape).as<ov::intel_npu::level_zero::ZeroBufferTensor>();++ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor2));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = remote_output_tensor2.get();++ EXPECT_NE(first_output, second_output);+ EXPECT_EQ(memcmp(first_output, second_output, remote_output_tensor2.get_byte_size()), 0);++ delete[] data;+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors3) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;+ void* second_output;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ memset(tensor.data(), 99, tensor.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor(0);++ auto input_tensor = inference_request.get_input_tensor();+ auto output_tensor = inference_request.get_output_tensor();+ const auto byte_size = input_tensor.get_byte_size();+ auto input_shape = input_tensor.get_shape();+ auto output_shape = output_tensor.get_shape();+ input_tensor = {};+ output_tensor = {};++ auto remote_input_tensor =+ context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);+ auto remote_output_tensor = context.create_l0_host_tensor(ov::element::f32, output_shape);++ memset(remote_input_tensor.get(), 99, byte_size);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());+ second_output = remote_output_tensor.get();++ EXPECT_NE(first_output.data(), second_output);+ EXPECT_EQ(memcmp(first_output.data(), second_output, first_output.get_byte_size()), 0);+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensorsHostTensor1) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ ov::Tensor first_output;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto tensor = inference_request.get_input_tensor();+ memset(tensor.data(), 99, tensor.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.infer());+ first_output = inference_request.get_output_tensor();++ auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, tensor.get_shape());+ auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, first_output.get_shape());++ memset(l0_host_input_tensor.data(), 99, tensor.get_byte_size());+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(l0_host_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(l0_host_output_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ EXPECT_NE(first_output.data(), l0_host_output_tensor.data());+ EXPECT_EQ(memcmp(first_output.data(), l0_host_output_tensor.data(), first_output.get_byte_size()), 0);+}++TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensorsHostTensor2) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ auto input_tensor = inference_request.get_input_tensor();+ auto output_tensor = inference_request.get_output_tensor();+ const auto byte_size = input_tensor.get_byte_size();+ auto input_shape = input_tensor.get_shape();+ auto output_shape = output_tensor.get_shape();+ input_tensor = {};+ output_tensor = {};++ auto remote_input_tensor =+ context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);+ auto remote_output_tensor =+ context.create_l0_host_tensor(ov::element::f32, output_shape, ov::intel_npu::TensorType::OUTPUT);+ memset(remote_input_tensor.get(), 1, byte_size);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, input_shape);+ auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, output_shape);++ memset(l0_host_input_tensor.data(), 99, byte_size);+ OV_ASSERT_NO_THROW(inference_request.set_input_tensor(l0_host_input_tensor));+ OV_ASSERT_NO_THROW(inference_request.set_output_tensor(l0_host_output_tensor));+ OV_ASSERT_NO_THROW(inference_request.infer());++ EXPECT_NE(remote_output_tensor.get(), l0_host_output_tensor.data());+ EXPECT_NE(memcmp(remote_output_tensor.get(), l0_host_output_tensor.data(), remote_output_tensor.get_byte_size()),+ 0);+}++TEST_P(RemoteRunTests, checkResultsAfterChangingStateTensors) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ testing::internal::Random random(1);+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 10, 10, 10};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device);++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ auto states = inference_request.query_state();++ auto tensor_state = states[0].get_state();+ auto tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor0 = context.create_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor1 = context.create_host_tensor(ov::element::f32, tensor_state_shape);++ states[0].set_state(l0_host_tensor0);+ states[0].reset();+ states[1].set_state(l0_host_tensor1);+ states[1].reset();++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ EXPECT_NEAR(0.5f, output_data[i], 1e-5);+ }++ auto tensor_size = l0_host_tensor0.get_size();+ auto state_data = static_cast<float*>(l0_host_tensor0.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor1.get_size();+ state_data = static_cast<float*>(l0_host_tensor1.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_state = states[0].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor2 = context.create_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor3 = context.create_host_tensor(ov::element::f32, tensor_state_shape);++ states[0].set_state(l0_host_tensor2);+ states[1].set_state(l0_host_tensor3);++ tensor_size = l0_host_tensor2.get_size();+ state_data = static_cast<float*>(l0_host_tensor2.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ tensor_size = l0_host_tensor3.get_size();+ state_data = static_cast<float*>(l0_host_tensor3.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ tensor_size = l0_host_tensor2.get_size();+ state_data = static_cast<float*>(l0_host_tensor2.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor3.get_size();+ state_data = static_cast<float*>(l0_host_tensor3.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }+}++TEST_P(RemoteRunTests, checkResultsAfterChangingStateTensorsWithRemoteTensors) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::CompiledModel compiled_model;+ testing::internal::Random random(1);+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 2, 2, 2};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ auto states = inference_request.query_state();++ auto tensor_state = states[0].get_state();+ auto tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor0 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor1 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ states[0].set_state(l0_host_tensor0);+ states[0].reset();+ states[1].set_state(l0_host_tensor1);+ states[1].reset();++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ EXPECT_NEAR(0.5f, output_data[i], 1e-5);+ }++ auto tensor_size = l0_host_tensor0.get_size();+ auto state_data = static_cast<float*>(l0_host_tensor0.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor1.get_size();+ state_data = static_cast<float*>(l0_host_tensor1.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_state = states[0].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor2 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor3 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ states[0].set_state(l0_host_tensor2);+ states[1].set_state(l0_host_tensor3);++ tensor_size = l0_host_tensor2.get_size();+ state_data = static_cast<float*>(l0_host_tensor2.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ tensor_size = l0_host_tensor3.get_size();+ state_data = static_cast<float*>(l0_host_tensor3.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ tensor_size = l0_host_tensor2.get_size();+ state_data = static_cast<float*>(l0_host_tensor2.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor3.get_size();+ state_data = static_cast<float*>(l0_host_tensor3.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }+}++TEST_P(RemoteRunTests, checkResultsAfterChangingStateDataWithRemoteAndRandomTensors0) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ testing::internal::Random random(1);+ ov::CompiledModel compiled_model;+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 10, 10, 10};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ auto states = inference_request.query_state();++ auto tensor_state = states[0].get_state();+ auto tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto byte_size = tensor_state.get_byte_size();+ float* data = new float[byte_size / sizeof(float)];+ ov::Tensor random_tensor{ov::element::f32, tensor_state_shape, data};++ states[0].set_state(l0_host_tensor);+ states[0].reset();+ states[1].set_state(random_tensor);+ states[1].reset();++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ EXPECT_NEAR(0.5f, output_data[i], 1e-5);+ }++ auto tensor_size = l0_host_tensor.get_size();+ auto state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor.get_size();+ state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ OV_ASSERT_NO_THROW(inference_request.infer());++ tensor_size = l0_host_tensor.get_size();+ state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }+}++TEST_P(RemoteRunTests, checkResultsAfterChangingStateDataWithRemoteAndRandomTensors1) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ testing::internal::Random random(1);+ ov::CompiledModel compiled_model;+ ov::Tensor input_tensor;++ auto original_shape = Shape{1, 10, 10, 10};+ auto shape_size = ov::shape_size(original_shape);+ auto model = createModelWithStates(element::f32, original_shape);++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ compiled_model = core->compile_model(model, target_device, configuration);+ ov::InferRequest inference_request;+ inference_request = compiled_model.create_infer_request();++ auto input = compiled_model.input();+ OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));+ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < shape_size; ++i) {+ input_data[i] = static_cast<float>(random.Generate(10));+ }++ auto states = inference_request.query_state();++ auto tensor_state = states[0].get_state();+ auto tensor_state_shape = tensor_state.get_shape();+ auto l0_host_tensor = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);++ tensor_state = states[1].get_state();+ tensor_state_shape = tensor_state.get_shape();+ auto byte_size = tensor_state.get_byte_size();+ float* data = new float[byte_size / sizeof(float)];+ ov::Tensor random_tensor{ov::element::f32, tensor_state_shape, data};++ auto tensor_size = l0_host_tensor.get_size();+ auto state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ state_data[i] = 1.0f;+ }++ states[0].set_state(l0_host_tensor);+ states[1].set_state(random_tensor);++ OV_ASSERT_NO_THROW(inference_request.infer());++ tensor_size = l0_host_tensor.get_size();+ state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(input_data[i], state_data[i], 1e-5);+ }++ states[0].reset();+ states[1].reset();++ OV_ASSERT_NO_THROW(inference_request.infer());++ auto output_tensor = inference_request.get_tensor("sigmod_state");+ auto output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); i++) {+ EXPECT_NEAR(0.5f, output_data[i], 1e-5);+ }++ tensor_size = l0_host_tensor.get_size();+ state_data = static_cast<float*>(l0_host_tensor.get());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }++ tensor_size = random_tensor.get_size();+ state_data = static_cast<float*>(random_tensor.data());+ for (size_t i = 0; i < tensor_size; ++i) {+ EXPECT_NEAR(0.0, state_data[i], 1e-5);+ }+}++TEST_P(RemoteRunTests, CheckContextFromDifferentOvCores) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ ov::Core core0;+ ov::Core core1;++ auto context0 = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto context1 = core0.get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto context2 = core1.get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ EXPECT_EQ(context0.get(), context1.get());+ EXPECT_EQ(context1.get(), context2.get());+}++TEST_P(RemoteRunTests, CheckContextFromDifferentDestroyedOvCores) {+ // Skip test according to plugin specific disabled_test_patterns() (if any)+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ ov::RemoteContext context1, context2;+ auto context0 = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();++ {+ ov::Core internal_core;+ context1 = internal_core.get_default_context(target_device);+ }++ {+ ov::Core internal_core;+ context2 = internal_core.get_default_context(target_device);+ }++ EXPECT_EQ(context0.get(), context1.get_params().at(ov::intel_npu::l0_context.name()).as<void*>());+ EXPECT_EQ(context1.get_params().at(ov::intel_npu::l0_context.name()).as<void*>(),+ context2.get_params().at(ov::intel_npu::l0_context.name()).as<void*>());+}++TEST_P(RemoteRunTests, SetMultipleDifferentTensors) {+ auto shape = Shape{1, 16, 16, 16};+ auto shape_size = ov::shape_size(shape);+ auto model = createModel(element::f32, shape, "N...");+ ov::CompiledModel compiled_model;++ auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ compiled_model = core->compile_model(model, target_device, configuration);++ const int inferences = 32;+ ov::InferRequest inference_request;+ ov::Tensor input_tensor;+ std::array<ov::Tensor, inferences> output_tensor;++ input_tensor = ov::Tensor{ov::element::f32, shape};+ auto* input_tensor_data = reinterpret_cast<float*>(input_tensor.data());+ for (size_t i = 0; i < shape_size; ++i) {+ input_tensor_data[i] = 0.f;+ }++ inference_request = compiled_model.create_infer_request();+ for (int i = 0; i < inferences; i++) {+ auto tensor = inference_request.get_output_tensor(0);++ if (i % 5 == 0) {+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};+ } else if (i % 5 == 1) {+ output_tensor[i] = context.create_l0_host_tensor(ov::element::f32, tensor.get_shape());+ } else if (i % 5 == 2) {+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};+ } else if (i % 5 == 3) {+ output_tensor[i] = context.create_host_tensor(ov::element::f32, tensor.get_shape());+ } else if (i % 5 == 4) {+ output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};+ }+ }++ inference_request.set_input_tensor(input_tensor);+ inference_request.set_output_tensor(output_tensor[0]);+ inference_request.infer(); // Adds '1' to each element++ for (int i = 1; i < inferences; i++) {+ inference_request.set_output_tensor(output_tensor[i]);+ inference_request.set_input_tensor(output_tensor[i - 1]);+ inference_request.infer(); // Adds '1' to each element+ }++ float expected_result = 1.f;++ for (int i = 0; i < inferences; i++) {+ float* output_tensor_data;+ if (i % 5 == 1) {+ auto remote_tensor = output_tensor[i].as<ov::intel_npu::level_zero::ZeroBufferTensor>();+ output_tensor_data = static_cast<float*>(remote_tensor.get());+ } else {+ output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());+ }+ for (size_t j = 0; j < shape_size; ++j) {+ EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)+ << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]+ << " for index " << j;+ }+ expected_result++;+ }+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.hpp b/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.hppdeleted file mode 100644index 8caeab502de..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/remote_tensor_tests/remote_run.hpp+++ /dev/null@@ -1,1575 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_remote_tensor.hpp"-#include "openvino/core/any.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "remote_context.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "zero_backend.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--namespace ov {-namespace test {-namespace behavior {-class RemoteRunTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> ov_model;-- std::string m_cache_dir;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- ov_model = getDefaultNGraphFunctionForTheDeviceNPU(); // FIXME: E#80555- }-- std::string generateCacheDirName(const std::string& test_name) {- using namespace std::chrono;- // Generate unique file names based on test name, thread id and timestamp- // This allows execution of tests in parallel (stress mode)- auto hash = std::to_string(std::hash<std::string>()(test_name));- std::stringstream ss;- auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());- ss << hash << "_" << "_" << ts.count();- return ss.str();- }-- void TearDown() override {- if (!m_cache_dir.empty()) {- core->set_property({ov::cache_dir()});- core.reset();- ov::test::utils::PluginCache::get().reset();- ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");- ov::test::utils::removeDir(m_cache_dir);- }-- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-- std::shared_ptr<ov::Model> createModel(element::Type type, const PartialShape& shape, const ov::Layout& layout) {- ResultVector res;- ParameterVector params;-- auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);- data1->set_friendly_name("input");- data1->get_output_tensor(0).set_names({"tensor_input"});- data1->set_layout(layout);- auto constant = opset8::Constant::create(type, {1}, {1});- auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);- op1->set_friendly_name("Add");- auto res1 = std::make_shared<ov::op::v0::Result>(op1);- res1->set_friendly_name("Result");- res1->get_output_tensor(0).set_names({"tensor_output"});- params.push_back(data1);- res.push_back(res1);-- return std::make_shared<Model>(res, params);- }-};--TEST_P(RemoteRunTests, CheckIsContinuousHostTensorScalar) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_context = core->get_default_context(target_device);-- auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{});- auto data = host_tensor.data();- auto strides = host_tensor.get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(ov::element::f32, ov::Shape{}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(RemoteRunTests, CheckIsContinuousHostTensor1Dimension) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_context = core->get_default_context(target_device);-- auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{128});- auto data = host_tensor.data();- auto strides = host_tensor.get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(ov::element::f32, ov::Shape{128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, ov::Shape{16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(RemoteRunTests, CheckIsContinuousHostTensor2Dimensions) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_context = core->get_default_context(target_device);-- auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{32, 128});- auto data = host_tensor.data();- auto strides = host_tensor.get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(ov::element::f32, Shape{16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-}--TEST_P(RemoteRunTests, CheckIsContinuousHostTensor3Dimensions) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_context = core->get_default_context(target_device);-- auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{5, 32, 128});- auto data = host_tensor.data();- auto strides = host_tensor.get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 64}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(RemoteRunTests, CheckIsContinuousHostTensor4Dimensions) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_context = core->get_default_context(target_device);-- auto host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 5, 32, 128});- auto data = host_tensor.data();- auto strides = host_tensor.get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 5, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 2, 5, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(ov::element::f32, Shape{3, 5, 32, 64}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{2, 1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(ov::element::f32, Shape{1, 1, 1, 32}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(RemoteRunTests, CheckRemoteTensorInternalBuf) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::InferRequest inference_request;- ov::CompiledModel compiled_model;-- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, zero_context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto tensor = inference_request.get_input_tensor();-- auto remote_tensor =- zero_context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);- tensor = {};-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(RemoteRunTests, CheckRemoteTensorImportFile0) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- const std::string filename = "CheckRemoteTensorImportFile0.bin";- std::vector<float> data(shape_size, 5.0f);-- {- std::ofstream out(filename, std::ios::binary);- out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));- out.close();- }-- ov::InferRequest inference_request;- ov::CompiledModel compiled_model;-- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, zero_context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto remote_tensor = zero_context.create_tensor(ov::element::f32, shape, ov::intel_npu::FileDescriptor{filename});-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_output_tensor();- float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- // destroy inference request and remote tensor to ensure that the file is closed- inference_request = {};- check_remote_tensor = {};- remote_tensor = {};-- std::filesystem::remove(filename);-}--TEST_P(RemoteRunTests, CheckRemoteTensorImportFile1) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- const std::string filename = "CheckRemoteTensorImportFile1.bin";- std::vector<float> data(shape_size, 5.0f);-- {- std::ofstream out(filename, std::ios::binary);- out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));- out.close();- }-- ov::InferRequest inference_request;- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},- {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto remote_tensor = context.create_tensor(ov::element::f32, shape, params);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_output_tensor();- float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- // destroy inference request and remote tensor to ensure that the file is closed- inference_request = {};- remote_tensor = {};-- std::filesystem::remove(filename);-}--TEST_P(RemoteRunTests, CheckRemoteTensorImportFile2) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- const std::string filename = "CheckRemoteTensorImportFile2.bin";- std::vector<float> data(shape_size, 5.0f);-- {- std::ofstream out(filename, std::ios::binary);- out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));- out.close();- }-- ov::InferRequest inference_request;- ov::CompiledModel compiled_model;-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},- {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, params);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto remote_tensor = context.create_tensor(ov::element::f32, shape);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_output_tensor();- float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- // destroy inference request and remote tensor to ensure that the file is closed- inference_request = {};- remote_tensor = {};-- std::filesystem::remove(filename);-}--TEST_P(RemoteRunTests, CheckRemoteTensorImportFile3) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 5, 5, 5};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- const std::string filename = "CheckRemoteTensorImportFile3.bin";- std::vector<float> data(shape_size, 5.0f);-- {- std::ofstream out(filename, std::ios::binary);- out.write(reinterpret_cast<const char*>(data.data()), data.size() * sizeof(float));- out.close();- }-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::MMAPED_FILE},- {ov::intel_npu::file_descriptor.name(), ov::intel_npu::FileDescriptor{filename}},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, params);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto remote_tensor = context.create_tensor(ov::element::f32, shape);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_output_tensor();- float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- // destroy inference request and remote tensor to ensure that the file is closed- inference_request = {};- remote_tensor = {};-- std::filesystem::remove(filename);-}--TEST_P(RemoteRunTests, TryImportCpuVAExpectedErrorUnalignedSize) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 64};- auto shape_size = ov::shape_size(shape);-- auto data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));- for (size_t i = 0; i < shape_size; ++i) {- static_cast<float*>(data)[i] = 5.f;- }-- auto context = core->get_default_context(target_device);-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},- {ov::intel_npu::mem_handle.name(), data}};- ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, shape, params), std::exception);-- ::operator delete(data, std::align_val_t(4096));- } else {- GTEST_SKIP() << "Standard allocation is not supported by the driver";- }-}--TEST_P(RemoteRunTests, TryImportCpuVAExpectedErrorUnalignedAddress) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 1024};- auto shape_size = ov::shape_size(shape);-- auto data = ::operator new(shape_size * sizeof(float) + 64, std::align_val_t(4096));- auto unaligned_data = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(data) + 64);- for (size_t i = 0; i < shape_size; ++i) {- static_cast<float*>(unaligned_data)[i] = 5.f;- }-- auto context = core->get_default_context(target_device);-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},- {ov::intel_npu::mem_handle.name(), unaligned_data}};- ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, shape, params), std::exception);-- ::operator delete(data, std::align_val_t(4096));- } else {- GTEST_SKIP() << "Standard allocation is not supported by the driver";- }-}--TEST_P(RemoteRunTests, ImportCpuVAUsingNpuRemoteTensorAPI) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 1024};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- auto input_data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));- auto output_data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));- for (size_t i = 0; i < shape_size; ++i) {- static_cast<float*>(input_data)[i] = 5.f;- }-- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- ov::intel_npu::level_zero::ZeroBufferTensor input_remote_tensor, output_remote_tensor;- OV_ASSERT_NO_THROW(input_remote_tensor = zero_context.create_tensor(ov::element::f32,- shape,- input_data,- ov::intel_npu::MemType::CPU_VA,- ov::intel_npu::TensorType::INPUT));-- OV_ASSERT_NO_THROW(output_remote_tensor = zero_context.create_tensor(ov::element::f32,- shape,- output_data,- ov::intel_npu::MemType::CPU_VA,- ov::intel_npu::TensorType::OUTPUT));-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- float* output_tensor_data = reinterpret_cast<float*>(output_remote_tensor.get());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_remote_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- inference_request = {};- input_remote_tensor = {};- output_remote_tensor = {};-- ::operator delete(input_data, std::align_val_t(4096));- ::operator delete(output_data, std::align_val_t(4096));- } else {- GTEST_SKIP() << "Standard allocation is not supported by the driver";- }-}--TEST_P(RemoteRunTests, ImportCpuVAUwithoutSettingBufferExpectedError) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()- auto shape = Shape{1, 1024};-- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- ov::intel_npu::level_zero::ZeroBufferTensor remote_tensor;- ASSERT_THROW(- remote_tensor = zero_context.create_tensor(ov::element::f32, shape, nullptr, ov::intel_npu::MemType::CPU_VA),- std::exception);-}--TEST_P(RemoteRunTests, ImportCpuVAUsingStandardRemoteTensorAPI) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (std::make_shared<::intel_npu::ZeroInitStructsHolder>()->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 1024};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- auto data = ::operator new(shape_size * sizeof(float), std::align_val_t(4096));- for (size_t i = 0; i < shape_size; ++i) {- static_cast<float*>(data)[i] = 5.f;- }-- auto context = core->get_default_context(target_device);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::CPU_VA},- {ov::intel_npu::mem_handle.name(), data}};- ov::RemoteTensor remote_tensor;- OV_ASSERT_NO_THROW(remote_tensor = context.create_tensor(ov::element::f32, shape, params));-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_output_tensor();- float* output_tensor_data = reinterpret_cast<float*>(output_tensor.data());-- float expected_result = 6.0f;- for (size_t j = 0; j < output_tensor.get_size(); ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << " Expected=" << expected_result << ", actual=" << output_tensor_data[j] << " for index " << j;- }-- // destroy inference request and remote tensor to ensure that the file is closed- inference_request = {};- remote_tensor = {};-- ::operator delete(data, std::align_val_t(4096));- } else {- GTEST_SKIP() << "Standard allocation is not supported by the driver";- }-}--TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContext) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::InferRequest inference_request;-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, params);- ov::CompiledModel compiled_model;- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto tensor = inference_request.get_input_tensor();- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape());- tensor = {};-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(RemoteRunTests, CheckRemoteTensorSetOnlyTensorType) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- ov::AnyMap params = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, params);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto tensor = inference_request.get_input_tensor();- ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape()), ov::Exception);-}--TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContextandChangedInTensor) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- ov::AnyMap paramsContext = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, paramsContext);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- ov::AnyMap paramsTensor = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::BINDED}}};-- auto tensor = inference_request.get_input_tensor();- auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), paramsTensor);- tensor = {};-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufSetPropertyInContextandChangedInTensorExpectToFail) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- ov::AnyMap paramsContext = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, paramsContext);- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, context, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- ov::AnyMap paramsTensor = {{ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::BINDED}}};-- auto tensor = inference_request.get_input_tensor();- ASSERT_THROW(auto remote_tensor = context.create_tensor(ov::element::f32, tensor.get_shape(), paramsTensor),- ov::Exception);-}--TEST_P(RemoteRunTests, CheckImportModelPath) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});- auto compiled_model_no_cache = core->compile_model(ov_model, zero_context, configuration);- compiled_model = core->compile_model(ov_model, zero_context, configuration);-- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- auto tensor = inference_request.get_input_tensor();-- auto remote_tensor =- zero_context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);- tensor = {};-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(RemoteRunTests, CheckRemoteTensorInternalBufChangingTensors) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());-- // set input remote tensor- auto tensor = inference_request.get_input_tensor();- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto remote_tensor =- context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);-- ov::Tensor check_remote_tensor;- OV_ASSERT_NO_THROW(check_remote_tensor = remote_tensor);- ASSERT_THROW(check_remote_tensor.data(), ov::Exception);-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(check_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random input tensor- ov::Tensor random_tensor_input{ov::element::f32, tensor.get_shape()};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(random_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set random output tensor- auto output_tensor = inference_request.get_output_tensor();- ov::Tensor outputrandom_tensor_input{ov::element::f32, output_tensor.get_shape()};- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(outputrandom_tensor_input));- OV_ASSERT_NO_THROW(inference_request.infer());-- // set output remote tensor- auto remote_output_tensor = inference_request.get_output_tensor();- auto output_remote_tensor = context.create_tensor(ov::element::f32, remote_output_tensor.get_shape());- remote_output_tensor = {};-- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(output_remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRuns) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;-- {- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- auto remote_tensor =- context.create_l0_host_tensor(ov::element::f32, tensor.get_shape(), ov::intel_npu::TensorType::INPUT);- memset(remote_tensor.get(), 1, tensor.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor(0);- }-- compiled_model = {};- inference_request = {};-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- float* data = new float[tensor.get_byte_size() / sizeof(float)];- memset(data, 1, tensor.get_byte_size());- ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = inference_request.get_output_tensor(0);-- delete[] data;- }-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);-}--TEST_P(RemoteRunTests, CheckOutputDataFromRemoteTensorFromDifferentContext) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- ov::Tensor second_output;-- {- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend =- std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto remote_tensor_impl = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- tensor.get_shape());- ov::Tensor remote_tensor = make_tensor(remote_tensor_impl);-- memset(remote_tensor_impl->get_original_memory(), 1, remote_tensor_impl->get_byte_size());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor(0);- }-- compiled_model = {};- inference_request = {};-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- float* data = new float[tensor.get_byte_size() / sizeof(float)];- memset(data, 1, tensor.get_byte_size());- ov::Tensor input_data_tensor{ov::element::f32, tensor.get_shape(), data};- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = inference_request.get_output_tensor(0);-- delete[] data;- }-- EXPECT_NE(first_output.data(), second_output.data());- EXPECT_EQ(memcmp(first_output.data(), second_output.data(), second_output.get_byte_size()), 0);-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors1) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- void* first_output = nullptr;- ov::intel_npu::level_zero::ZeroBufferTensor remote_output_tensor;- ov::Tensor second_output;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto input_tensor = inference_request.get_input_tensor();- auto output_tensor = inference_request.get_output_tensor();- const auto byte_size = input_tensor.get_byte_size();- auto input_shape = input_tensor.get_shape();- auto output_shape = output_tensor.get_shape();- input_tensor = {};- output_tensor = {};-- auto remote_input_tensor =- context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);- remote_output_tensor = context.create_l0_host_tensor(ov::element::f32, output_shape);-- memset(remote_input_tensor.get(), 99, byte_size);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- first_output = remote_output_tensor.get();- }-- compiled_model = {};- inference_request = {};-- {- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- memset(tensor.data(), 99, tensor.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.infer());-- second_output = inference_request.get_output_tensor(0);- }-- EXPECT_NE(first_output, second_output.data());- EXPECT_EQ(memcmp(first_output, second_output.data(), second_output.get_byte_size()), 0);-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors2) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- void* first_output = NULL;- void* second_output;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto input_tensor = inference_request.get_input_tensor();- auto output_tensor = inference_request.get_output_tensor();- const auto byte_size = input_tensor.get_byte_size();- auto input_shape = input_tensor.get_shape();- auto output_shape = output_tensor.get_shape();- input_tensor = {};- output_tensor = {};-- auto remote_input_tensor =- context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);- auto remote_output_tensor1 =- context.create_tensor(ov::element::f32, output_shape).as<ov::intel_npu::level_zero::ZeroBufferTensor>();-- memset(remote_input_tensor.get(), 99, byte_size);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor1));- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = remote_output_tensor1.get();-- float* data = new float[byte_size / sizeof(float)];- memset(data, 99, byte_size);- ov::Tensor input_data_tensor{ov::element::f32, input_shape, data};- auto remote_output_tensor2 =- context.create_tensor(ov::element::f32, output_shape).as<ov::intel_npu::level_zero::ZeroBufferTensor>();-- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(input_data_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor2));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = remote_output_tensor2.get();-- EXPECT_NE(first_output, second_output);- EXPECT_EQ(memcmp(first_output, second_output, remote_output_tensor2.get_byte_size()), 0);-- delete[] data;-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensors3) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;- void* second_output;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- memset(tensor.data(), 99, tensor.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor(0);-- auto input_tensor = inference_request.get_input_tensor();- auto output_tensor = inference_request.get_output_tensor();- const auto byte_size = input_tensor.get_byte_size();- auto input_shape = input_tensor.get_shape();- auto output_shape = output_tensor.get_shape();- input_tensor = {};- output_tensor = {};-- auto remote_input_tensor =- context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);- auto remote_output_tensor = context.create_l0_host_tensor(ov::element::f32, output_shape);-- memset(remote_input_tensor.get(), 99, byte_size);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());- second_output = remote_output_tensor.get();-- EXPECT_NE(first_output.data(), second_output);- EXPECT_EQ(memcmp(first_output.data(), second_output, first_output.get_byte_size()), 0);-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensorsHostTensor1) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- ov::Tensor first_output;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto tensor = inference_request.get_input_tensor();- memset(tensor.data(), 99, tensor.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.infer());- first_output = inference_request.get_output_tensor();-- auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, tensor.get_shape());- auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, first_output.get_shape());-- memset(l0_host_input_tensor.data(), 99, tensor.get_byte_size());- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(l0_host_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(l0_host_output_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- EXPECT_NE(first_output.data(), l0_host_output_tensor.data());- EXPECT_EQ(memcmp(first_output.data(), l0_host_output_tensor.data(), first_output.get_byte_size()), 0);-}--TEST_P(RemoteRunTests, CheckOutputDataFromTwoRunsInOutRemoteTensorsHostTensor2) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(ov_model, target_device, configuration));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- auto input_tensor = inference_request.get_input_tensor();- auto output_tensor = inference_request.get_output_tensor();- const auto byte_size = input_tensor.get_byte_size();- auto input_shape = input_tensor.get_shape();- auto output_shape = output_tensor.get_shape();- input_tensor = {};- output_tensor = {};-- auto remote_input_tensor =- context.create_l0_host_tensor(ov::element::f32, input_shape, ov::intel_npu::TensorType::INPUT);- auto remote_output_tensor =- context.create_l0_host_tensor(ov::element::f32, output_shape, ov::intel_npu::TensorType::OUTPUT);- memset(remote_input_tensor.get(), 1, byte_size);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(remote_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(remote_output_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- auto l0_host_input_tensor = context.create_host_tensor(ov::element::f32, input_shape);- auto l0_host_output_tensor = context.create_host_tensor(ov::element::f32, output_shape);-- memset(l0_host_input_tensor.data(), 99, byte_size);- OV_ASSERT_NO_THROW(inference_request.set_input_tensor(l0_host_input_tensor));- OV_ASSERT_NO_THROW(inference_request.set_output_tensor(l0_host_output_tensor));- OV_ASSERT_NO_THROW(inference_request.infer());-- EXPECT_NE(remote_output_tensor.get(), l0_host_output_tensor.data());- EXPECT_NE(memcmp(remote_output_tensor.get(), l0_host_output_tensor.data(), remote_output_tensor.get_byte_size()),- 0);-}--TEST_P(RemoteRunTests, checkResultsAfterChangingStateTensors) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- testing::internal::Random random(1);- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 10, 10, 10};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device);-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- auto states = inference_request.query_state();-- auto tensor_state = states[0].get_state();- auto tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor0 = context.create_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor1 = context.create_host_tensor(ov::element::f32, tensor_state_shape);-- states[0].set_state(l0_host_tensor0);- states[0].reset();- states[1].set_state(l0_host_tensor1);- states[1].reset();-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- EXPECT_NEAR(0.5f, output_data[i], 1e-5);- }-- auto tensor_size = l0_host_tensor0.get_size();- auto state_data = static_cast<float*>(l0_host_tensor0.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_size = l0_host_tensor1.get_size();- state_data = static_cast<float*>(l0_host_tensor1.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_state = states[0].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor2 = context.create_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor3 = context.create_host_tensor(ov::element::f32, tensor_state_shape);-- states[0].set_state(l0_host_tensor2);- states[1].set_state(l0_host_tensor3);-- tensor_size = l0_host_tensor2.get_size();- state_data = static_cast<float*>(l0_host_tensor2.data());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- tensor_size = l0_host_tensor3.get_size();- state_data = static_cast<float*>(l0_host_tensor3.data());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- tensor_size = l0_host_tensor2.get_size();- state_data = static_cast<float*>(l0_host_tensor2.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-- tensor_size = l0_host_tensor3.get_size();- state_data = static_cast<float*>(l0_host_tensor3.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-}--TEST_P(RemoteRunTests, checkResultsAfterChangingStateTensorsWithRemoteTensors) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::CompiledModel compiled_model;- testing::internal::Random random(1);- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 2, 2, 2};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- auto states = inference_request.query_state();-- auto tensor_state = states[0].get_state();- auto tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor0 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor1 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- states[0].set_state(l0_host_tensor0);- states[0].reset();- states[1].set_state(l0_host_tensor1);- states[1].reset();-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- EXPECT_NEAR(0.5f, output_data[i], 1e-5);- }-- auto tensor_size = l0_host_tensor0.get_size();- auto state_data = static_cast<float*>(l0_host_tensor0.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_size = l0_host_tensor1.get_size();- state_data = static_cast<float*>(l0_host_tensor1.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_state = states[0].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor2 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor3 = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- states[0].set_state(l0_host_tensor2);- states[1].set_state(l0_host_tensor3);-- tensor_size = l0_host_tensor2.get_size();- state_data = static_cast<float*>(l0_host_tensor2.get());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- tensor_size = l0_host_tensor3.get_size();- state_data = static_cast<float*>(l0_host_tensor3.get());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- tensor_size = l0_host_tensor2.get_size();- state_data = static_cast<float*>(l0_host_tensor2.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-- tensor_size = l0_host_tensor3.get_size();- state_data = static_cast<float*>(l0_host_tensor3.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-}--TEST_P(RemoteRunTests, checkResultsAfterChangingStateDataWithRemoteAndRandomTensors0) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- testing::internal::Random random(1);- ov::CompiledModel compiled_model;- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 10, 10, 10};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- auto states = inference_request.query_state();-- auto tensor_state = states[0].get_state();- auto tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto byte_size = tensor_state.get_byte_size();- float* data = new float[byte_size / sizeof(float)];- ov::Tensor random_tensor{ov::element::f32, tensor_state_shape, data};-- states[0].set_state(l0_host_tensor);- states[0].reset();- states[1].set_state(random_tensor);- states[1].reset();-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- EXPECT_NEAR(0.5f, output_data[i], 1e-5);- }-- auto tensor_size = l0_host_tensor.get_size();- auto state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_size = l0_host_tensor.get_size();- state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- OV_ASSERT_NO_THROW(inference_request.infer());-- tensor_size = l0_host_tensor.get_size();- state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-}--TEST_P(RemoteRunTests, checkResultsAfterChangingStateDataWithRemoteAndRandomTensors1) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- testing::internal::Random random(1);- ov::CompiledModel compiled_model;- ov::Tensor input_tensor;-- auto original_shape = Shape{1, 10, 10, 10};- auto shape_size = ov::shape_size(original_shape);- auto model = createModelWithStates(element::f32, original_shape);-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- compiled_model = core->compile_model(model, target_device, configuration);- ov::InferRequest inference_request;- inference_request = compiled_model.create_infer_request();-- auto input = compiled_model.input();- OV_ASSERT_NO_THROW(input_tensor = inference_request.get_tensor(input));- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < shape_size; ++i) {- input_data[i] = static_cast<float>(random.Generate(10));- }-- auto states = inference_request.query_state();-- auto tensor_state = states[0].get_state();- auto tensor_state_shape = tensor_state.get_shape();- auto l0_host_tensor = context.create_l0_host_tensor(ov::element::f32, tensor_state_shape);-- tensor_state = states[1].get_state();- tensor_state_shape = tensor_state.get_shape();- auto byte_size = tensor_state.get_byte_size();- float* data = new float[byte_size / sizeof(float)];- ov::Tensor random_tensor{ov::element::f32, tensor_state_shape, data};-- auto tensor_size = l0_host_tensor.get_size();- auto state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- state_data[i] = 1.0f;- }-- states[0].set_state(l0_host_tensor);- states[1].set_state(random_tensor);-- OV_ASSERT_NO_THROW(inference_request.infer());-- tensor_size = l0_host_tensor.get_size();- state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(input_data[i], state_data[i], 1e-5);- }-- states[0].reset();- states[1].reset();-- OV_ASSERT_NO_THROW(inference_request.infer());-- auto output_tensor = inference_request.get_tensor("sigmod_state");- auto output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); i++) {- EXPECT_NEAR(0.5f, output_data[i], 1e-5);- }-- tensor_size = l0_host_tensor.get_size();- state_data = static_cast<float*>(l0_host_tensor.get());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-- tensor_size = random_tensor.get_size();- state_data = static_cast<float*>(random_tensor.data());- for (size_t i = 0; i < tensor_size; ++i) {- EXPECT_NEAR(0.0, state_data[i], 1e-5);- }-}--TEST_P(RemoteRunTests, CheckContextFromDifferentOvCores) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()- ov::Core core0;- ov::Core core1;-- auto context0 = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto context1 = core0.get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto context2 = core1.get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- EXPECT_EQ(context0.get(), context1.get());- EXPECT_EQ(context1.get(), context2.get());-}--TEST_P(RemoteRunTests, CheckContextFromDifferentDestroyedOvCores) {- // Skip test according to plugin specific disabled_test_patterns() (if any)- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- ov::RemoteContext context1, context2;- auto context0 = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();-- {- ov::Core internal_core;- context1 = internal_core.get_default_context(target_device);- }-- {- ov::Core internal_core;- context2 = internal_core.get_default_context(target_device);- }-- EXPECT_EQ(context0.get(), context1.get_params().at(ov::intel_npu::l0_context.name()).as<void*>());- EXPECT_EQ(context1.get_params().at(ov::intel_npu::l0_context.name()).as<void*>(),- context2.get_params().at(ov::intel_npu::l0_context.name()).as<void*>());-}--TEST_P(RemoteRunTests, SetMultipleDifferentTensors) {- auto shape = Shape{1, 16, 16, 16};- auto shape_size = ov::shape_size(shape);- auto model = createModel(element::f32, shape, "N...");- ov::CompiledModel compiled_model;-- auto context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- compiled_model = core->compile_model(model, target_device, configuration);-- const int inferences = 32;- ov::InferRequest inference_request;- ov::Tensor input_tensor;- std::array<ov::Tensor, inferences> output_tensor;-- input_tensor = ov::Tensor{ov::element::f32, shape};- auto* input_tensor_data = reinterpret_cast<float*>(input_tensor.data());- for (size_t i = 0; i < shape_size; ++i) {- input_tensor_data[i] = 0.f;- }-- inference_request = compiled_model.create_infer_request();- for (int i = 0; i < inferences; i++) {- auto tensor = inference_request.get_output_tensor(0);-- if (i % 5 == 0) {- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};- } else if (i % 5 == 1) {- output_tensor[i] = context.create_l0_host_tensor(ov::element::f32, tensor.get_shape());- } else if (i % 5 == 2) {- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};- } else if (i % 5 == 3) {- output_tensor[i] = context.create_host_tensor(ov::element::f32, tensor.get_shape());- } else if (i % 5 == 4) {- output_tensor[i] = ov::Tensor{ov::element::f32, tensor.get_shape()};- }- }-- inference_request.set_input_tensor(input_tensor);- inference_request.set_output_tensor(output_tensor[0]);- inference_request.infer(); // Adds '1' to each element-- for (int i = 1; i < inferences; i++) {- inference_request.set_output_tensor(output_tensor[i]);- inference_request.set_input_tensor(output_tensor[i - 1]);- inference_request.infer(); // Adds '1' to each element- }-- float expected_result = 1.f;-- for (int i = 0; i < inferences; i++) {- float* output_tensor_data;- if (i % 5 == 1) {- auto remote_tensor = output_tensor[i].as<ov::intel_npu::level_zero::ZeroBufferTensor>();- output_tensor_data = static_cast<float*>(remote_tensor.get());- } else {- output_tensor_data = reinterpret_cast<float*>(output_tensor[i].data());- }- for (size_t j = 0; j < shape_size; ++j) {- EXPECT_NEAR(output_tensor_data[j], expected_result, 1e-5)- << "Output=" << i << " Expected=" << expected_result << ", actual=" << output_tensor_data[j]- << " for index " << j;- }- expected_result++;- }-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cppindex 91b15e3f3ad..da91537a55f 100644--- a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.cpp@@ -2,11 +2,1190 @@// SPDX-License-Identifier: Apache-2.0//-#include "roi_tensors_tests.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_remote_tensor.hpp"+#include "intel_npu/utils/zero/zero_tensor.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/node_vector.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"+#include "openvino/runtime/iremote_tensor.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "remote_context.hpp"+#include "zero_backend.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class RoiTensorsTestsRun : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (const auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(target_device, configuration) = this->GetParam();+ OVPluginTestBase::SetUp();++ isStridedEnabled();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }++ std::shared_ptr<Model> createModelWithNInputs(element::Type type,+ const PartialShape& shape,+ const ov::Layout& layout,+ size_t n = 1) {+ ResultVector res;+ ParameterVector params;++ for (size_t i = 0; i < n; i++) {+ auto index_str = std::to_string(i);+ auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);+ data1->set_friendly_name("input" + index_str);+ data1->get_output_tensor(0).set_names({"tensor_input" + index_str});+ data1->set_layout(layout);+ auto constant = opset8::Constant::create(type, {1}, {1});+ auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);+ op1->set_friendly_name("Add" + index_str);+ auto res1 = std::make_shared<ov::op::v0::Result>(op1);+ res1->set_friendly_name("Result" + index_str);+ res1->get_output_tensor(0).set_names({"tensor_output" + index_str});+ params.push_back(data1);+ res.push_back(res1);+ }++ return std::make_shared<Model>(res, params);+ }++ void isStridedEnabled() {+ auto supportedProperties =+ core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();++ bool stridesEnabled =+ std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const auto& property) {+ return property == ov::intel_npu::enable_strides_for.name();+ });++ auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();+ if (zeroInit->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {+ stridesEnabled = false;+ }++ if (!stridesEnabled) {+ GTEST_SKIP() << "NPU_ENABLE_STRIDES_FOR property is not supported";+ }+ }+};++TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabled) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(req.infer());+}++TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabledInternalOperator) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");+ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});+ auto input_strides = input_host_tensor.get_strides();+ auto output_strides = output_host_tensor.get_strides();++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));++ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));++ OV_ASSERT_NO_THROW(req.infer());+}++TEST_P(RoiTensorsTestsRun, CreateStridedTensorFromHostTensorAndRunInfer) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");+ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});+ auto input_strides = input_host_tensor.get_strides();+ auto output_strides = output_host_tensor.get_strides();++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));++ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);+ output_view_tensor.copy_to(check_out_view_tensor);+ auto* check_data = check_out_view_tensor.data<float>();+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, SetStridedTensorForUnexpectedTensorExpectedThrow) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");+ auto zero_context = core->get_default_context(target_device);+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});+ auto output_strides = output_host_tensor.get_strides();++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0";+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ EXPECT_THROW(req.set_output_tensor(output_view_tensor), ov::Exception);+}++TEST_P(RoiTensorsTestsRun, SetStridedMultipleOutputTensorForUnexpectedTensorExpectedThrow) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...", 2);+ auto zero_context = core->get_default_context(target_device);+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});+ auto output_strides = output_host_tensor.get_strides();++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,tensor_output0";+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());+ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ EXPECT_THROW(req.set_output_tensor(1, output_view_tensor), ov::Exception);+}++TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInfer) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatching) {+ auto shape = Shape{2, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatchingUpdateMCL) {+ auto shape = Shape{2, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));++ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor1.copy_to(check_out_roi_tensor1);+ auto* check_data = check_out_roi_tensor1.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ ov::Tensor input_roi_tensor2 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {2, 4, 5, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor2));++ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor2.copy_to(check_out_roi_tensor2);+ check_data = check_out_roi_tensor2.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRunInferWithBatchingUpdateMCL) {+ auto shape = Shape{2, 2, 2, 2};+ auto batchedShape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});+ ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_host_tensor, {2, 4, 4, 4}, {3, 6, 6, 6});+ std::vector<ov::Tensor> tensors1;+ tensors1.push_back(input_roi_tensor1_batched0);+ tensors1.push_back(input_roi_tensor1_batched1);+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););++ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor1.copy_to(check_out_roi_tensor1);+ auto* check_data = check_out_roi_tensor1.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});+ ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});++ std::vector<ov::Tensor> tensors2;+ tensors2.push_back(input_roi_tensor2_batched0);+ tensors2.push_back(input_roi_tensor2_batched1);+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););++ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor2.copy_to(check_out_roi_tensor2);+ check_data = check_out_roi_tensor2.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRegularTensorAndRunInferWithBatchingUpdateMCL) {+ auto shape = Shape{2, 2, 2, 2};+ auto batchedShape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});+ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }+ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ auto input_regular_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};+ input_data = input_regular_tensor.data<float>();+ for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});+ ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_regular_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ std::vector<ov::Tensor> tensors1;+ tensors1.push_back(input_roi_tensor1_batched0);+ tensors1.push_back(input_roi_tensor1_batched1);+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););++ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor1.copy_to(check_out_roi_tensor1);+ auto* check_data = check_out_roi_tensor1.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ input_data = input_regular_tensor.data<float>();+ for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }+ input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_regular_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});+ ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});++ std::vector<ov::Tensor> tensors2;+ tensors2.push_back(input_roi_tensor2_batched0);+ tensors2.push_back(input_roi_tensor2_batched1);+ OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););++ ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor2.copy_to(check_out_roi_tensor2);+ check_data = check_out_roi_tensor2.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++TEST_P(RoiTensorsTestsRun, FallbackOnMemcpy) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto input_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};+ auto output_tensor = ov::Tensor{ov::element::f32, Shape{3, 8, 8, 8}};++ auto* input_data = input_tensor.data<float>();+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContext) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();++ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ Shape{1, 10, 10, 10});++ auto output_remote_tensor =+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});++ auto input_tensor = make_tensor(input_remote_tensor);+ auto output_tensor = make_tensor(output_remote_tensor);++ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ init_struct = nullptr;+}++TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyToAnotherRemoteTensor) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();++ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ Shape{1, 10, 10, 10});++ auto output_remote_tensor =+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});++ auto input_tensor = make_tensor(input_remote_tensor);+ auto output_tensor = make_tensor(output_remote_tensor);++ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ Shape{1, 8, 8, 10});+ auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);+ ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});+ output_roi_tensor.copy_to(check_out_roi_tensor_roi);++ auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);+ check_out_roi_tensor_roi.copy_to(check_out_roi_roi_tensor);+ auto* check_data = check_out_roi_roi_tensor.data<float>();+ for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ init_struct = nullptr;+}++TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyFromAnotherRemoteTensor) {+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);+ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();++ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ Shape{1, 10, 10, 10});++ auto output_remote_tensor =+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});++ auto input_tensor = make_tensor(input_remote_tensor);+ auto output_tensor = make_tensor(output_remote_tensor);++ auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,+ init_struct,+ ov::element::f32,+ Shape{1, 8, 8, 10});+ auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);+ ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});+ auto check_out_roi_remote_tensor_roi =+ std::dynamic_pointer_cast<ov::IRemoteTensor>(get_tensor_impl(check_out_roi_tensor_roi)._ptr);+ check_out_roi_remote_tensor_roi->copy_from(get_tensor_impl(output_roi_tensor)._ptr);++ auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);+ check_out_roi_remote_tensor_roi->copy_to(get_tensor_impl(check_out_roi_roi_tensor)._ptr);+ auto* check_data = check_out_roi_roi_tensor.data<float>();+ for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ init_struct = nullptr;+}++TEST_P(RoiTensorsTestsRun, ImportStandardAllocation) {+ auto shape = Shape{1, 2, 2, 1024};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto shape_input = Shape{1, 4, 8, 1024};+ auto shape_output = Shape{1, 2, 4, 2048};++ auto input_data = static_cast<float*>(+ ::operator new(ov::shape_size(shape_input) * ov::element::f32.size(), std::align_val_t(4096)));+ auto output_data = static_cast<float*>(+ ::operator new(ov::shape_size(shape_output) * ov::element::f32.size(), std::align_val_t(4096)));++ auto input_tensor = ov::Tensor{ov::element::f32, shape_input, input_data};+ auto output_tensor = ov::Tensor{ov::element::f32, shape_output, output_data};++ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 0, 0, 0}, {1, 2, 2, 1024});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {0, 0, 2, 0}, {1, 2, 4, 1024});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ req = {};+ check_out_roi_tensor = {};+ input_roi_tensor = {};+ output_roi_tensor = {};+ input_tensor = {};+ output_tensor = {};++ ::operator delete(input_data, std::align_val_t(4096));+ ::operator delete(output_data, std::align_val_t(4096));+}++TEST_P(RoiTensorsTestsRun, RunWithRemoteTensor) {+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 8, 8, 8});++ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto input_data = static_cast<float*>(input_remote_tensor.get());+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto output_data = static_cast<float*>(output_remote_tensor.get());+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor = ov::Tensor(input_remote_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_remote_tensor, {2, 5, 6, 6}, {3, 7, 8, 8});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);++ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, MultipleIOCreateRoiTensorFromHostTensorAndRunInfer) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...", 2);++ auto zero_context = core->get_default_context(target_device);+ auto input0_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto input1_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 12, 15, 8});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});++ auto* input_data = input0_host_tensor.data<float>();+ for (size_t i = 0; i < input0_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ input_data = input1_host_tensor.data<float>();+ for (size_t i = 0; i < input1_host_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input0_roi_tensor = ov::Tensor(input0_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(0, input0_roi_tensor));++ ov::Tensor input1_roi_tensor = ov::Tensor(input1_host_tensor, {1, 5, 7, 6}, {2, 7, 9, 8});+ OV_ASSERT_NO_THROW(req.set_input_tensor(1, input1_roi_tensor));++ ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(0, output_roi_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ auto check_out1_tensor = req.get_output_tensor(1);+ check_data = check_out1_tensor.data<float>();+ for (size_t i = 0; i < check_out1_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBatching) {+ auto model_shape = PartialShape{-1, 5, 8, 9};+ auto shape = Shape{2, 5, 8, 9};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");+ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});+ auto input_strides = input_host_tensor.get_strides();+ auto output_strides = output_host_tensor.get_strides();++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));++ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);+ output_view_tensor.copy_to(check_out_view_tensor);+ auto* check_data = check_out_view_tensor.data<float>();+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBoundedBatching) {+ auto model_shape = PartialShape{ov::Dimension(1, 10), 5, 8, 9};+ auto shape = Shape{2, 5, 8, 9};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");+ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});+ auto input_strides = input_host_tensor.get_strides();+ auto output_strides = output_host_tensor.get_strides();++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));++ ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);+ output_view_tensor.copy_to(check_out_view_tensor);+ auto* check_data = check_out_view_tensor.data<float>();+ for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }+}++TEST_P(RoiTensorsTestsRun, TryToCompileStridedTensorWithDynamicBoundsExpectedThrow) {+ auto model_shape = PartialShape{ov::Dimension(1, 10), 5, ov::Dimension(2, 15), 9};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, model_shape, "N...");++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ EXPECT_THROW(core->compile_model(model, target_device, configuration), ov::Exception);+}++TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorUpdateCommandListAndRunInfer) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor0 = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor0));++ ov::Tensor output_roi_tensor0 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor0));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor0 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor0.copy_to(check_out_roi_tensor0);+ auto* check_data = check_out_roi_tensor0.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor0.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {0, 5, 6, 8}, {1, 7, 8, 10});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));++ ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 2, 19, 13}, {1, 4, 21, 15});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor1.copy_to(check_out_roi_tensor1);+ check_data = check_out_roi_tensor1.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CheckRemoteCopyToWithRoiRemoteTensors) {+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});++ auto data = static_cast<float*>(input_remote_tensor.get());+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {+ data[i] = 50.0f;+ }++ data = static_cast<float*>(output_remote_tensor.get());+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {+ data[i] = 10.0f;+ }++ auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});+ auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});++ input_roi_tensor.copy_to(output_roi_tensor);++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 50.0f);+ }+}++TEST_P(RoiTensorsTestsRun, CheckRemoteCopyFromWithRoiRemoteTensors) {+ auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();+ auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});+ auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});++ auto data = static_cast<float*>(input_remote_tensor.get());+ for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {+ data[i] = 50.0f;+ }++ data = static_cast<float*>(output_remote_tensor.get());+ for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {+ data[i] = 10.0f;+ }++ auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});+ auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});+ output_roi_tensor.copy_from(input_roi_tensor);++ auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});+ output_roi_tensor.copy_to(check_out_roi_tensor);+ auto* check_data = check_out_roi_tensor.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 50.0f);+ }+}++TEST_P(RoiTensorsTestsRun, SetContiguousTensorAfterRoiAndCheckResults) {+ auto shape = Shape{1, 2, 2, 2};+ ov::CompiledModel compiled_model;+ auto model = createModelWithNInputs(element::f32, shape, "N...");++ auto zero_context = core->get_default_context(target_device);+ auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});+ auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});++ auto* input_data = input_host_tensor.data<float>();+ for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {+ input_data[i] = 50.0f;+ }++ auto* output_data = output_host_tensor.data<float>();+ for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {+ output_data[i] = 10.0f;+ }++ configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ov::InferRequest req;+ OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());++ ov::Tensor input_roi_tensor0 = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor0));++ ov::Tensor output_roi_tensor0 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor0));++ OV_ASSERT_NO_THROW(req.infer());++ auto check_out_roi_tensor0 = ov::Tensor(ov::element::f32, shape);+ output_roi_tensor0.copy_to(check_out_roi_tensor0);+ auto* check_data = check_out_roi_tensor0.data<float>();+ for (size_t i = 0; i < check_out_roi_tensor0.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 51.0f);+ }++ auto input_tensor = zero_context.create_host_tensor(ov::element::f32, shape);+ OV_ASSERT_NO_THROW(req.set_input_tensor(input_tensor));++ auto output_tensor = zero_context.create_host_tensor(ov::element::f32, shape);+ OV_ASSERT_NO_THROW(req.set_output_tensor(output_tensor));++ input_data = input_tensor.data<float>();+ for (size_t i = 0; i < input_tensor.get_size(); ++i) {+ input_data[i] = 75.0f;+ }++ output_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ output_data[i] = 20.0f;+ }++ OV_ASSERT_NO_THROW(req.infer());++ check_data = output_tensor.data<float>();+ for (size_t i = 0; i < output_tensor.get_size(); ++i) {+ EXPECT_EQ(check_data[i], 76.0f);+ }+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hppdeleted file mode 100644index 002c910fea9..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/roi_tensors_tests/roi_tensors_tests.hpp+++ /dev/null@@ -1,1189 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_remote_tensor.hpp"-#include "intel_npu/utils/zero/zero_tensor.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/node_vector.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/level_zero/level_zero.hpp"-#include "openvino/runtime/iremote_tensor.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "remote_context.hpp"-#include "zero_backend.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class RoiTensorsTestsRun : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (const auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(target_device, configuration) = this->GetParam();- OVPluginTestBase::SetUp();-- isStridedEnabled();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-- std::shared_ptr<Model> createModelWithNInputs(element::Type type,- const PartialShape& shape,- const ov::Layout& layout,- size_t n = 1) {- ResultVector res;- ParameterVector params;-- for (size_t i = 0; i < n; i++) {- auto index_str = std::to_string(i);- auto data1 = std::make_shared<ov::op::v0::Parameter>(type, shape);- data1->set_friendly_name("input" + index_str);- data1->get_output_tensor(0).set_names({"tensor_input" + index_str});- data1->set_layout(layout);- auto constant = opset8::Constant::create(type, {1}, {1});- auto op1 = std::make_shared<ov::op::v1::Add>(data1, constant);- op1->set_friendly_name("Add" + index_str);- auto res1 = std::make_shared<ov::op::v0::Result>(op1);- res1->set_friendly_name("Result" + index_str);- res1->get_output_tensor(0).set_names({"tensor_output" + index_str});- params.push_back(data1);- res.push_back(res1);- }-- return std::make_shared<Model>(res, params);- }-- void isStridedEnabled() {- auto supportedProperties =- core->get_property(target_device, supported_properties.name()).as<std::vector<PropertyName>>();-- bool stridesEnabled =- std::any_of(supportedProperties.begin(), supportedProperties.end(), [](const auto& property) {- return property == ov::intel_npu::enable_strides_for.name();- });-- auto zeroInit = ::intel_npu::ZeroInitStructsHolder::getInstance();- if (zeroInit->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 16)) {- stridesEnabled = false;- }-- if (!stridesEnabled) {- GTEST_SKIP() << "NPU_ENABLE_STRIDES_FOR property is not supported";- }- }-};--TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabled) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(req.infer());-}--TEST_P(RoiTensorsTestsRun, CompileAndRunStridedTensorsPropertyEnabledInternalOperator) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});- auto input_strides = input_host_tensor.get_strides();- auto output_strides = output_host_tensor.get_strides();-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0,dummy";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);- OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));-- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));-- OV_ASSERT_NO_THROW(req.infer());-}--TEST_P(RoiTensorsTestsRun, CreateStridedTensorFromHostTensorAndRunInfer) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});- auto input_strides = input_host_tensor.get_strides();- auto output_strides = output_host_tensor.get_strides();-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);- OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));-- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);- output_view_tensor.copy_to(check_out_view_tensor);- auto* check_data = check_out_view_tensor.data<float>();- for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, SetStridedTensorForUnexpectedTensorExpectedThrow) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");- auto zero_context = core->get_default_context(target_device);- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});- auto output_strides = output_host_tensor.get_strides();-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0";- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- EXPECT_THROW(req.set_output_tensor(output_view_tensor), ov::Exception);-}--TEST_P(RoiTensorsTestsRun, SetStridedMultipleOutputTensorForUnexpectedTensorExpectedThrow) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...", 2);- auto zero_context = core->get_default_context(target_device);- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});- auto output_strides = output_host_tensor.get_strides();-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,tensor_output0";- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- EXPECT_THROW(req.set_output_tensor(1, output_view_tensor), ov::Exception);-}--TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInfer) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatching) {- auto shape = Shape{2, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorAndRunInferWithBatchingUpdateMCL) {- auto shape = Shape{2, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {3, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));-- ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor1.copy_to(check_out_roi_tensor1);- auto* check_data = check_out_roi_tensor1.data<float>();- for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- ov::Tensor input_roi_tensor2 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {2, 4, 5, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor2));-- ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor2.copy_to(check_out_roi_tensor2);- check_data = check_out_roi_tensor2.data<float>();- for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRunInferWithBatchingUpdateMCL) {- auto shape = Shape{2, 2, 2, 2};- auto batchedShape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});- ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_host_tensor, {2, 4, 4, 4}, {3, 6, 6, 6});- std::vector<ov::Tensor> tensors1;- tensors1.push_back(input_roi_tensor1_batched0);- tensors1.push_back(input_roi_tensor1_batched1);- OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););-- ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor1.copy_to(check_out_roi_tensor1);- auto* check_data = check_out_roi_tensor1.data<float>();- for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_host_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});- ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});-- std::vector<ov::Tensor> tensors2;- tensors2.push_back(input_roi_tensor2_batched0);- tensors2.push_back(input_roi_tensor2_batched1);- OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););-- ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor2.copy_to(check_out_roi_tensor2);- check_data = check_out_roi_tensor2.data<float>();- for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--TEST_P(RoiTensorsTestsRun, CreateRoiBatchedTensorsFromHostTensorAndRegularTensorAndRunInferWithBatchingUpdateMCL) {- auto shape = Shape{2, 2, 2, 2};- auto batchedShape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- auto input_regular_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};- input_data = input_regular_tensor.data<float>();- for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor1_batched0 = ov::Tensor(input_host_tensor, {1, 4, 4, 4}, {2, 6, 6, 6});- ov::Tensor input_roi_tensor1_batched1 = ov::Tensor(input_regular_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- std::vector<ov::Tensor> tensors1;- tensors1.push_back(input_roi_tensor1_batched0);- tensors1.push_back(input_roi_tensor1_batched1);- OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors1););-- ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {2, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor1.copy_to(check_out_roi_tensor1);- auto* check_data = check_out_roi_tensor1.data<float>();- for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- input_data = input_regular_tensor.data<float>();- for (size_t i = 0; i < input_regular_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }- input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- ov::Tensor input_roi_tensor2_batched0 = ov::Tensor(input_regular_tensor, {0, 2, 3, 4}, {1, 4, 5, 6});- ov::Tensor input_roi_tensor2_batched1 = ov::Tensor(input_host_tensor, {1, 2, 3, 4}, {2, 4, 5, 6});-- std::vector<ov::Tensor> tensors2;- tensors2.push_back(input_roi_tensor2_batched0);- tensors2.push_back(input_roi_tensor2_batched1);- OV_ASSERT_NO_THROW(req.set_tensors("tensor_input0", tensors2););-- ov::Tensor output_roi_tensor2 = ov::Tensor(output_host_tensor, {0, 0, 0, 0}, {2, 2, 2, 2});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor2));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor2 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor2.copy_to(check_out_roi_tensor2);- check_data = check_out_roi_tensor2.data<float>();- for (size_t i = 0; i < check_out_roi_tensor2.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--TEST_P(RoiTensorsTestsRun, FallbackOnMemcpy) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto input_tensor = ov::Tensor{ov::element::f32, Shape{1, 10, 10, 10}};- auto output_tensor = ov::Tensor{ov::element::f32, Shape{3, 8, 8, 8}};-- auto* input_data = input_tensor.data<float>();- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContext) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;- std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();- ::intel_npu::Config npu_config = ::intel_npu::Config(options);- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();-- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- Shape{1, 10, 10, 10});-- auto output_remote_tensor =- std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});-- auto input_tensor = make_tensor(input_remote_tensor);- auto output_tensor = make_tensor(output_remote_tensor);-- auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- init_struct = nullptr;-}--TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyToAnotherRemoteTensor) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;- std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();- ::intel_npu::Config npu_config = ::intel_npu::Config(options);- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();-- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- Shape{1, 10, 10, 10});-- auto output_remote_tensor =- std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});-- auto input_tensor = make_tensor(input_remote_tensor);- auto output_tensor = make_tensor(output_remote_tensor);-- auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- Shape{1, 8, 8, 10});- auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);- ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});- output_roi_tensor.copy_to(check_out_roi_tensor_roi);-- auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);- check_out_roi_tensor_roi.copy_to(check_out_roi_roi_tensor);- auto* check_data = check_out_roi_roi_tensor.data<float>();- for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- init_struct = nullptr;-}--TEST_P(RoiTensorsTestsRun, FallbackOnMemcpyRemoteTensorFromAnotherContextCopyFromAnotherRemoteTensor) {- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;- std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();- ::intel_npu::Config npu_config = ::intel_npu::Config(options);- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();-- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto input_remote_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- Shape{1, 10, 10, 10});-- auto output_remote_tensor =- std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, Shape{3, 8, 8, 8});-- auto input_tensor = make_tensor(input_remote_tensor);- auto output_tensor = make_tensor(output_remote_tensor);-- auto input_data = static_cast<float*>(input_remote_tensor->get_original_memory());- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto output_data = static_cast<float*>(output_remote_tensor->get_original_memory());- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {2, 4, 5, 6}, {3, 6, 7, 8});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context,- init_struct,- ov::element::f32,- Shape{1, 8, 8, 10});- auto check_out_roi_ov_tensor = make_tensor(check_out_roi_tensor);- ov::Tensor check_out_roi_tensor_roi = ov::Tensor(check_out_roi_ov_tensor, {0, 4, 5, 6}, {1, 6, 7, 8});- auto check_out_roi_remote_tensor_roi =- std::dynamic_pointer_cast<ov::IRemoteTensor>(get_tensor_impl(check_out_roi_tensor_roi)._ptr);- check_out_roi_remote_tensor_roi->copy_from(get_tensor_impl(output_roi_tensor)._ptr);-- auto check_out_roi_roi_tensor = ov::Tensor(ov::element::f32, shape);- check_out_roi_remote_tensor_roi->copy_to(get_tensor_impl(check_out_roi_roi_tensor)._ptr);- auto* check_data = check_out_roi_roi_tensor.data<float>();- for (size_t i = 0; i < req.get_output_tensor().get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- init_struct = nullptr;-}--TEST_P(RoiTensorsTestsRun, ImportStandardAllocation) {- auto shape = Shape{1, 2, 2, 1024};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto shape_input = Shape{1, 4, 8, 1024};- auto shape_output = Shape{1, 2, 4, 2048};-- auto input_data = static_cast<float*>(- ::operator new(ov::shape_size(shape_input) * ov::element::f32.size(), std::align_val_t(4096)));- auto output_data = static_cast<float*>(- ::operator new(ov::shape_size(shape_output) * ov::element::f32.size(), std::align_val_t(4096)));-- auto input_tensor = ov::Tensor{ov::element::f32, shape_input, input_data};- auto output_tensor = ov::Tensor{ov::element::f32, shape_output, output_data};-- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_tensor, {0, 0, 0, 0}, {1, 2, 2, 1024});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_tensor, {0, 0, 2, 0}, {1, 2, 4, 1024});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- req = {};- check_out_roi_tensor = {};- input_roi_tensor = {};- output_roi_tensor = {};- input_tensor = {};- output_tensor = {};-- ::operator delete(input_data, std::align_val_t(4096));- ::operator delete(output_data, std::align_val_t(4096));-}--TEST_P(RoiTensorsTestsRun, RunWithRemoteTensor) {- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 8, 8, 8});-- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto input_data = static_cast<float*>(input_remote_tensor.get());- for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto output_data = static_cast<float*>(output_remote_tensor.get());- for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor = ov::Tensor(input_remote_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_remote_tensor, {2, 5, 6, 6}, {3, 7, 8, 8});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);-- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, MultipleIOCreateRoiTensorFromHostTensorAndRunInfer) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...", 2);-- auto zero_context = core->get_default_context(target_device);- auto input0_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto input1_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 12, 15, 8});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});-- auto* input_data = input0_host_tensor.data<float>();- for (size_t i = 0; i < input0_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- input_data = input1_host_tensor.data<float>();- for (size_t i = 0; i < input1_host_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,input1,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input0_roi_tensor = ov::Tensor(input0_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(0, input0_roi_tensor));-- ov::Tensor input1_roi_tensor = ov::Tensor(input1_host_tensor, {1, 5, 7, 6}, {2, 7, 9, 8});- OV_ASSERT_NO_THROW(req.set_input_tensor(1, input1_roi_tensor));-- ov::Tensor output_roi_tensor = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(0, output_roi_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, shape);- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- auto check_out1_tensor = req.get_output_tensor(1);- check_data = check_out1_tensor.data<float>();- for (size_t i = 0; i < check_out1_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBatching) {- auto model_shape = PartialShape{-1, 5, 8, 9};- auto shape = Shape{2, 5, 8, 9};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, model_shape, "N...");- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});- auto input_strides = input_host_tensor.get_strides();- auto output_strides = output_host_tensor.get_strides();-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);- OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));-- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);- output_view_tensor.copy_to(check_out_view_tensor);- auto* check_data = check_out_view_tensor.data<float>();- for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, RunStridedTensorWithDynamicBoundedBatching) {- auto model_shape = PartialShape{ov::Dimension(1, 10), 5, 8, 9};- auto shape = Shape{2, 5, 8, 9};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, model_shape, "N...");- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{2, 25, 25, 25});- auto input_strides = input_host_tensor.get_strides();- auto output_strides = output_host_tensor.get_strides();-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_view_tensor = ov::Tensor(ov::element::f32, shape, input_host_tensor.data(), input_strides);- OV_ASSERT_NO_THROW(req.set_input_tensor(input_view_tensor));-- ov::Tensor output_view_tensor = ov::Tensor(ov::element::f32, shape, output_host_tensor.data(), output_strides);- OV_ASSERT_NO_THROW(req.set_output_tensor(output_view_tensor));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_view_tensor = ov::Tensor(ov::element::f32, shape);- output_view_tensor.copy_to(check_out_view_tensor);- auto* check_data = check_out_view_tensor.data<float>();- for (size_t i = 0; i < check_out_view_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-}--TEST_P(RoiTensorsTestsRun, TryToCompileStridedTensorWithDynamicBoundsExpectedThrow) {- auto model_shape = PartialShape{ov::Dimension(1, 10), 5, ov::Dimension(2, 15), 9};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, model_shape, "N...");-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- EXPECT_THROW(core->compile_model(model, target_device, configuration), ov::Exception);-}--TEST_P(RoiTensorsTestsRun, CreateRoiTensorFromHostTensorUpdateCommandListAndRunInfer) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor0 = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor0));-- ov::Tensor output_roi_tensor0 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor0));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor0 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor0.copy_to(check_out_roi_tensor0);- auto* check_data = check_out_roi_tensor0.data<float>();- for (size_t i = 0; i < check_out_roi_tensor0.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- ov::Tensor input_roi_tensor1 = ov::Tensor(input_host_tensor, {0, 5, 6, 8}, {1, 7, 8, 10});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor1));-- ov::Tensor output_roi_tensor1 = ov::Tensor(output_host_tensor, {0, 2, 19, 13}, {1, 4, 21, 15});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor1));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor1 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor1.copy_to(check_out_roi_tensor1);- check_data = check_out_roi_tensor1.data<float>();- for (size_t i = 0; i < check_out_roi_tensor1.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--TEST_P(RoiTensorsTestsRun, CheckRemoteCopyToWithRoiRemoteTensors) {- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});-- auto data = static_cast<float*>(input_remote_tensor.get());- for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {- data[i] = 50.0f;- }-- data = static_cast<float*>(output_remote_tensor.get());- for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {- data[i] = 10.0f;- }-- auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});- auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});-- input_roi_tensor.copy_to(output_roi_tensor);-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 50.0f);- }-}--TEST_P(RoiTensorsTestsRun, CheckRemoteCopyFromWithRoiRemoteTensors) {- auto zero_context = core->get_default_context(target_device).as<ov::intel_npu::level_zero::ZeroContext>();- auto input_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 10, 10, 10});- auto output_remote_tensor = zero_context.create_l0_host_tensor(ov::element::f32, Shape{3, 15, 12, 9});-- auto data = static_cast<float*>(input_remote_tensor.get());- for (size_t i = 0; i < input_remote_tensor.get_size(); ++i) {- data[i] = 50.0f;- }-- data = static_cast<float*>(output_remote_tensor.get());- for (size_t i = 0; i < output_remote_tensor.get_size(); ++i) {- data[i] = 10.0f;- }-- auto input_roi_tensor = ov::RemoteTensor(input_remote_tensor, {0, 4, 4, 4}, {2, 6, 6, 6});- auto output_roi_tensor = ov::RemoteTensor(output_remote_tensor, {1, 5, 6, 6}, {3, 7, 8, 8});- output_roi_tensor.copy_from(input_roi_tensor);-- auto check_out_roi_tensor = ov::Tensor(ov::element::f32, Shape{2, 2, 2, 2});- output_roi_tensor.copy_to(check_out_roi_tensor);- auto* check_data = check_out_roi_tensor.data<float>();- for (size_t i = 0; i < check_out_roi_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 50.0f);- }-}--TEST_P(RoiTensorsTestsRun, SetContiguousTensorAfterRoiAndCheckResults) {- auto shape = Shape{1, 2, 2, 2};- ov::CompiledModel compiled_model;- auto model = createModelWithNInputs(element::f32, shape, "N...");-- auto zero_context = core->get_default_context(target_device);- auto input_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 10, 10, 10});- auto output_host_tensor = zero_context.create_host_tensor(ov::element::f32, Shape{1, 25, 25, 25});-- auto* input_data = input_host_tensor.data<float>();- for (size_t i = 0; i < input_host_tensor.get_size(); ++i) {- input_data[i] = 50.0f;- }-- auto* output_data = output_host_tensor.data<float>();- for (size_t i = 0; i < output_host_tensor.get_size(); ++i) {- output_data[i] = 10.0f;- }-- configuration[ov::intel_npu::enable_strides_for.name()] = "input0,Result0";-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ov::InferRequest req;- OV_ASSERT_NO_THROW(req = compiled_model.create_infer_request());-- ov::Tensor input_roi_tensor0 = ov::Tensor(input_host_tensor, {0, 4, 4, 4}, {1, 6, 6, 6});- OV_ASSERT_NO_THROW(req.set_input_tensor(input_roi_tensor0));-- ov::Tensor output_roi_tensor0 = ov::Tensor(output_host_tensor, {0, 15, 15, 15}, {1, 17, 17, 17});- OV_ASSERT_NO_THROW(req.set_output_tensor(output_roi_tensor0));-- OV_ASSERT_NO_THROW(req.infer());-- auto check_out_roi_tensor0 = ov::Tensor(ov::element::f32, shape);- output_roi_tensor0.copy_to(check_out_roi_tensor0);- auto* check_data = check_out_roi_tensor0.data<float>();- for (size_t i = 0; i < check_out_roi_tensor0.get_size(); ++i) {- EXPECT_EQ(check_data[i], 51.0f);- }-- auto input_tensor = zero_context.create_host_tensor(ov::element::f32, shape);- OV_ASSERT_NO_THROW(req.set_input_tensor(input_tensor));-- auto output_tensor = zero_context.create_host_tensor(ov::element::f32, shape);- OV_ASSERT_NO_THROW(req.set_output_tensor(output_tensor));-- input_data = input_tensor.data<float>();- for (size_t i = 0; i < input_tensor.get_size(); ++i) {- input_data[i] = 75.0f;- }-- output_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- output_data[i] = 20.0f;- }-- OV_ASSERT_NO_THROW(req.infer());-- check_data = output_tensor.data<float>();- for (size_t i = 0; i < output_tensor.get_size(); ++i) {- EXPECT_EQ(check_data[i], 76.0f);- }-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.cpp b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.cppindex fca5a5a6b0a..7b17d6479e6 100644--- a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.cpp@@ -2,7 +2,724 @@// SPDX-License-Identifier: Apache-2.0//-#include "behavior/weights_separation.hpp"+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>++#include <cstddef>+#include <exception>++#include "behavior/ov_infer_request/inference.hpp"+#include "common/utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/graph_util.hpp"+#include "openvino/core/model_util.hpp"+#include "openvino/core/rt_info/weightless_caching_attributes.hpp"+#include "openvino/op/op.hpp"+#include "openvino/opsets/opset8.hpp"+#include "openvino/runtime/compiled_model.hpp"+#include "openvino/runtime/core.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using testing::_;+using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {++class WeightsSeparationTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+public:+ static std::string getTestCaseName(testing::TestParamInfo<CompilationParams> obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ }++ std::string generateCacheDirName(const std::string& test_name) {+ using namespace std::chrono;+ // Generate unique file names based on test name, thread id and timestamp+ // This allows execution of tests in parallel (stress mode)+ auto hash = std::to_string(std::hash<std::string>()(test_name));+ std::stringstream ss;+ auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());+ ss << hash << "_" << "_" << ts.count();+ return ss.str();+ }++ void TearDown() override {+ if (!m_cache_dir.empty()) {+ core->set_property({ov::cache_dir()});+ core.reset();+ ov::test::utils::PluginCache::get().reset();+ ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");+ ov::test::utils::removeDir(m_cache_dir);+ }++ if (!model_path.empty()) {+ utils::removeFile(model_path + ".xml");+ utils::removeFile(model_path + ".bin");+ }++ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }++ std::shared_ptr<ov::Model> createTestModel(const bool addWeightlessCacheAttribute = true,+ const bool alternativeWeights = false) {+ constexpr auto precision = element::f32;++ const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;+ auto weights = std::make_shared<op::v0::Constant>(precision, Shape{5}, std::vector<float>{weightsValue});+ auto input = std::make_shared<op::v0::Parameter>(precision, Shape{1});+ auto add = std::make_shared<op::v1::Add>(input, weights);++ weights->set_friendly_name("weights");+ input->set_friendly_name("input");+ add->set_friendly_name("add");++ if (addWeightlessCacheAttribute) {+ weights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights->get_byte_size(), 0, weights->get_element_type());+ }++ auto model = std::make_shared<Model>(OutputVector{add}, ParameterVector{input}, "Simple with weights");+ ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});+ return model;+ }++ // This is a special model that has weightless constants that are guaranteed+ // to be skipped by weights schedule. This tests cases where compiler+ // produces "blob with weights" when "weightless blob" is requested: in+ // theory, this may happen, and must not cause any errors.+ std::shared_ptr<ov::Model> createTestModelWeightlessWithDummyConstants() {+ constexpr auto precision = element::f32;++ const auto reshapeWeights =+ std::make_shared<op::v0::Constant>(element::i64, Shape{3}, std::vector<int64_t>{1, 2, 3});++ const auto input1 = std::make_shared<op::v0::Parameter>(precision, Shape{6});+ const auto input2 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 2, 3});+ const auto reshapedInput1 = std::make_shared<op::v1::Reshape>(input1, reshapeWeights, /*special_zero=*/false);+ auto add = std::make_shared<op::v1::Add>(reshapedInput1, input2);++ reshapeWeights->set_friendly_name("weights");+ input1->set_friendly_name("input1");+ input2->set_friendly_name("input2");+ reshapedInput1->set_friendly_name("reshapedInput1");+ add->set_friendly_name("add");++ // Note: Reshape weights with weightless cache attribute satisfy the+ // basic requirement to create weights schedule. However, since this is+ // a static reshape, these weights would "disappear" during compilation,+ // causing the compiler to put nothing into the weights schedule.+ reshapeWeights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(reshapeWeights->get_byte_size(), 0, reshapeWeights->get_element_type());++ auto model =+ std::make_shared<Model>(OutputVector{add}, ParameterVector{input1, input2}, "Dummy weightless model");+ ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});+ return model;+ }++ /**+ * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.+ */+ std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {+ ov::ParameterVector parameter_vector;+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(data);+ auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});+ auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);++ for (int i = 0; i < 10; i++) {+ auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});+ parameter_vector.push_back(intermediate_input);+ add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});+ add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());+ add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);+ add = std::make_shared<ov::op::v1::Add>(add, add_constant);+ }++ return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);+ }++ // This is a special test model with multiple constants using the same weights buffer.+ std::shared_ptr<ov::Model> createTestModelWeightlessWithDuplicateConstants() {+ const std::vector<float> sharedData{1.0f, 2.0f, 3.0f, 4.0f};+ constexpr auto precision = element::f32;++ auto input1 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 1, 4});+ auto input2 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 4, 1});++ auto weights1 = std::make_shared<op::v0::Constant>(precision, Shape{1, 1, 4}, sharedData);+ auto multiply1 = std::make_shared<op::v1::Multiply>(input1, weights1);++ auto weights2 = std::make_shared<op::v0::Constant>(precision, Shape{1, 4, 1}, sharedData);+ auto multiply2 = std::make_shared<op::v1::Multiply>(input2, weights2);++ auto reshapeWeights = std::make_shared<op::v0::Constant>(element::i64, Shape{3}, std::vector<int64_t>{1, 4, 1});+ auto reshape = std::make_shared<op::v1::Reshape>(multiply1, reshapeWeights, false);++ auto add = std::make_shared<op::v1::Add>(reshape, multiply2);++ input1->set_friendly_name("input1");+ input2->set_friendly_name("input2");+ weights1->set_friendly_name("weights");+ multiply1->set_friendly_name("multiply1");+ weights2->set_friendly_name("weights_new_shape");+ multiply2->set_friendly_name("multiply2");+ reshapeWeights->set_friendly_name("reshapeWeights");+ reshape->set_friendly_name("reshape");+ add->set_friendly_name("add");++ // Note: if this offset is changed, compiled_model->export_model() =>+ // core->import_model() would fail as the weightless bin offset is+ // "reset" through this boundary; right now this is by design+ constexpr size_t theOnlyFunctioningBinOffset = 0;+ weights1->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights1->get_byte_size(),+ theOnlyFunctioningBinOffset,+ weights1->get_element_type());+ weights2->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =+ ov::WeightlessCacheAttribute(weights2->get_byte_size(),+ theOnlyFunctioningBinOffset,+ weights2->get_element_type());++ auto model =+ std::make_shared<Model>(OutputVector{add}, ParameterVector{input1, input2}, "duplicate_weights_model");+ ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});+ return model;+ }++ Tensor from_stream(std::istream& stream, const size_t size) {+ ov::Tensor t(element::from<char>(), Shape{size});+ stream.read(t.data<char>(), size);+ return t;+ }++ void create_infer_request_and_check_result() {+ const ov::Tensor expected =+ utils::create_tensor(element::f32, Shape{5}, std::vector<float>{3.0f, 3.0f, 3.0f, 3.0f, 3.0f});+ const ov::Tensor input = utils::create_tensor(element::f32, Shape{1}, std::vector<float>{2.0f});+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input", input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ const ov::Tensor output = inference_request.get_tensor("add");+ OV_ASSERT_NO_THROW(utils::compare(expected, output));+ }++ // This is a "template" of a test used in multiple configurations+ void runCorrectInferenceResultIfCannotCompileAsWeightless();++protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<ov::Model> model;+ ov::CompiledModel compiled_model;+ ov::InferRequest inference_request;+ std::string m_cache_dir;+ std::string model_path;+};++/**+ * @brief The "one shot" implementation of the weights separation feature is not supported in the compiler-in-driver+ * case.+ */+TEST_P(WeightsSeparationTests, CheckOneShotVersionThrows) {+ model = createTestModel();+ configuration[ov::intel_npu::compiler_type.name()] = ov::intel_npu::CompilerType::DRIVER;+ configuration.insert(ov::enable_weightless(true));+ configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));+ OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);+}++/**+ * @brief The current implementation requires the WeightlessCacheAttribute to be found within at least one ov::Constant+ * node.+ */+TEST_P(WeightsSeparationTests, CheckForFailureNoWeightlessCacheAttribute) {+ model = createTestModel(false);+ configuration.insert(ov::enable_weightless(true));+ OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);+}++/**+ * @brief compile -> import using OV caching -> create inference request -> run one inference and check the result+ */+TEST_P(WeightsSeparationTests, CorrectInferenceResultIfCachingUsed) {+ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});++ model = createTestModel();+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_TRUE(compiled_model.get_property(ov::loaded_from_cache));++ create_infer_request_and_check_result();+}++/**+ * @brief compile -> import the result, ov::hint::model provided -> create inference request -> run one inference and+ * check the result+ */+TEST_P(WeightsSeparationTests, CorrectInferenceResultIfModelHintUsed) {+ model = createTestModel();+ configuration.insert(ov::enable_weightless(true));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::hint::model(model));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief compile -> import the result, ov::weights_path provided -> create inference request -> run one inference and+ * check the result+ */+TEST_P(WeightsSeparationTests, CorrectInferenceResultIfWeightsPathUsed) {+ model = createTestModel();++ model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();+ ov::serialize(model, model_path + ".xml", model_path + ".bin");++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::weights_path(model_path + ".bin"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief Providing the wrong weights to a weightless compiled model should produce incorrect results.+ */+TEST_P(WeightsSeparationTests, WrongInferenceResultIfWrongWeightsProvided) {+ model = createTestModel();++ const std::shared_ptr<ov::Model> different_model = createTestModel(false, true);+ model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();+ ov::serialize(different_model, model_path + ".xml", model_path + ".bin");++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::weights_path(model_path + ".bin"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ const ov::Tensor expected =+ utils::create_tensor(element::f32, Shape{5}, std::vector<float>{3.0f, 3.0f, 3.0f, 3.0f, 3.0f});+ const ov::Tensor input = utils::create_tensor(element::f32, Shape{1}, std::vector<float>{2.0f});+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input", input));+ OV_ASSERT_NO_THROW(inference_request.infer());++ const ov::Tensor output = inference_request.get_tensor("add");+ OV_EXPECT_THROW(utils::compare(expected, output), std::runtime_error, _);+}++/**+ * @brief compile -> delete .xml file -> import the result, ov::weights_path provided -> create inference request -> run+ * one inference and check the result+ */+TEST_P(WeightsSeparationTests, CorrectInferenceResultIfWeightsPathUsedAndModelFileDeleted) {+ model = createTestModel();++ model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();+ ov::serialize(model, model_path + ".xml", model_path + ".bin");++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ utils::removeFile(model_path + ".xml");++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::weights_path(model_path + ".bin"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief compile -> import the result shaped as a tensor, ov::hint::model provided -> create inference request -> run+ * one inference and check the result+ */+TEST_P(WeightsSeparationTests, CorrectInferenceResultIfTensorImported) {+ model = createTestModel();++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);+ ov::Tensor exported_model = from_stream(export_stream, export_stream.str().size());++ configuration.insert(ov::hint::model(model));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(exported_model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief compile -> attempt to import the result, failure is expected due to the missing weights+ */+TEST_P(WeightsSeparationTests, ImportFailureIfNoWeightsProvided) {+ model = createTestModel();++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_EXPECT_THROW(core->import_model(export_stream, target_device, configuration), ov::Exception, _);+}++/**+ * @brief A weightless compiled model is imported. Both ov::hint::model and ov::weights_path are provided.+ * ov::hint::model should have priority.+ */+TEST_P(WeightsSeparationTests, ModelHintHasPriorityOverWeightsPath) {+ model = createTestModel();++ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::hint::model(model));+ configuration.insert(ov::weights_path("this_file_does_not_exist"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be+ * weightless.+ */+TEST_P(WeightsSeparationTests, WeightfulIfCacheModeOptimizeSpeed) {+ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});++ model = createTestModel();+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SPEED));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be+ * weightless.+ */+TEST_P(WeightsSeparationTests, WeightlessIfCacheModeOptimizeSize) {+ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});++ model = createTestModel();+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_EXPECT_THROW(core->import_model(export_stream, target_device, configuration), ov::Exception, _);+}++/**+ * @brief ov::cache_mode is not taken into consideration if OV caching is disabled.+ */+TEST_P(WeightsSeparationTests, WeightfulIfCacheDirectoryNotProvided) {+ model = createTestModel();+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be+ * weightless. Otherwise, ov::enable_weightless is this switch.+ */+TEST_P(WeightsSeparationTests, CacheModeHasPriorityOverWeightlessBlobIfCachingIsUsed) {+ m_cache_dir = generateCacheDirName(GetTestName());+ core->set_property({ov::cache_dir(m_cache_dir)});++ model = createTestModel();++ configuration.emplace(ov::enable_weightless(true));+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SPEED));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be+ * weightless. Otherwise, ov::enable_weightless is this switch.+ */+TEST_P(WeightsSeparationTests, WeightlessBlobHasPriorityOverCacheModeIfCachingIsNotUsed) {+ model = createTestModel();++ configuration.emplace(ov::enable_weightless(false));+ configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ create_infer_request_and_check_result();+}++/**+ * @brief The weightless blob should have a smaller size compared to the standard one.+ */+TEST_P(WeightsSeparationTests, WeightlessBlobIsSmaller) {+ model = createTestModelLightInitSchedule();+ std::ostringstream weightfullBlobStream;+ configuration.insert(ov::enable_weightless(false));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ OV_ASSERT_NO_THROW(compiled_model.export_model(weightfullBlobStream));++ std::ostringstream weightlessBlobStream;+ configuration.at(ov::enable_weightless.name()) = true;++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ OV_ASSERT_NO_THROW(compiled_model.export_model(weightlessBlobStream));++ // At the moment of creating this test, the sizes on platform 3720 are 2019328 vs. 331776+ ASSERT_TRUE(weightfullBlobStream.str().size() > weightlessBlobStream.str().size());+}++void WeightsSeparationTests::runCorrectInferenceResultIfCannotCompileAsWeightless() {+ model = createTestModelWeightlessWithDummyConstants();++ model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();+ ov::serialize(model, model_path + ".xml", model_path + ".bin");++ // compilation should succeed+ configuration.insert(ov::enable_weightless(true));+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::weights_path(model_path + ".bin"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ // inference should also succeed+ const ov::Tensor input1 =+ utils::create_tensor(element::f32, Shape{6}, std::vector<float>{40.0f, 40.0f, 40.0f, 40.0f, 40.0f, 40.0f});+ const ov::Tensor input2 =+ utils::create_tensor(element::f32, Shape{1, 2, 3}, std::vector<float>{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f});+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input1", input1));+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input2", input2));+ OV_ASSERT_NO_THROW(inference_request.infer());++ const ov::Tensor expected = utils::create_tensor(element::f32,+ Shape{1, 2, 3},+ std::vector<float>{40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f});+ const ov::Tensor output = inference_request.get_tensor("add");+ OV_ASSERT_NO_THROW(utils::compare(expected, output));+}++TEST_P(WeightsSeparationTests, CorrectInferenceResultWeightlessWithDuplicateConstants) {+ model = createTestModelWeightlessWithDuplicateConstants();+ configuration.insert(ov::enable_weightless(true));++ model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();+ ov::serialize(model, model_path + ".xml", model_path + ".bin");++ // compilation should succeed+ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ std::stringstream export_stream;+ compiled_model.export_model(export_stream);++ configuration.insert(ov::weights_path(model_path + ".bin"));+ OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));+ ASSERT_TRUE(compiled_model);++ // inference should also succeed+ const ov::Tensor input1 = utils::create_tensor(element::f32, Shape{1, 1, 4}, std::vector<float>(4, -2.0f));+ const ov::Tensor input2 = utils::create_tensor(element::f32, Shape{1, 4, 1}, std::vector<float>(4, 0.0f));+ OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input1", input1));+ OV_ASSERT_NO_THROW(inference_request.set_tensor("input2", input2));+ OV_ASSERT_NO_THROW(inference_request.infer());++ const ov::Tensor expected =+ utils::create_tensor(element::f32, Shape{1, 4, 1}, std::vector<float>{-2.0f, -4.0f, -6.0f, -8.0f});+ const ov::Tensor output = inference_request.get_tensor("add");+ OV_ASSERT_NO_THROW(utils::compare(expected, output));+}++using WeightsSeparationOneShotTests = WeightsSeparationTests;++/**+ * @brief The "one shot" implementation of the weights separation feature is supported in the compiler-in-plugin case.+ */+TEST_P(WeightsSeparationOneShotTests, CorrectInferenceResultNoImportOneShot) {+ model = createTestModel();+ configuration.insert(ov::enable_weightless(true));+ configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ create_infer_request_and_check_result();+}++/**+ * @brief compile -> import the result, ov::weights_path provided -> create inference request -> run one inference and+ * check the result+ * compilation and inference must work even if the weightless model is not actually weightless+ * (compiler may not be able to find any "suitable" weights)+ */+TEST_P(WeightsSeparationOneShotTests, CorrectInferenceResultIfCannotCompileAsWeightlessOneShot) {+ configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));+ runCorrectInferenceResultIfCannotCompileAsWeightless();+}++using WeightsSeparationIterativeTests = WeightsSeparationTests;++/**+ * @brief Compiles a basic model and checks if it produces correct results.+ */+TEST_P(WeightsSeparationIterativeTests, CorrectInferenceResultNoImportIterative) {+ model = createTestModel();+ configuration.insert(ov::enable_weightless(true));+ configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE));++ OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));+ ASSERT_TRUE(compiled_model);+ EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));++ create_infer_request_and_check_result();+}++/**+ * @brief Compiles a special model in WeightsSeparation ITERATIVE mode to ensure+ * compilation succeeds. This is similar to the ONE_SHOT version test.+ */+TEST_P(WeightsSeparationIterativeTests, CorrectInferenceResultIfCannotCompileAsWeightlessIterative) {+ configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE));+ runCorrectInferenceResultIfCannotCompileAsWeightless();+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp b/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hppdeleted file mode 100644index 2b6c4a70ba7..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/weights_separation.hpp+++ /dev/null@@ -1,724 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <cstddef>-#include <exception>--#include "behavior/ov_infer_request/inference.hpp"-#include "common/utils.hpp"-#include "common_test_utils/ov_tensor_utils.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/graph_util.hpp"-#include "openvino/core/model_util.hpp"-#include "openvino/core/rt_info/weightless_caching_attributes.hpp"-#include "openvino/op/op.hpp"-#include "openvino/opsets/opset8.hpp"-#include "openvino/runtime/compiled_model.hpp"-#include "openvino/runtime/core.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using testing::_;-using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {--class WeightsSeparationTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-public:- static std::string getTestCaseName(testing::TestParamInfo<CompilationParams> obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- targetDevice = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- }-- std::string generateCacheDirName(const std::string& test_name) {- using namespace std::chrono;- // Generate unique file names based on test name, thread id and timestamp- // This allows execution of tests in parallel (stress mode)- auto hash = std::to_string(std::hash<std::string>()(test_name));- std::stringstream ss;- auto ts = duration_cast<nanoseconds>(high_resolution_clock::now().time_since_epoch());- ss << hash << "_" << "_" << ts.count();- return ss.str();- }-- void TearDown() override {- if (!m_cache_dir.empty()) {- core->set_property({ov::cache_dir()});- core.reset();- ov::test::utils::PluginCache::get().reset();- ov::test::utils::removeFilesWithExt<opt::FORCE>(m_cache_dir, "blob");- ov::test::utils::removeDir(m_cache_dir);- }-- if (!model_path.empty()) {- utils::removeFile(model_path + ".xml");- utils::removeFile(model_path + ".bin");- }-- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-- std::shared_ptr<ov::Model> createTestModel(const bool addWeightlessCacheAttribute = true,- const bool alternativeWeights = false) {- constexpr auto precision = element::f32;-- const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;- auto weights = std::make_shared<op::v0::Constant>(precision, Shape{5}, std::vector<float>{weightsValue});- auto input = std::make_shared<op::v0::Parameter>(precision, Shape{1});- auto add = std::make_shared<op::v1::Add>(input, weights);-- weights->set_friendly_name("weights");- input->set_friendly_name("input");- add->set_friendly_name("add");-- if (addWeightlessCacheAttribute) {- weights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights->get_byte_size(), 0, weights->get_element_type());- }-- auto model = std::make_shared<Model>(OutputVector{add}, ParameterVector{input}, "Simple with weights");- ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});- return model;- }-- // This is a special model that has weightless constants that are guaranteed- // to be skipped by weights schedule. This tests cases where compiler- // produces "blob with weights" when "weightless blob" is requested: in- // theory, this may happen, and must not cause any errors.- std::shared_ptr<ov::Model> createTestModelWeightlessWithDummyConstants() {- constexpr auto precision = element::f32;-- const auto reshapeWeights =- std::make_shared<op::v0::Constant>(element::i64, Shape{3}, std::vector<int64_t>{1, 2, 3});-- const auto input1 = std::make_shared<op::v0::Parameter>(precision, Shape{6});- const auto input2 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 2, 3});- const auto reshapedInput1 = std::make_shared<op::v1::Reshape>(input1, reshapeWeights, /*special_zero=*/false);- auto add = std::make_shared<op::v1::Add>(reshapedInput1, input2);-- reshapeWeights->set_friendly_name("weights");- input1->set_friendly_name("input1");- input2->set_friendly_name("input2");- reshapedInput1->set_friendly_name("reshapedInput1");- add->set_friendly_name("add");-- // Note: Reshape weights with weightless cache attribute satisfy the- // basic requirement to create weights schedule. However, since this is- // a static reshape, these weights would "disappear" during compilation,- // causing the compiler to put nothing into the weights schedule.- reshapeWeights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(reshapeWeights->get_byte_size(), 0, reshapeWeights->get_element_type());-- auto model =- std::make_shared<Model>(OutputVector{add}, ParameterVector{input1, input2}, "Dummy weightless model");- ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});- return model;- }-- /**- * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.- */- std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {- ov::ParameterVector parameter_vector;- auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});- parameter_vector.push_back(data);- auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});- auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);-- for (int i = 0; i < 10; i++) {- auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});- parameter_vector.push_back(intermediate_input);- add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});- add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());- add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);- add = std::make_shared<ov::op::v1::Add>(add, add_constant);- }-- return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);- }-- // This is a special test model with multiple constants using the same weights buffer.- std::shared_ptr<ov::Model> createTestModelWeightlessWithDuplicateConstants() {- const std::vector<float> sharedData{1.0f, 2.0f, 3.0f, 4.0f};- constexpr auto precision = element::f32;-- auto input1 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 1, 4});- auto input2 = std::make_shared<op::v0::Parameter>(precision, Shape{1, 4, 1});-- auto weights1 = std::make_shared<op::v0::Constant>(precision, Shape{1, 1, 4}, sharedData);- auto multiply1 = std::make_shared<op::v1::Multiply>(input1, weights1);-- auto weights2 = std::make_shared<op::v0::Constant>(precision, Shape{1, 4, 1}, sharedData);- auto multiply2 = std::make_shared<op::v1::Multiply>(input2, weights2);-- auto reshapeWeights = std::make_shared<op::v0::Constant>(element::i64, Shape{3}, std::vector<int64_t>{1, 4, 1});- auto reshape = std::make_shared<op::v1::Reshape>(multiply1, reshapeWeights, false);-- auto add = std::make_shared<op::v1::Add>(reshape, multiply2);-- input1->set_friendly_name("input1");- input2->set_friendly_name("input2");- weights1->set_friendly_name("weights");- multiply1->set_friendly_name("multiply1");- weights2->set_friendly_name("weights_new_shape");- multiply2->set_friendly_name("multiply2");- reshapeWeights->set_friendly_name("reshapeWeights");- reshape->set_friendly_name("reshape");- add->set_friendly_name("add");-- // Note: if this offset is changed, compiled_model->export_model() =>- // core->import_model() would fail as the weightless bin offset is- // "reset" through this boundary; right now this is by design- constexpr size_t theOnlyFunctioningBinOffset = 0;- weights1->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights1->get_byte_size(),- theOnlyFunctioningBinOffset,- weights1->get_element_type());- weights2->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =- ov::WeightlessCacheAttribute(weights2->get_byte_size(),- theOnlyFunctioningBinOffset,- weights2->get_element_type());-- auto model =- std::make_shared<Model>(OutputVector{add}, ParameterVector{input1, input2}, "duplicate_weights_model");- ov::util::set_tensors_names(AUTO, *model, {}, {{0, {"add"}}});- return model;- }-- Tensor from_stream(std::istream& stream, const size_t size) {- ov::Tensor t(element::from<char>(), Shape{size});- stream.read(t.data<char>(), size);- return t;- }-- void create_infer_request_and_check_result() {- const ov::Tensor expected =- utils::create_tensor(element::f32, Shape{5}, std::vector<float>{3.0f, 3.0f, 3.0f, 3.0f, 3.0f});- const ov::Tensor input = utils::create_tensor(element::f32, Shape{1}, std::vector<float>{2.0f});- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_tensor("input", input));- OV_ASSERT_NO_THROW(inference_request.infer());-- const ov::Tensor output = inference_request.get_tensor("add");- OV_ASSERT_NO_THROW(utils::compare(expected, output));- }-- // This is a "template" of a test used in multiple configurations- void runCorrectInferenceResultIfCannotCompileAsWeightless();--protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<ov::Model> model;- ov::CompiledModel compiled_model;- ov::InferRequest inference_request;- std::string m_cache_dir;- std::string model_path;-};--/**- * @brief The "one shot" implementation of the weights separation feature is not supported in the compiler-in-driver- * case.- */-TEST_P(WeightsSeparationTests, CheckOneShotVersionThrows) {- model = createTestModel();- configuration[ov::intel_npu::compiler_type.name()] = ov::intel_npu::CompilerType::DRIVER;- configuration.insert(ov::enable_weightless(true));- configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));- OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);-}--/**- * @brief The current implementation requires the WeightlessCacheAttribute to be found within at least one ov::Constant- * node.- */-TEST_P(WeightsSeparationTests, CheckForFailureNoWeightlessCacheAttribute) {- model = createTestModel(false);- configuration.insert(ov::enable_weightless(true));- OV_EXPECT_THROW(compiled_model = core->compile_model(model, target_device, configuration), ov::Exception, _);-}--/**- * @brief compile -> import using OV caching -> create inference request -> run one inference and check the result- */-TEST_P(WeightsSeparationTests, CorrectInferenceResultIfCachingUsed) {- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});-- model = createTestModel();- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_TRUE(compiled_model.get_property(ov::loaded_from_cache));-- create_infer_request_and_check_result();-}--/**- * @brief compile -> import the result, ov::hint::model provided -> create inference request -> run one inference and- * check the result- */-TEST_P(WeightsSeparationTests, CorrectInferenceResultIfModelHintUsed) {- model = createTestModel();- configuration.insert(ov::enable_weightless(true));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::hint::model(model));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief compile -> import the result, ov::weights_path provided -> create inference request -> run one inference and- * check the result- */-TEST_P(WeightsSeparationTests, CorrectInferenceResultIfWeightsPathUsed) {- model = createTestModel();-- model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();- ov::serialize(model, model_path + ".xml", model_path + ".bin");-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::weights_path(model_path + ".bin"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief Providing the wrong weights to a weightless compiled model should produce incorrect results.- */-TEST_P(WeightsSeparationTests, WrongInferenceResultIfWrongWeightsProvided) {- model = createTestModel();-- const std::shared_ptr<ov::Model> different_model = createTestModel(false, true);- model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();- ov::serialize(different_model, model_path + ".xml", model_path + ".bin");-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::weights_path(model_path + ".bin"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- const ov::Tensor expected =- utils::create_tensor(element::f32, Shape{5}, std::vector<float>{3.0f, 3.0f, 3.0f, 3.0f, 3.0f});- const ov::Tensor input = utils::create_tensor(element::f32, Shape{1}, std::vector<float>{2.0f});- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_tensor("input", input));- OV_ASSERT_NO_THROW(inference_request.infer());-- const ov::Tensor output = inference_request.get_tensor("add");- OV_EXPECT_THROW(utils::compare(expected, output), std::runtime_error, _);-}--/**- * @brief compile -> delete .xml file -> import the result, ov::weights_path provided -> create inference request -> run- * one inference and check the result- */-TEST_P(WeightsSeparationTests, CorrectInferenceResultIfWeightsPathUsedAndModelFileDeleted) {- model = createTestModel();-- model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();- ov::serialize(model, model_path + ".xml", model_path + ".bin");-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- utils::removeFile(model_path + ".xml");-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::weights_path(model_path + ".bin"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief compile -> import the result shaped as a tensor, ov::hint::model provided -> create inference request -> run- * one inference and check the result- */-TEST_P(WeightsSeparationTests, CorrectInferenceResultIfTensorImported) {- model = createTestModel();-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);- ov::Tensor exported_model = from_stream(export_stream, export_stream.str().size());-- configuration.insert(ov::hint::model(model));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(exported_model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief compile -> attempt to import the result, failure is expected due to the missing weights- */-TEST_P(WeightsSeparationTests, ImportFailureIfNoWeightsProvided) {- model = createTestModel();-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_EXPECT_THROW(core->import_model(export_stream, target_device, configuration), ov::Exception, _);-}--/**- * @brief A weightless compiled model is imported. Both ov::hint::model and ov::weights_path are provided.- * ov::hint::model should have priority.- */-TEST_P(WeightsSeparationTests, ModelHintHasPriorityOverWeightsPath) {- model = createTestModel();-- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::hint::model(model));- configuration.insert(ov::weights_path("this_file_does_not_exist"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless.- */-TEST_P(WeightsSeparationTests, WeightfulIfCacheModeOptimizeSpeed) {- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});-- model = createTestModel();- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SPEED));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless.- */-TEST_P(WeightsSeparationTests, WeightlessIfCacheModeOptimizeSize) {- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});-- model = createTestModel();- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_EXPECT_THROW(core->import_model(export_stream, target_device, configuration), ov::Exception, _);-}--/**- * @brief ov::cache_mode is not taken into consideration if OV caching is disabled.- */-TEST_P(WeightsSeparationTests, WeightfulIfCacheDirectoryNotProvided) {- model = createTestModel();- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless. Otherwise, ov::enable_weightless is this switch.- */-TEST_P(WeightsSeparationTests, CacheModeHasPriorityOverWeightlessBlobIfCachingIsUsed) {- m_cache_dir = generateCacheDirName(GetTestName());- core->set_property({ov::cache_dir(m_cache_dir)});-- model = createTestModel();-- configuration.emplace(ov::enable_weightless(true));- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SPEED));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief If OV caching is used, then ov::cache_mode tells the plugin whether or not the compiled model should be- * weightless. Otherwise, ov::enable_weightless is this switch.- */-TEST_P(WeightsSeparationTests, WeightlessBlobHasPriorityOverCacheModeIfCachingIsNotUsed) {- model = createTestModel();-- configuration.emplace(ov::enable_weightless(false));- configuration.emplace(ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- create_infer_request_and_check_result();-}--/**- * @brief The weightless blob should have a smaller size compared to the standard one.- */-TEST_P(WeightsSeparationTests, WeightlessBlobIsSmaller) {- model = createTestModelLightInitSchedule();- std::ostringstream weightfullBlobStream;- configuration.insert(ov::enable_weightless(false));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- OV_ASSERT_NO_THROW(compiled_model.export_model(weightfullBlobStream));-- std::ostringstream weightlessBlobStream;- configuration.at(ov::enable_weightless.name()) = true;-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- OV_ASSERT_NO_THROW(compiled_model.export_model(weightlessBlobStream));-- // At the moment of creating this test, the sizes on platform 3720 are 2019328 vs. 331776- ASSERT_TRUE(weightfullBlobStream.str().size() > weightlessBlobStream.str().size());-}--void WeightsSeparationTests::runCorrectInferenceResultIfCannotCompileAsWeightless() {- model = createTestModelWeightlessWithDummyConstants();-- model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();- ov::serialize(model, model_path + ".xml", model_path + ".bin");-- // compilation should succeed- configuration.insert(ov::enable_weightless(true));- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::weights_path(model_path + ".bin"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- // inference should also succeed- const ov::Tensor input1 =- utils::create_tensor(element::f32, Shape{6}, std::vector<float>{40.0f, 40.0f, 40.0f, 40.0f, 40.0f, 40.0f});- const ov::Tensor input2 =- utils::create_tensor(element::f32, Shape{1, 2, 3}, std::vector<float>{0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f});- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_tensor("input1", input1));- OV_ASSERT_NO_THROW(inference_request.set_tensor("input2", input2));- OV_ASSERT_NO_THROW(inference_request.infer());-- const ov::Tensor expected = utils::create_tensor(element::f32,- Shape{1, 2, 3},- std::vector<float>{40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f});- const ov::Tensor output = inference_request.get_tensor("add");- OV_ASSERT_NO_THROW(utils::compare(expected, output));-}--TEST_P(WeightsSeparationTests, CorrectInferenceResultWeightlessWithDuplicateConstants) {- model = createTestModelWeightlessWithDuplicateConstants();- configuration.insert(ov::enable_weightless(true));-- model_path = ov::util::path_join({utils::getCurrentWorkingDir(), utils::generateTestFilePrefix()}).string();- ov::serialize(model, model_path + ".xml", model_path + ".bin");-- // compilation should succeed- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);-- std::stringstream export_stream;- compiled_model.export_model(export_stream);-- configuration.insert(ov::weights_path(model_path + ".bin"));- OV_ASSERT_NO_THROW(compiled_model = core->import_model(export_stream, target_device, configuration));- ASSERT_TRUE(compiled_model);-- // inference should also succeed- const ov::Tensor input1 = utils::create_tensor(element::f32, Shape{1, 1, 4}, std::vector<float>(4, -2.0f));- const ov::Tensor input2 = utils::create_tensor(element::f32, Shape{1, 4, 1}, std::vector<float>(4, 0.0f));- OV_ASSERT_NO_THROW(inference_request = compiled_model.create_infer_request());- OV_ASSERT_NO_THROW(inference_request.set_tensor("input1", input1));- OV_ASSERT_NO_THROW(inference_request.set_tensor("input2", input2));- OV_ASSERT_NO_THROW(inference_request.infer());-- const ov::Tensor expected =- utils::create_tensor(element::f32, Shape{1, 4, 1}, std::vector<float>{-2.0f, -4.0f, -6.0f, -8.0f});- const ov::Tensor output = inference_request.get_tensor("add");- OV_ASSERT_NO_THROW(utils::compare(expected, output));-}--using WeightsSeparationOneShotTests = WeightsSeparationTests;--/**- * @brief The "one shot" implementation of the weights separation feature is supported in the compiler-in-plugin case.- */-TEST_P(WeightsSeparationOneShotTests, CorrectInferenceResultNoImportOneShot) {- model = createTestModel();- configuration.insert(ov::enable_weightless(true));- configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- create_infer_request_and_check_result();-}--/**- * @brief compile -> import the result, ov::weights_path provided -> create inference request -> run one inference and- * check the result- * compilation and inference must work even if the weightless model is not actually weightless- * (compiler may not be able to find any "suitable" weights)- */-TEST_P(WeightsSeparationOneShotTests, CorrectInferenceResultIfCannotCompileAsWeightlessOneShot) {- configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT));- runCorrectInferenceResultIfCannotCompileAsWeightless();-}--using WeightsSeparationIterativeTests = WeightsSeparationTests;--/**- * @brief Compiles a basic model and checks if it produces correct results.- */-TEST_P(WeightsSeparationIterativeTests, CorrectInferenceResultNoImportIterative) {- model = createTestModel();- configuration.insert(ov::enable_weightless(true));- configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE));-- OV_ASSERT_NO_THROW(compiled_model = core->compile_model(model, target_device, configuration));- ASSERT_TRUE(compiled_model);- EXPECT_FALSE(compiled_model.get_property(ov::loaded_from_cache));-- create_infer_request_and_check_result();-}--/**- * @brief Compiles a special model in WeightsSeparation ITERATIVE mode to ensure- * compilation succeeds. This is similar to the ONE_SHOT version test.- */-TEST_P(WeightsSeparationIterativeTests, CorrectInferenceResultIfCannotCompileAsWeightlessIterative) {- configuration.insert(ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE));- runCorrectInferenceResultIfCannotCompileAsWeightless();-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.cpp b/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.cppindex b8e3312d5c9..8ff435ecf65 100644--- a/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.cpp@@ -2,13 +2,180 @@// SPDX-License-Identifier: Apache-2.0//-#include "behavior/work_with_devices.hpp"+#include <cstring>+#include <string>+#include <vector>+#include "common/functions.hpp"+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"#include "intel_npu/config/options.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using CompilerType = ov::intel_npu::CompilerType;namespace {+class TestCompiledModelNPU : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<std::tuple<std::string, ov::AnyMap>> {+public:+ void SetUp() override {+ std::tie(target_device, configuration) = GetParam();+ OVPluginTestBase::SetUp();+ }++ static std::string getTestCaseName(const testing::TestParamInfo<std::tuple<std::string, ov::AnyMap>>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');+ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ using namespace ov::test::utils;+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++protected:+ ov::AnyMap configuration;+ std::shared_ptr<ov::Core> core = ov::test::utils::PluginCache::get().core();+};++TEST_P(TestCompiledModelNPU, samePlatformProduceTheSameBlob) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ configuration[ov::intel_npu::defer_weights_load.name()] = true;+ auto configuration1 = configuration;+ const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();+ auto compiled_model1 = core->compile_model(ov_model1, target_device, configuration1);+ std::stringstream blobStream1;+ compiled_model1.export_model(blobStream1);++ auto configuration2 = configuration;+ const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();+ auto compiled_model2 = core->compile_model(ov_model2, target_device, configuration2);+ std::stringstream blobStream2;+ compiled_model2.export_model(blobStream2);++ ASSERT_NE(0, blobStream1.str().size());+ ASSERT_EQ(0, std::memcmp(blobStream1.str().c_str(), blobStream2.str().c_str(), blobStream1.str().size()));+ }+}++TEST_P(TestCompiledModelNPU, samePlatformProduceTheSameBlobCacheEnabled) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ // compiled model (uncached)+ configuration[ov::intel_npu::defer_weights_load.name()] = true;+ auto configuration1 = configuration;+ const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();+ auto compiled_model1 = core->compile_model(ov_model1, target_device, configuration1);+ std::stringstream blobStream1;+ compiled_model1.export_model(blobStream1);++ // cached blobs+ auto configuration2 = configuration;+ configuration2[ov::intel_npu::bypass_umd_caching.name()] = false;+ const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();+ // call compile_model() twice to make sure compiled model is cached+ auto compiled_model2 = core->compile_model(ov_model2, target_device, configuration2);+ // Workaround: destroy graph to force driver to close file descriptor to cache file+ compiled_model2 = {};++ auto compiled_model3 = core->compile_model(ov_model2, target_device, configuration2);+ std::stringstream blobStream3;+ compiled_model3.export_model(blobStream3);++ ASSERT_NE(0, blobStream1.str().size());+ ASSERT_EQ(0, std::memcmp(blobStream1.str().c_str(), blobStream3.str().c_str(), blobStream1.str().size()));+ }+}++class TestCompileModelWithoutDeviceNPU : public TestCompiledModelNPU {+protected:+ void SetUp() override {+ const auto devices = core->get_available_devices();+ const auto isNPUDeviceAvailable =+ std::find_if(devices.cbegin(), devices.cend(), [this](const std::string& device) {+ return device.find(target_device) != std::string::npos;+ }) != devices.cend();+ if (isNPUDeviceAvailable) {+ GTEST_SKIP() << "Skip the tests since device is available";+ }+ }+};++TEST_P(TestCompileModelWithoutDeviceNPU, ThrowIfNoDeviceAndNoPlatform) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ const auto& ov_model = buildSingleLayerSoftMaxNetwork();+ ASSERT_THROW(auto compiled_model = core->compile_model(ov_model, target_device, configuration), ov::Exception);+ }+}++TEST_P(TestCompileModelWithoutDeviceNPU, NoThrowIfNoDeviceAndButPlatformPassed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ auto netConfiguration = configuration;+ netConfiguration[ov::intel_npu::platform.name()] = ov::test::utils::getTestsPlatformFromEnvironmentOr("3720");+ const auto& ov_model = buildSingleLayerSoftMaxNetwork();+ OV_ASSERT_NO_THROW(auto compiled_model = core->compile_model(ov_model, target_device, netConfiguration));+ }+}++const std::map<std::string_view, std::array<std::string_view, 2>> wrongDevice = {+ // {orig, {wrong for PLUGIN}}+ {"VPU3720", {"VPU0000"}},+};++std::string getWrongDevice(const std::string_view platform, const CompilerType&) {+ // here we mix up devices in order to test the check on the runtime side+ auto device = wrongDevice.find(platform);++ if (device == wrongDevice.end()) {+ OPENVINO_THROW("Cannot map wrong device for the platform ", platform);+ }+ return std::string(device->second[0]);+}++const std::map<std::string_view, std::array<std::string_view, 2>> validDevice = {+ // {orig, {valid for PLUGIN}}+ {"VPU3720", {"VPU3720"}}};++std::string getValidDevice(const std::string_view platform, const CompilerType&) {+ auto device = validDevice.find(platform);++ if (device == validDevice.end()) {+ OPENVINO_THROW("Cannot map valid device for the platform ", platform);+ }+ return std::string(device->second[0]);+}++TEST_P(TestCompileModelWithoutDeviceNPU, CheckDeviceInBlob) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED() {+ // Compile model to target plugins, wrong platform specified -> expect an exception+ auto netConfigurationPLUGIN_wrong = configuration;+ netConfigurationPLUGIN_wrong[ov::intel_npu::platform.name()] =+ getWrongDevice(PlatformEnvironment::PLATFORM, CompilerType::PLUGIN);+ netConfigurationPLUGIN_wrong[ov::intel_npu::compiler_type.name()] = "PLUGIN";+ const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();+ EXPECT_ANY_THROW(auto compiled_model =+ core->compile_model(ov_model1, target_device, netConfigurationPLUGIN_wrong));++ // Compile model to target plugins, valid platform specified -> expect no exception+ auto netConfigurationPLUGIN_valid = configuration;+ netConfigurationPLUGIN_valid[ov::intel_npu::platform.name()] =+ getValidDevice(PlatformEnvironment::PLATFORM, CompilerType::PLUGIN);+ netConfigurationPLUGIN_valid[ov::intel_npu::compiler_type.name()] = "PLUGIN";+ const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();+ EXPECT_NO_THROW(auto compiled_model =+ core->compile_model(ov_model2, target_device, netConfigurationPLUGIN_valid));+ }+}+const std::vector<ov::AnyMap> configs = {{{ov::intel_npu::bypass_umd_caching(true),// Test manipulates UMD caching, compiler needs to be set to CiDov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}}};diff --git a/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.hpp b/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.hppdeleted file mode 100644index 718fe241be1..00000000000--- a/src/plugins/intel_npu/tests/functional/behavior/work_with_devices.hpp+++ /dev/null@@ -1,180 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <cstring>-#include <string>-#include <vector>--#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "common/functions.hpp"-#include "common/npu_test_env_cfg.hpp"-#include "intel_npu/config/options.hpp"-#include "intel_npu/npu_private_properties.hpp"--using CompilerType = ov::intel_npu::CompilerType;--namespace {--class TestCompiledModelNPU : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<std::tuple<std::string, ov::AnyMap>> {-public:- void SetUp() override {- std::tie(target_device, configuration) = GetParam();- OVPluginTestBase::SetUp();- }-- static std::string getTestCaseName(const testing::TestParamInfo<std::tuple<std::string, ov::AnyMap>>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '.');- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- using namespace ov::test::utils;- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }--protected:- ov::AnyMap configuration;- std::shared_ptr<ov::Core> core = ov::test::utils::PluginCache::get().core();-};--TEST_P(TestCompiledModelNPU, samePlatformProduceTheSameBlob) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- configuration[ov::intel_npu::defer_weights_load.name()] = true;- auto configuration1 = configuration;- const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();- auto compiled_model1 = core->compile_model(ov_model1, target_device, configuration1);- std::stringstream blobStream1;- compiled_model1.export_model(blobStream1);-- auto configuration2 = configuration;- const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();- auto compiled_model2 = core->compile_model(ov_model2, target_device, configuration2);- std::stringstream blobStream2;- compiled_model2.export_model(blobStream2);-- ASSERT_NE(0, blobStream1.str().size());- ASSERT_EQ(0, std::memcmp(blobStream1.str().c_str(), blobStream2.str().c_str(), blobStream1.str().size()));- }-}--TEST_P(TestCompiledModelNPU, samePlatformProduceTheSameBlobCacheEnabled) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- // compiled model (uncached)- configuration[ov::intel_npu::defer_weights_load.name()] = true;- auto configuration1 = configuration;- const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();- auto compiled_model1 = core->compile_model(ov_model1, target_device, configuration1);- std::stringstream blobStream1;- compiled_model1.export_model(blobStream1);-- // cached blobs- auto configuration2 = configuration;- configuration2[ov::intel_npu::bypass_umd_caching.name()] = false;- const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();- // call compile_model() twice to make sure compiled model is cached- auto compiled_model2 = core->compile_model(ov_model2, target_device, configuration2);- // Workaround: destroy graph to force driver to close file descriptor to cache file- compiled_model2 = {};-- auto compiled_model3 = core->compile_model(ov_model2, target_device, configuration2);- std::stringstream blobStream3;- compiled_model3.export_model(blobStream3);-- ASSERT_NE(0, blobStream1.str().size());- ASSERT_EQ(0, std::memcmp(blobStream1.str().c_str(), blobStream3.str().c_str(), blobStream1.str().size()));- }-}--class TestCompileModelWithoutDeviceNPU : public TestCompiledModelNPU {-protected:- void SetUp() override {- const auto devices = core->get_available_devices();- const auto isNPUDeviceAvailable =- std::find_if(devices.cbegin(), devices.cend(), [this](const std::string& device) {- return device.find(target_device) != std::string::npos;- }) != devices.cend();- if (isNPUDeviceAvailable) {- GTEST_SKIP() << "Skip the tests since device is available";- }- }-};--TEST_P(TestCompileModelWithoutDeviceNPU, ThrowIfNoDeviceAndNoPlatform) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- const auto& ov_model = buildSingleLayerSoftMaxNetwork();- ASSERT_THROW(auto compiled_model = core->compile_model(ov_model, target_device, configuration), ov::Exception);- }-}--TEST_P(TestCompileModelWithoutDeviceNPU, NoThrowIfNoDeviceAndButPlatformPassed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- auto netConfiguration = configuration;- netConfiguration[ov::intel_npu::platform.name()] = ov::test::utils::getTestsPlatformFromEnvironmentOr("3720");- const auto& ov_model = buildSingleLayerSoftMaxNetwork();- OV_ASSERT_NO_THROW(auto compiled_model = core->compile_model(ov_model, target_device, netConfiguration));- }-}--const std::map<std::string_view, std::array<std::string_view, 2>> wrongDevice = {- // {orig, {wrong for PLUGIN}}- {"VPU3720", {"VPU0000"}},-};--std::string getWrongDevice(const std::string_view platform, const CompilerType&) {- // here we mix up devices in order to test the check on the runtime side- auto device = wrongDevice.find(platform);-- if (device == wrongDevice.end()) {- OPENVINO_THROW("Cannot map wrong device for the platform ", platform);- }- return std::string(device->second[0]);-}--const std::map<std::string_view, std::array<std::string_view, 2>> validDevice = {- // {orig, {valid for PLUGIN}}- {"VPU3720", {"VPU3720"}}};--std::string getValidDevice(const std::string_view platform, const CompilerType&) {- auto device = validDevice.find(platform);-- if (device == validDevice.end()) {- OPENVINO_THROW("Cannot map valid device for the platform ", platform);- }- return std::string(device->second[0]);-}--TEST_P(TestCompileModelWithoutDeviceNPU, CheckDeviceInBlob) {- SKIP_IF_CURRENT_TEST_IS_DISABLED() {- // Compile model to target plugins, wrong platform specified -> expect an exception- auto netConfigurationPLUGIN_wrong = configuration;- netConfigurationPLUGIN_wrong[ov::intel_npu::platform.name()] =- getWrongDevice(PlatformEnvironment::PLATFORM, CompilerType::PLUGIN);- netConfigurationPLUGIN_wrong[ov::intel_npu::compiler_type.name()] = "PLUGIN";- const auto& ov_model1 = buildSingleLayerSoftMaxNetwork();- EXPECT_ANY_THROW(auto compiled_model =- core->compile_model(ov_model1, target_device, netConfigurationPLUGIN_wrong));-- // Compile model to target plugins, valid platform specified -> expect no exception- auto netConfigurationPLUGIN_valid = configuration;- netConfigurationPLUGIN_valid[ov::intel_npu::platform.name()] =- getValidDevice(PlatformEnvironment::PLATFORM, CompilerType::PLUGIN);- netConfigurationPLUGIN_valid[ov::intel_npu::compiler_type.name()] = "PLUGIN";- const auto& ov_model2 = buildSingleLayerSoftMaxNetwork();- EXPECT_NO_THROW(auto compiled_model =- core->compile_model(ov_model2, target_device, netConfigurationPLUGIN_valid));- }-}--} // namespacediff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.cppindex 1cdfc1ea899..fb543f171ff 100644--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.cpp@@ -2,7 +2,77 @@// SPDX-License-Identifier: Apache-2.0//-#include "zero_device_tests.hpp"+#include <algorithm>+#include <gtest/gtest.h>+#include <memory>+#include <sstream>+#include <string>+#include <tuple>++#include "common/npu_test_env_cfg.hpp"+#include "common_test_utils/test_assertions.hpp"+#include "functional_test_utils/skip_tests_config.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "zero_device.hpp"++namespace ov::test::behavior {++using namespace ::intel_npu;++using ZeroDeviceTestParams = std::tuple<std::string, ov::AnyMap>;++class ZeroDeviceTest : public ::testing::TestWithParam<ZeroDeviceTestParams> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<ZeroDeviceTestParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice);+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "_configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ return result.str();+ }++protected:+ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(targetDevice, configuration) = this->GetParam();++ zeroInitStruct = ZeroInitStructsHolder::getInstance();+ ASSERT_NE(zeroInitStruct, nullptr);+ ASSERT_NE(zeroInitStruct->getDevice(), nullptr);++ device = std::make_unique<ZeroDevice>(zeroInitStruct);+ }++ std::string targetDevice;+ ov::AnyMap configuration;+ std::shared_ptr<ZeroInitStructsHolder> zeroInitStruct;+ std::unique_ptr<ZeroDevice> device;+};++// E2E tests fail earlier (at metadata parse), so this narrow unit test provides+// the only coverage for the L0 driver validation branch with invalid descriptors.+TEST_P(ZeroDeviceTest, ValidateRejectsInvalidString) {+ if (zeroInitStruct->getZeDrvApiVersion() < ZE_MAKE_VERSION(1, 16)) {+ ASSERT_ANY_THROW(device->validateCompatibilityDescriptor("not_a_valid_compat_string"));+ } else {+ bool isCompatible = true;+ OV_ASSERT_NO_THROW(isCompatible = device->validateCompatibilityDescriptor("not_a_valid_compat_string"));+ EXPECT_FALSE(isCompatible);+ }+}++} // namespace ov::test::behaviornamespace {using namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.hppdeleted file mode 100644index 801464ddad3..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_device_tests.hpp+++ /dev/null@@ -1,78 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>--#include <algorithm>-#include <memory>-#include <sstream>-#include <string>-#include <tuple>--#include "common/npu_test_env_cfg.hpp"-#include "common_test_utils/test_assertions.hpp"-#include "functional_test_utils/skip_tests_config.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "zero_device.hpp"--namespace ov::test::behavior {--using namespace ::intel_npu;--using ZeroDeviceTestParams = std::tuple<std::string, ov::AnyMap>;--class ZeroDeviceTest : public ::testing::TestWithParam<ZeroDeviceTestParams> {-public:- static std::string getTestCaseName(const testing::TestParamInfo<ZeroDeviceTestParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice);- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "_configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- return result.str();- }--protected:- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(targetDevice, configuration) = this->GetParam();-- zeroInitStruct = ZeroInitStructsHolder::getInstance();- ASSERT_NE(zeroInitStruct, nullptr);- ASSERT_NE(zeroInitStruct->getDevice(), nullptr);-- device = std::make_unique<ZeroDevice>(zeroInitStruct);- }-- std::string targetDevice;- ov::AnyMap configuration;- std::shared_ptr<ZeroInitStructsHolder> zeroInitStruct;- std::unique_ptr<ZeroDevice> device;-};--// E2E tests fail earlier (at metadata parse), so this narrow unit test provides-// the only coverage for the L0 driver validation branch with invalid descriptors.-TEST_P(ZeroDeviceTest, ValidateRejectsInvalidString) {- if (zeroInitStruct->getZeDrvApiVersion() < ZE_MAKE_VERSION(1, 16)) {- ASSERT_ANY_THROW(device->validateCompatibilityDescriptor("not_a_valid_compat_string"));- } else {- bool isCompatible = true;- OV_ASSERT_NO_THROW(isCompatible = device->validateCompatibilityDescriptor("not_a_valid_compat_string"));- EXPECT_FALSE(isCompatible);- }-}--} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cppindex 43b466c131a..5c82c187e1c 100644--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp@@ -2,7 +2,339 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/backend/zero_infer_request_tests.hpp"+#include <gtest/gtest.h>++#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "common/zero_init_mock.hpp"+#include "common_test_utils/file_utils.hpp"+#include "common_test_utils/ov_plugin_cache.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "compiled_model.hpp"+#include "driver_compiler_adapter.hpp"+#include "graph.hpp"+#include "intel_npu/common/compiler_adapter_factory.hpp"+#include "intel_npu/common/device_helpers.hpp"+#include "intel_npu/config/config.hpp"+#include "intel_npu/utils/utils.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/less_eq.hpp"+#include "openvino/op/non_zero.hpp"+#include "openvino/op/shape_of.hpp"+#include "openvino/openvino.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "plugin_compiler_adapter.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "transformations.hpp"+#include "zero_backend.hpp"+#include "zero_infer_request.hpp"++namespace {+[[maybe_unused]] std::shared_ptr<ov::Model> make_2_input_less_eq(const ov::Shape& input_shape = {2, 16, 16, 16}) {+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);+ param0->get_output_tensor(0).set_names({"tensor_input_0"});+ param0->set_layout("N...");+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);+ param1->get_output_tensor(0).set_names({"tensor_input_1"});+ param1->set_layout("N...");+ auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);+ auto result = std::make_shared<ov::op::v0::Result>(lessEqual);+ result->get_output_tensor(0).set_names({"tensor_output"});++ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});+ model->set_friendly_name("TwoInputLessEqual");+ return model;+}++std::shared_ptr<ov::Model> make_2_input_less_eq_non_zero(const ov::Shape& input_shape = {2, 16, 16, 16}) {+ auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);+ param0->get_output_tensor(0).set_names({"tensor_input_0"});+ param0->set_layout("N...");+ auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);+ param1->get_output_tensor(0).set_names({"tensor_input_1"});+ param1->set_layout("N...");+ auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);+ auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);+ // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input+ // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf+ auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);+ auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);+ auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);+ auto result = std::make_shared<ov::op::v0::Result>(add);+ result->get_output_tensor(0).set_names({"tensor_output"});++ auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});+ model->set_friendly_name("TwoTwoInputNonZeroAddModel");+ return model;+}++} // namespace++namespace ov {+namespace test {+namespace behavior {+namespace {++using CompilationParamsAndTensorDataType =+ std::tuple<std::string, // Device name+ ov::AnyMap, // Config+ ov::element::Type, // Tensor data type+ bool, // With warmup infer+ bool, // With reset infer request+ std::pair<uint32_t, uint32_t>>; // Graph Ext Version and Mutable Command List Version+} // namespace++class ZeroInferRequestTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParamsAndTensorDataType> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ ov::element::Type element_type;+ bool withWarmUpInfer;+ bool withResetInferRequest;+ uint32_t zeGraphNpuExtVersion;+ uint32_t zeMutableCommandListExtVersion;+ std::unique_ptr<::intel_npu::FilteredConfig> npu_config;+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zeroInitStruct;+ std::shared_ptr<ov::Model> ov_model;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndTensorDataType>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ ov::element::Type type;+ bool withWarmUpInfer;+ bool withResetInferRequest;+ std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;++ std::tie(targetDevice,+ configuration,+ type,+ withWarmUpInfer,+ withResetInferRequest,+ graphExtMutableCommandListExtPair) = obj.param;+ auto [zeGraphNpuExtVersion, zeMutableCommandListExtVersion] = graphExtMutableCommandListExtPair;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ result << "_";+ }+ }+ if (!type.get_type_name().empty()) {+ result << "tensorDataType=" << type.get_type_name() << "_";+ }++ result << "withWarmUpInfer=" << withWarmUpInfer << "_" << "withResetInferRequest=" << withResetInferRequest+ << "_";+ result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." ++ std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion))+ << "_";+ result << "zeMutableCommandListExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeMutableCommandListExtVersion)) ++ "." + std::to_string(ZE_MINOR_VERSION(zeMutableCommandListExtVersion));++ return result.str();+ }++ void SetUp() override {+ SKIP_IF_CURRENT_TEST_IS_DISABLED();+ std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;+ std::tie(target_device,+ configuration,+ element_type,+ withWarmUpInfer,+ withResetInferRequest,+ graphExtMutableCommandListExtPair) = this->GetParam();+ zeGraphNpuExtVersion = graphExtMutableCommandListExtPair.first;+ zeMutableCommandListExtVersion = graphExtMutableCommandListExtPair.second;++ auto options = std::make_shared<::intel_npu::OptionsDesc>();+ options->add<::intel_npu::PLATFORM>();+ options->add<::intel_npu::COMPILER_TYPE>();+ options->add<::intel_npu::BATCH_MODE>();+ options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();+ npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);+ ::intel_npu::Config::ConfigMap configMap;+ npu_config->enable(::intel_npu::PLATFORM::key().data(), true);+ npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), true);+ for (const auto& [propertyName, propertyValue] : configuration) {+ configMap[propertyName] = propertyValue.as<std::string>();+ npu_config->enable(propertyName, true);+ }+ npu_config->update(configMap);++ auto zeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>(+ ::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,+ zeGraphNpuExtVersion,+ ::intel_npu::test_constants::TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION,+ ::intel_npu::test_constants::TARGET_ZE_PROFILING_NPU_EXT_VERSION,+ ::intel_npu::test_constants::TARGET_ZE_CONTEXT_NPU_EXT_VERSION,+ zeMutableCommandListExtVersion);+ zeroInitStruct = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zeroInitMock);++ OVPluginTestBase::SetUp();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ APIBaseTest::TearDown();+ }+};++} // namespace behavior+} // namespace test+} // namespace ov++TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {+ // TODO: Also test make_2_input_less_eq model when we have compiler support+ ov_model = make_2_input_less_eq_non_zero();++ // FIXME: OV needs to update ov::util::load_shared_object logic to check if certain module was already loaded in+ // memory+ // Force loading compiler lib via core flow to avoid missing library in the current path+ core->set_property(target_device, ov::intel_npu::compiler_type(npu_config->get<::intel_npu::COMPILER_TYPE>()));+ (void)core->get_property(target_device, ov::supported_properties);++ auto zero_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto device = intel_npu::utils::getDeviceById(zero_backend,+ ov::test::utils::getDeviceNameID(ov::test::utils::getDeviceName()));++ std::shared_ptr<::intel_npu::ICompilerAdapter> compiler;+ try {+ compiler = npu_config->get<::intel_npu::COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER+ ? std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(+ std::make_shared<::intel_npu::DriverCompilerAdapter>(zeroInitStruct))+ : std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(+ std::make_shared<::intel_npu::PluginCompilerAdapter>(zeroInitStruct));+ } catch (...) {+ GTEST_SKIP() << "Couldn't load compiler library";+ }++ // WA for error `[NPU_VCL] Unsupported IR API version! Val: 48.0`+ if (compiler->is_option_supported(::intel_npu::MODEL_SERIALIZER_VERSION::key().data())) {+ npu_config->update({{::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),+ ::intel_npu::MODEL_SERIALIZER_VERSION::toString(+ ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)}});+ } else {+ npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), false);+ }++ // logic for batch+ auto copy_model = ov_model;+ std::optional<int64_t> batch = std::nullopt;+ if (npu_config->has<::intel_npu::BATCH_MODE>() &&+ npu_config->get<::intel_npu::BATCH_MODE>() == ov::intel_npu::BatchMode::PLUGIN) {+ std::optional<ov::Dimension> originalBatch = std::nullopt;+ auto [batchedModel, successfullyDebatched] = intel_npu::batch_helpers::handlePluginBatching(+ ov_model,+ *npu_config,+ [&](ov::intel_npu::BatchMode mode) {+ npu_config->update({{::intel_npu::BATCH_MODE::key().data(), ::intel_npu::BATCH_MODE::toString(mode)}});+ },+ originalBatch,+ ::intel_npu::Logger::global());+ OPENVINO_ASSERT(successfullyDebatched, "Couldn't debatch test model!");+ batch = originalBatch.value().get_length();+ copy_model = batchedModel;+ }++ auto graph = compiler->compile(copy_model, *npu_config);+ if (batch) {+ graph->set_batch_size(batch.value());+ }++ auto compiledModel = std::make_shared<intel_npu::CompiledModel>(+ ov_model,+ std::make_shared<ov::test::utils::MockPlugin>(), // MockPlugin needed only to avoid throw for nullptr+ device,+ graph,+ *npu_config,+ batch);+ OPENVINO_ASSERT(compiledModel->inputs()[0].get_element_type() == element_type);+ OPENVINO_ASSERT(compiledModel->inputs()[1].get_element_type() == element_type);++ auto zero_infer_request =+ std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);+ auto [importMemoryBatchedTensor,+ importMemoryTensor_1,+ importMemoryTensor_2,+ unalignedBatchedTensor,+ unalignedTensor_1,+ unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);++ ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());+ ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());+ importMemoryBatchedTensor.copy_to(ref_import_tensor);+ unalignedBatchedTensor.copy_to(ref_tensor_unaligned);++ auto reset_infer_cb = [this, &zero_infer_request, &compiledModel]() -> void {+ zero_infer_request =+ std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);+ };++ if (withWarmUpInfer) {+ zero_infer_request->infer();+ }++ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(+ zero_infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiledModel->inputs()[0],+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_1),+ ov::get_tensor_impl(unalignedTensor_2)},+ reset_infer_cb));+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(+ zero_infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiledModel->inputs()[1],+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_2),+ ov::get_tensor_impl(unalignedTensor_1)},+ reset_infer_cb));++ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiledModel->inputs()[0],+ ov::get_tensor_impl(importMemoryBatchedTensor),+ reset_infer_cb));+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiledModel->inputs()[1],+ ov::get_tensor_impl(unalignedBatchedTensor),+ reset_infer_cb));++ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(+ zero_infer_request,+ /* should_infer = */ false,+ withResetInferRequest,+ compiledModel->inputs()[0],+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_1),+ ov::get_tensor_impl(importMemoryTensor_1)},+ reset_infer_cb));+ OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(+ zero_infer_request,+ /* should_infer = */ true,+ withResetInferRequest,+ compiledModel->inputs()[1],+ std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_2),+ ov::get_tensor_impl(importMemoryTensor_2)},+ reset_infer_cb));++ // ensure user tensors don't get altered during tests+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));+ OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));+}using namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hppdeleted file mode 100644index 6ac8fa24bf8..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp+++ /dev/null@@ -1,337 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common/zero_init_mock.hpp"-#include "common_test_utils/file_utils.hpp"-#include "common_test_utils/ov_plugin_cache.hpp"-#include "common_test_utils/ov_tensor_utils.hpp"-#include "compiled_model.hpp"-#include "driver_compiler_adapter.hpp"-#include "graph.hpp"-#include "intel_npu/common/compiler_adapter_factory.hpp"-#include "intel_npu/common/device_helpers.hpp"-#include "intel_npu/config/config.hpp"-#include "intel_npu/utils/utils.hpp"-#include "openvino/op/add.hpp"-#include "openvino/op/less_eq.hpp"-#include "openvino/op/non_zero.hpp"-#include "openvino/op/shape_of.hpp"-#include "openvino/openvino.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "plugin_compiler_adapter.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "transformations.hpp"-#include "zero_backend.hpp"-#include "zero_infer_request.hpp"--namespace {-[[maybe_unused]] std::shared_ptr<ov::Model> make_2_input_less_eq(const ov::Shape& input_shape = {2, 16, 16, 16}) {- auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);- param0->get_output_tensor(0).set_names({"tensor_input_0"});- param0->set_layout("N...");- auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);- param1->get_output_tensor(0).set_names({"tensor_input_1"});- param1->set_layout("N...");- auto lessEqual = std::make_shared<ov::op::v1::LessEqual>(param0, param1);- auto result = std::make_shared<ov::op::v0::Result>(lessEqual);- result->get_output_tensor(0).set_names({"tensor_output"});-- auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});- model->set_friendly_name("TwoInputLessEqual");- return model;-}--std::shared_ptr<ov::Model> make_2_input_less_eq_non_zero(const ov::Shape& input_shape = {2, 16, 16, 16}) {- auto param0 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);- param0->get_output_tensor(0).set_names({"tensor_input_0"});- param0->set_layout("N...");- auto param1 = std::make_shared<ov::op::v0::Parameter>(ov::element::boolean, input_shape);- param1->get_output_tensor(0).set_names({"tensor_input_1"});- param1->set_layout("N...");- auto nonZero0 = std::make_shared<ov::op::v3::NonZero>(param0);- auto nonZero1 = std::make_shared<ov::op::v3::NonZero>(param1);- // NonZero Op returns 2D tensor [rank(data), num_non_zero] where second value is dynamic depending on the input- // need to workaround this for NPU_BATCH_MODE=PLUGIN using intermediary op e.g. ShapeOf- auto shapeOf0 = std::make_shared<ov::op::v0::ShapeOf>(nonZero0);- auto shapeOf1 = std::make_shared<ov::op::v0::ShapeOf>(nonZero1);- auto add = std::make_shared<ov::op::v1::Add>(shapeOf0, shapeOf1);- auto result = std::make_shared<ov::op::v0::Result>(add);- result->get_output_tensor(0).set_names({"tensor_output"});-- auto model = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param0, param1});- model->set_friendly_name("TwoTwoInputNonZeroAddModel");- return model;-}--} // namespace--namespace ov {-namespace test {-namespace behavior {--using CompilationParamsAndTensorDataType =- std::tuple<std::string, // Device name- ov::AnyMap, // Config- ov::element::Type, // Tensor data type- bool, // With warmup infer- bool, // With reset infer request- std::pair<uint32_t, uint32_t>>; // Graph Ext Version and Mutable Command List Version--class ZeroInferRequestTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParamsAndTensorDataType> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- ov::element::Type element_type;- bool withWarmUpInfer;- bool withResetInferRequest;- uint32_t zeGraphNpuExtVersion;- uint32_t zeMutableCommandListExtVersion;- std::unique_ptr<::intel_npu::FilteredConfig> npu_config;- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zeroInitStruct;- std::shared_ptr<ov::Model> ov_model;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndTensorDataType>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- ov::element::Type type;- bool withWarmUpInfer;- bool withResetInferRequest;- std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;-- std::tie(targetDevice,- configuration,- type,- withWarmUpInfer,- withResetInferRequest,- graphExtMutableCommandListExtPair) = obj.param;- auto [zeGraphNpuExtVersion, zeMutableCommandListExtVersion] = graphExtMutableCommandListExtPair;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- result << "_";- }- }- if (!type.get_type_name().empty()) {- result << "tensorDataType=" << type.get_type_name() << "_";- }-- result << "withWarmUpInfer=" << withWarmUpInfer << "_" << "withResetInferRequest=" << withResetInferRequest- << "_";- result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." +- std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion))- << "_";- result << "zeMutableCommandListExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeMutableCommandListExtVersion)) +- "." + std::to_string(ZE_MINOR_VERSION(zeMutableCommandListExtVersion));-- return result.str();- }-- void SetUp() override {- SKIP_IF_CURRENT_TEST_IS_DISABLED();- std::pair<uint32_t, uint32_t> graphExtMutableCommandListExtPair;- std::tie(target_device,- configuration,- element_type,- withWarmUpInfer,- withResetInferRequest,- graphExtMutableCommandListExtPair) = this->GetParam();- zeGraphNpuExtVersion = graphExtMutableCommandListExtPair.first;- zeMutableCommandListExtVersion = graphExtMutableCommandListExtPair.second;-- auto options = std::make_shared<::intel_npu::OptionsDesc>();- options->add<::intel_npu::PLATFORM>();- options->add<::intel_npu::COMPILER_TYPE>();- options->add<::intel_npu::BATCH_MODE>();- options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();- npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);- ::intel_npu::Config::ConfigMap configMap;- npu_config->enable(::intel_npu::PLATFORM::key().data(), true);- npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), true);- for (const auto& [propertyName, propertyValue] : configuration) {- configMap[propertyName] = propertyValue.as<std::string>();- npu_config->enable(propertyName, true);- }- npu_config->update(configMap);-- auto zeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>(- ::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,- zeGraphNpuExtVersion,- ::intel_npu::test_constants::TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION,- ::intel_npu::test_constants::TARGET_ZE_PROFILING_NPU_EXT_VERSION,- ::intel_npu::test_constants::TARGET_ZE_CONTEXT_NPU_EXT_VERSION,- zeMutableCommandListExtVersion);- zeroInitStruct = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zeroInitMock);-- OVPluginTestBase::SetUp();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- APIBaseTest::TearDown();- }-};--} // namespace behavior-} // namespace test-} // namespace ov--TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {- // TODO: Also test make_2_input_less_eq model when we have compiler support- ov_model = make_2_input_less_eq_non_zero();-- // FIXME: OV needs to update ov::util::load_shared_object logic to check if certain module was already loaded in- // memory- // Force loading compiler lib via core flow to avoid missing library in the current path- core->set_property(target_device, ov::intel_npu::compiler_type(npu_config->get<::intel_npu::COMPILER_TYPE>()));- (void)core->get_property(target_device, ov::supported_properties);-- auto zero_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto device = intel_npu::utils::getDeviceById(zero_backend,- ov::test::utils::getDeviceNameID(ov::test::utils::getDeviceName()));-- std::shared_ptr<::intel_npu::ICompilerAdapter> compiler;- try {- compiler = npu_config->get<::intel_npu::COMPILER_TYPE>() == ov::intel_npu::CompilerType::DRIVER- ? std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(- std::make_shared<::intel_npu::DriverCompilerAdapter>(zeroInitStruct))- : std::dynamic_pointer_cast<::intel_npu::ICompilerAdapter>(- std::make_shared<::intel_npu::PluginCompilerAdapter>(zeroInitStruct));- } catch (...) {- GTEST_SKIP() << "Couldn't load compiler library";- }-- // WA for error `[NPU_VCL] Unsupported IR API version! Val: 48.0`- if (compiler->is_option_supported(::intel_npu::MODEL_SERIALIZER_VERSION::key().data())) {- npu_config->update({{::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),- ::intel_npu::MODEL_SERIALIZER_VERSION::toString(- ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)}});- } else {- npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), false);- }-- // logic for batch- auto copy_model = ov_model;- std::optional<int64_t> batch = std::nullopt;- if (npu_config->has<::intel_npu::BATCH_MODE>() &&- npu_config->get<::intel_npu::BATCH_MODE>() == ov::intel_npu::BatchMode::PLUGIN) {- std::optional<ov::Dimension> originalBatch = std::nullopt;- auto [batchedModel, successfullyDebatched] = intel_npu::batch_helpers::handlePluginBatching(- ov_model,- *npu_config,- [&](ov::intel_npu::BatchMode mode) {- npu_config->update({{::intel_npu::BATCH_MODE::key().data(), ::intel_npu::BATCH_MODE::toString(mode)}});- },- originalBatch,- ::intel_npu::Logger::global());- OPENVINO_ASSERT(successfullyDebatched, "Couldn't debatch test model!");- batch = originalBatch.value().get_length();- copy_model = batchedModel;- }-- auto graph = compiler->compile(copy_model, *npu_config);- if (batch) {- graph->set_batch_size(batch.value());- }-- auto compiledModel = std::make_shared<intel_npu::CompiledModel>(- ov_model,- std::make_shared<ov::test::utils::MockPlugin>(), // MockPlugin needed only to avoid throw for nullptr- device,- graph,- *npu_config,- batch);- OPENVINO_ASSERT(compiledModel->inputs()[0].get_element_type() == element_type);- OPENVINO_ASSERT(compiledModel->inputs()[1].get_element_type() == element_type);-- auto zero_infer_request =- std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);- auto [importMemoryBatchedTensor,- importMemoryTensor_1,- importMemoryTensor_2,- unalignedBatchedTensor,- unalignedTensor_1,- unalignedTensor_2] = ov::test::utils::allocate_tensors(ov_model, ov::element::boolean);-- ov::Tensor ref_import_tensor(importMemoryBatchedTensor.get_element_type(), importMemoryBatchedTensor.get_shape());- ov::Tensor ref_tensor_unaligned(unalignedBatchedTensor.get_element_type(), unalignedBatchedTensor.get_shape());- importMemoryBatchedTensor.copy_to(ref_import_tensor);- unalignedBatchedTensor.copy_to(ref_tensor_unaligned);-- auto reset_infer_cb = [this, &zero_infer_request, &compiledModel]() -> void {- zero_infer_request =- std::make_shared<::intel_npu::ZeroInferRequest>(zeroInitStruct, compiledModel, *npu_config);- };-- if (withWarmUpInfer) {- zero_infer_request->infer();- }-- OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(- zero_infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiledModel->inputs()[0],- std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_1),- ov::get_tensor_impl(unalignedTensor_2)},- reset_infer_cb));- OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(- zero_infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiledModel->inputs()[1],- std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(importMemoryTensor_2),- ov::get_tensor_impl(unalignedTensor_1)},- reset_infer_cb));-- OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiledModel->inputs()[0],- ov::get_tensor_impl(importMemoryBatchedTensor),- reset_infer_cb));- OV_ASSERT_NO_THROW(ov::test::utils::set_tensor_and_infer(zero_infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiledModel->inputs()[1],- ov::get_tensor_impl(unalignedBatchedTensor),- reset_infer_cb));-- OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(- zero_infer_request,- /* should_infer = */ false,- withResetInferRequest,- compiledModel->inputs()[0],- std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_1),- ov::get_tensor_impl(importMemoryTensor_1)},- reset_infer_cb));- OV_ASSERT_NO_THROW(ov::test::utils::set_tensors_and_infer(- zero_infer_request,- /* should_infer = */ true,- withResetInferRequest,- compiledModel->inputs()[1],- std::vector<ov::SoPtr<ov::ITensor>>{ov::get_tensor_impl(unalignedTensor_2),- ov::get_tensor_impl(importMemoryTensor_2)},- reset_infer_cb));-- // ensure user tensors don't get altered during tests- OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_import_tensor, importMemoryBatchedTensor, ov::element::boolean));- OV_ASSERT_NO_THROW(ov::test::utils::compare(ref_tensor_unaligned, importMemoryBatchedTensor, ov::element::boolean));-}diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.cppindex 5a134e295f4..d27aace45eb 100644--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.cpp@@ -2,12 +2,594 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/backend/zero_tensor_tests.hpp"+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <random>+#include <thread>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"+#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_host_tensor.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_remote_tensor.hpp"+#include "intel_npu/utils/zero/zero_tensor.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"+#include "openvino/core/any.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "remote_context.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "zero_backend.hpp"++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+namespace {+using CompilationParamsAndTensorDataType = std::tuple<std::string, // Device name+ ov::AnyMap, // Config+ ov::element::Type // Tensor data type+ >;+} // namespace++class ZeroTensorTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParamsAndTensorDataType> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ ov::element::Type element_type;+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndTensorDataType>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ ov::element::Type type;+ std::tie(targetDevice, configuration, type) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ if (!type.get_type_name().empty()) {+ result << "tensorDataType=" << type.get_type_name() << "_";+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration, element_type) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ init_struct = nullptr;+ APIBaseTest::TearDown();+ }+};++TEST_P(ZeroTensorTests, AllocateDeleteAllocateZeroTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);+ ASSERT_TRUE(+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));++ zero_tensor = {};+ zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, false);+ ASSERT_TRUE(+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));++ void* address = zero_tensor->data();+ zero_tensor = {};+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), address));+}++TEST_P(ZeroTensorTests, CheckSetSmallerShape) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 20, 20, 20};+ auto shape_size = ov::shape_size(shape);+ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);+ EXPECT_EQ(shape, zero_tensor->get_shape());+ EXPECT_EQ(shape_size, zero_tensor->get_size());+ EXPECT_EQ(shape_size * element_type.size(), zero_tensor->get_byte_size());++ auto data = zero_tensor->data();++ auto new_shape = Shape{1, 10, 10, 10};+ auto new_shape_size = ov::shape_size(new_shape);+ // Reallocation is not required.+ zero_tensor->set_shape(new_shape);+ EXPECT_EQ(new_shape, zero_tensor->get_shape());+ EXPECT_EQ(new_shape_size, zero_tensor->get_size());+ EXPECT_EQ(new_shape_size * element_type.size(), zero_tensor->get_byte_size());+ EXPECT_EQ(data, zero_tensor->data());+ ASSERT_TRUE(+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));+}++TEST_P(ZeroTensorTests, CheckSetBiggerShape) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 20, 20, 20};+ auto shape_size = ov::shape_size(shape);+ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, false);+ EXPECT_EQ(shape, zero_tensor->get_shape());+ EXPECT_EQ(shape_size, zero_tensor->get_size());+ EXPECT_EQ(shape_size * element_type.size(), zero_tensor->get_byte_size());++ auto new_shape = Shape{1, 50, 50, 50};+ auto new_shape_size = ov::shape_size(new_shape);+ // set_shape() will force tensor reallocation for a larger shape. The new data pointer must also be a valid level+ // zero address.+ if (init_struct->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0)) {+ zero_tensor->set_shape(new_shape);+ EXPECT_EQ(new_shape, zero_tensor->get_shape());+ EXPECT_EQ(new_shape_size, zero_tensor->get_size());+ EXPECT_EQ(new_shape_size * element_type.size(), zero_tensor->get_byte_size());+ ASSERT_TRUE(zero_tensor->memory_address_changed());+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_tensor->data()));+ } else {+ ASSERT_THROW(zero_tensor->set_shape(new_shape), ov::Exception);+ }+}++TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensorScalar) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{}, true);+ auto data = zero_tensor->data();+ auto strides = zero_tensor->get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(element_type, ov::Shape{}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(ZeroTensorTests, CheckIsContinuousHostTensor1Dimension) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{128}, true);++ auto data = zero_tensor->data();+ auto strides = zero_tensor->get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(element_type, ov::Shape{128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, ov::Shape{16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor2Dimensions) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{32, 128}, true);+ auto data = zero_tensor->data();+ auto strides = zero_tensor->get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(element_type, Shape{16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{1, 16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{2, 16}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);+}++TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor3Dimensions) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{5, 32, 128}, true);+ auto data = zero_tensor->data();+ auto strides = zero_tensor->get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(element_type, Shape{2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{2, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(element_type, Shape{1, 1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{1, 1, 64}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor4Dimensions) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{3, 5, 32, 128}, true);+ auto data = zero_tensor->data();+ auto strides = zero_tensor->get_strides();++ ov::Tensor view_tensor;++ view_tensor = ov::Tensor(element_type, Shape{1, 2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{2, 5, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{2, 2, 32, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(element_type, Shape{1, 2, 5, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(element_type, Shape{3, 5, 32, 64}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(element_type, Shape{1, 1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{2, 1, 16, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), false);++ view_tensor = ov::Tensor(element_type, Shape{1, 1, 1, 128}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);++ view_tensor = ov::Tensor(element_type, Shape{1, 1, 1, 32}, data, strides);+ EXPECT_EQ(view_tensor.is_continuous(), true);+}++TEST_P(ZeroTensorTests, CopyDefaultTensorExpectedThrow) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};++ // shape size is unaligned to standard page size, expect to fail+ auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size()));+ auto default_tensor = make_tensor(element_type, shape, data);+ ASSERT_THROW(auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor),+ ::intel_npu::ZeroMemException);++ ::operator delete(data);+}++TEST_P(ZeroTensorTests, CopyZeroTensorAndKeepAlive) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);++ auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor);++ EXPECT_EQ(zero_tensor->get_shape(), copy_zero_tensor->get_shape());+ EXPECT_EQ(zero_tensor->data(), copy_zero_tensor->data());+ EXPECT_EQ(zero_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());+ EXPECT_EQ(zero_tensor->get_size(), copy_zero_tensor->get_size());++ zero_tensor = {};+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ copy_zero_tensor->data()));+ ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);+}++TEST_P(ZeroTensorTests, CopyHostTensorAndKeepAlive) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 2, 2, 2};++ auto host_tensor = std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, element_type, shape);++ auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, host_tensor);++ EXPECT_EQ(host_tensor->get_shape(), copy_zero_tensor->get_shape());+ EXPECT_EQ(host_tensor->data(), copy_zero_tensor->data());+ EXPECT_EQ(host_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());+ EXPECT_EQ(host_tensor->get_size(), copy_zero_tensor->get_size());++ host_tensor = {};+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ copy_zero_tensor->data()));+ ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);+}++TEST_P(ZeroTensorTests, CopyRemoteTensorAndKeepAlive) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 2, 2, 2};++ auto remote_tensor =+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, element_type, shape);++ auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, remote_tensor);++ EXPECT_EQ(remote_tensor->get_shape(), copy_zero_tensor->get_shape());+ EXPECT_EQ(remote_tensor->get_original_memory(), copy_zero_tensor->data());+ EXPECT_EQ(remote_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());+ EXPECT_EQ(remote_tensor->get_size(), copy_zero_tensor->get_size());++ remote_tensor = {};+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ copy_zero_tensor->data()));+ ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);+}++TEST_P(ZeroTensorTests, CopyRemoteTensorFromAnotherContextThrow) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 2, 2, 2};++ ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},+ {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};++ auto context = core->create_context(target_device, params);+ auto remote_tensor = context.create_tensor(element_type, shape);+ auto remote_tensor_impl = get_tensor_impl(remote_tensor);++ ASSERT_THROW(auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, remote_tensor_impl),+ ::intel_npu::ZeroMemException);+}++TEST_P(ZeroTensorTests, CheckStandardAllocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 4194304};++ auto logger = ::intel_npu::Logger("CheckStandardAllocation", ov::log::Level::INFO);++ // shape size is aligned to standard page size, align address as well+ auto data =+ static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));++ {+ auto default_tensor = make_tensor(element_type, shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor;+ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ OV_ASSERT_NO_THROW(zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));+ logger.info("Import memory");+ } else {+ ASSERT_THROW(zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor),+ ::intel_npu::ZeroMemException);+ logger.error("Import memory is not supported, throw is expected.");+ }+ }++ ::operator delete(data, std::align_val_t(4096));+}++TEST_P(ZeroTensorTests, UseSameStandardAllocationMultipleTimesCompatible) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 4194304};++ // shape size is aligned to standard page size, align address as well+ auto data =+ static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));++ {+ auto default_tensor = make_tensor(element_type, shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;+ OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));++ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;+ OV_ASSERT_NO_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));++ zero_tensor0 = {};+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));++ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor2;+ OV_ASSERT_NO_THROW(zero_tensor2 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor1));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));++ zero_tensor1 = {};+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));++ zero_tensor2 = {};+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()));+ }++ ::operator delete(data, std::align_val_t(4096));+ }+}++TEST_P(ZeroTensorTests, UseRangePointerFromAlreadyImportedStandardAllocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 4194304};++ // shape size is aligned to standard page size, align address as well+ auto data =+ static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));++ {+ auto default_tensor = make_tensor(element_type, shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;+ OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));++ auto smaller_shape = Shape{1, 128};+ auto smaller_tensor = make_tensor(element_type, smaller_shape, data + 16);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;+ OV_ASSERT_NO_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor));++ EXPECT_EQ(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_tensor0->data()),+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_tensor1->data()));+ EXPECT_EQ(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ default_tensor->data()),+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ smaller_tensor->data()));+ EXPECT_EQ(default_tensor->data(), zero_tensor0->data());+ EXPECT_EQ(smaller_tensor->data(), zero_tensor1->data());+ EXPECT_NE(zero_tensor0->data(), zero_tensor1->data());+ EXPECT_EQ(static_cast<void*>(static_cast<float*>(zero_tensor0->data()) + 16), zero_tensor1->data());+ }++ ::operator delete(data, std::align_val_t(4096));+ }+}++TEST_P(ZeroTensorTests, UseRangeOutOfBoundsPointerFromAlreadyImportedStandardAllocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 1024};++ // shape size is aligned to standard page size, align address as well+ auto data =+ static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));++ {+ auto default_tensor = make_tensor(element_type, shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;+ OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));++ auto different_shape = Shape{1, 1024};+ auto different_tensor = make_tensor(element_type, different_shape, data + 16);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;+ ASSERT_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, different_tensor),+ ::intel_npu::ZeroMemException);+ }++ ::operator delete(data, std::align_val_t(4096));+ }+}++TEST_P(ZeroTensorTests, UseBiggerMemoryFromAlreadyImportedStandardAllocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ auto shape = Shape{1, 2048};++ // shape size is aligned to standard page size, align address as well+ auto data =+ static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));++ {+ auto smaller_shape = Shape{1, 1024};+ auto smaller_tensor = make_tensor(element_type, smaller_shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;+ OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor));++ auto bigger_tensor = make_tensor(element_type, shape, data);+ std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;+ ASSERT_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, bigger_tensor),+ ::intel_npu::ZeroMemException);+ }++ ::operator delete(data, std::align_val_t(4096));+ }+}++TEST_P(ZeroTensorTests, CreateSmallerZeroTensorsFromLargerRemoteTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 1024};++ auto host_tensor = std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, element_type, shape);+ void* data = host_tensor->data();++ auto smaller_shape0 = Shape{1, 128};+ auto smaller_tensor0 = make_tensor(element_type, smaller_shape0, host_tensor->data());+ auto zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor0);+ EXPECT_EQ(smaller_shape0, zero_tensor0->get_shape());+ EXPECT_EQ(host_tensor->data(), smaller_tensor0->data());++ auto smaller_shape1 = Shape{1, 64};+ auto smaller_tensor1 = make_tensor(element_type, smaller_shape1, smaller_tensor0->data());+ auto zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor1);+ EXPECT_EQ(smaller_shape1, zero_tensor1->get_shape());+ EXPECT_EQ(host_tensor->data(), smaller_tensor1->data());++ host_tensor = {};+ ASSERT_TRUE(+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor0->data()));++ zero_tensor0 = {};+ smaller_tensor0 = {};+ ASSERT_TRUE(+ ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor1->data()));++ smaller_tensor1 = {};+ zero_tensor1 = {};+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));+}++using ZeroTensorTestsCheckDataType = ZeroTensorTests;++TEST_P(ZeroTensorTestsCheckDataType, CopyZeroTensorAndCheckTensorDataType) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);+ EXPECT_EQ(element_type, zero_tensor->get_element_type());++ auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor);+ EXPECT_EQ(zero_tensor->get_element_type(), copy_zero_tensor->get_element_type());+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hppdeleted file mode 100644index 57abca95869..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_tensor_tests.hpp+++ /dev/null@@ -1,592 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <random>-#include <thread>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "functional_test_utils/ov_plugin_cache.hpp"-#include "intel_npu/common/npu.hpp"-#include "intel_npu/config/config.hpp"-#include "intel_npu/config/options.hpp"-#include "intel_npu/utils/zero/zero_host_tensor.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_remote_tensor.hpp"-#include "intel_npu/utils/zero/zero_tensor.hpp"-#include "intel_npu/utils/zero/zero_utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "remote_context.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "zero_backend.hpp"--using CompilationParamsAndTensorDataType = std::tuple<std::string, // Device name- ov::AnyMap, // Config- ov::element::Type // Tensor data type- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class ZeroTensorTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParamsAndTensorDataType> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- ov::element::Type element_type;- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndTensorDataType>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- ov::element::Type type;- std::tie(targetDevice, configuration, type) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- if (!type.get_type_name().empty()) {- result << "tensorDataType=" << type.get_type_name() << "_";- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration, element_type) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();-- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- init_struct = nullptr;- APIBaseTest::TearDown();- }-};--TEST_P(ZeroTensorTests, AllocateDeleteAllocateZeroTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);- ASSERT_TRUE(- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));-- zero_tensor = {};- zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, false);- ASSERT_TRUE(- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));-- void* address = zero_tensor->data();- zero_tensor = {};- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), address));-}--TEST_P(ZeroTensorTests, CheckSetSmallerShape) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 20, 20, 20};- auto shape_size = ov::shape_size(shape);- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);- EXPECT_EQ(shape, zero_tensor->get_shape());- EXPECT_EQ(shape_size, zero_tensor->get_size());- EXPECT_EQ(shape_size * element_type.size(), zero_tensor->get_byte_size());-- auto data = zero_tensor->data();-- auto new_shape = Shape{1, 10, 10, 10};- auto new_shape_size = ov::shape_size(new_shape);- // Reallocation is not required.- zero_tensor->set_shape(new_shape);- EXPECT_EQ(new_shape, zero_tensor->get_shape());- EXPECT_EQ(new_shape_size, zero_tensor->get_size());- EXPECT_EQ(new_shape_size * element_type.size(), zero_tensor->get_byte_size());- EXPECT_EQ(data, zero_tensor->data());- ASSERT_TRUE(- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor->data()));-}--TEST_P(ZeroTensorTests, CheckSetBiggerShape) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 20, 20, 20};- auto shape_size = ov::shape_size(shape);- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, false);- EXPECT_EQ(shape, zero_tensor->get_shape());- EXPECT_EQ(shape_size, zero_tensor->get_size());- EXPECT_EQ(shape_size * element_type.size(), zero_tensor->get_byte_size());-- auto new_shape = Shape{1, 50, 50, 50};- auto new_shape_size = ov::shape_size(new_shape);- // set_shape() will force tensor reallocation for a larger shape. The new data pointer must also be a valid level- // zero address.- if (init_struct->getMutableCommandListExtVersion() >= ZE_MAKE_VERSION(1, 0)) {- zero_tensor->set_shape(new_shape);- EXPECT_EQ(new_shape, zero_tensor->get_shape());- EXPECT_EQ(new_shape_size, zero_tensor->get_size());- EXPECT_EQ(new_shape_size * element_type.size(), zero_tensor->get_byte_size());- ASSERT_TRUE(zero_tensor->memory_address_changed());- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_tensor->data()));- } else {- ASSERT_THROW(zero_tensor->set_shape(new_shape), ov::Exception);- }-}--TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensorScalar) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{}, true);- auto data = zero_tensor->data();- auto strides = zero_tensor->get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(element_type, ov::Shape{}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(ZeroTensorTests, CheckIsContinuousHostTensor1Dimension) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{128}, true);-- auto data = zero_tensor->data();- auto strides = zero_tensor->get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(element_type, ov::Shape{128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, ov::Shape{16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor2Dimensions) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{32, 128}, true);- auto data = zero_tensor->data();- auto strides = zero_tensor->get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(element_type, Shape{16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{1, 16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{2, 16}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-}--TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor3Dimensions) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{5, 32, 128}, true);- auto data = zero_tensor->data();- auto strides = zero_tensor->get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(element_type, Shape{2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{2, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(element_type, Shape{1, 1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{1, 1, 64}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(ZeroTensorTests, CheckIsContinuousZeroTensor4Dimensions) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, Shape{3, 5, 32, 128}, true);- auto data = zero_tensor->data();- auto strides = zero_tensor->get_strides();-- ov::Tensor view_tensor;-- view_tensor = ov::Tensor(element_type, Shape{1, 2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{2, 5, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{2, 2, 32, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(element_type, Shape{1, 2, 5, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(element_type, Shape{3, 5, 32, 64}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(element_type, Shape{1, 1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{2, 1, 16, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), false);-- view_tensor = ov::Tensor(element_type, Shape{1, 1, 1, 128}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-- view_tensor = ov::Tensor(element_type, Shape{1, 1, 1, 32}, data, strides);- EXPECT_EQ(view_tensor.is_continuous(), true);-}--TEST_P(ZeroTensorTests, CopyDefaultTensorExpectedThrow) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};-- // shape size is unaligned to standard page size, expect to fail- auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size()));- auto default_tensor = make_tensor(element_type, shape, data);- ASSERT_THROW(auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor),- ::intel_npu::ZeroMemException);-- ::operator delete(data);-}--TEST_P(ZeroTensorTests, CopyZeroTensorAndKeepAlive) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);-- auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor);-- EXPECT_EQ(zero_tensor->get_shape(), copy_zero_tensor->get_shape());- EXPECT_EQ(zero_tensor->data(), copy_zero_tensor->data());- EXPECT_EQ(zero_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());- EXPECT_EQ(zero_tensor->get_size(), copy_zero_tensor->get_size());-- zero_tensor = {};- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- copy_zero_tensor->data()));- ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);-}--TEST_P(ZeroTensorTests, CopyHostTensorAndKeepAlive) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 2, 2, 2};-- auto host_tensor = std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, element_type, shape);-- auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, host_tensor);-- EXPECT_EQ(host_tensor->get_shape(), copy_zero_tensor->get_shape());- EXPECT_EQ(host_tensor->data(), copy_zero_tensor->data());- EXPECT_EQ(host_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());- EXPECT_EQ(host_tensor->get_size(), copy_zero_tensor->get_size());-- host_tensor = {};- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- copy_zero_tensor->data()));- ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);-}--TEST_P(ZeroTensorTests, CopyRemoteTensorAndKeepAlive) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 2, 2, 2};-- auto remote_tensor =- std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, element_type, shape);-- auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, remote_tensor);-- EXPECT_EQ(remote_tensor->get_shape(), copy_zero_tensor->get_shape());- EXPECT_EQ(remote_tensor->get_original_memory(), copy_zero_tensor->data());- EXPECT_EQ(remote_tensor->get_byte_size(), copy_zero_tensor->get_byte_size());- EXPECT_EQ(remote_tensor->get_size(), copy_zero_tensor->get_size());-- remote_tensor = {};- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- copy_zero_tensor->data()));- ASSERT_THROW(copy_zero_tensor->set_shape({1, 20, 20, 20}), ov::Exception);-}--TEST_P(ZeroTensorTests, CopyRemoteTensorFromAnotherContextThrow) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 2, 2, 2};-- ov::AnyMap params = {{ov::intel_npu::mem_type.name(), ov::intel_npu::MemType::L0_INTERNAL_BUF},- {ov::intel_npu::tensor_type.name(), {ov::intel_npu::TensorType::INPUT}}};-- auto context = core->create_context(target_device, params);- auto remote_tensor = context.create_tensor(element_type, shape);- auto remote_tensor_impl = get_tensor_impl(remote_tensor);-- ASSERT_THROW(auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, remote_tensor_impl),- ::intel_npu::ZeroMemException);-}--TEST_P(ZeroTensorTests, CheckStandardAllocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 4194304};-- auto logger = ::intel_npu::Logger("CheckStandardAllocation", ov::log::Level::INFO);-- // shape size is aligned to standard page size, align address as well- auto data =- static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));-- {- auto default_tensor = make_tensor(element_type, shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor;- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- OV_ASSERT_NO_THROW(zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));- logger.info("Import memory");- } else {- ASSERT_THROW(zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor),- ::intel_npu::ZeroMemException);- logger.error("Import memory is not supported, throw is expected.");- }- }-- ::operator delete(data, std::align_val_t(4096));-}--TEST_P(ZeroTensorTests, UseSameStandardAllocationMultipleTimesCompatible) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 4194304};-- // shape size is aligned to standard page size, align address as well- auto data =- static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));-- {- auto default_tensor = make_tensor(element_type, shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;- OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));-- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;- OV_ASSERT_NO_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));-- zero_tensor0 = {};- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));-- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor2;- OV_ASSERT_NO_THROW(zero_tensor2 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor1));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));-- zero_tensor1 = {};- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));-- zero_tensor2 = {};- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()));- }-- ::operator delete(data, std::align_val_t(4096));- }-}--TEST_P(ZeroTensorTests, UseRangePointerFromAlreadyImportedStandardAllocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 4194304};-- // shape size is aligned to standard page size, align address as well- auto data =- static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));-- {- auto default_tensor = make_tensor(element_type, shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;- OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));-- auto smaller_shape = Shape{1, 128};- auto smaller_tensor = make_tensor(element_type, smaller_shape, data + 16);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;- OV_ASSERT_NO_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor));-- EXPECT_EQ(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_tensor0->data()),- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_tensor1->data()));- EXPECT_EQ(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- default_tensor->data()),- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- smaller_tensor->data()));- EXPECT_EQ(default_tensor->data(), zero_tensor0->data());- EXPECT_EQ(smaller_tensor->data(), zero_tensor1->data());- EXPECT_NE(zero_tensor0->data(), zero_tensor1->data());- EXPECT_EQ(static_cast<void*>(static_cast<float*>(zero_tensor0->data()) + 16), zero_tensor1->data());- }-- ::operator delete(data, std::align_val_t(4096));- }-}--TEST_P(ZeroTensorTests, UseRangeOutOfBoundsPointerFromAlreadyImportedStandardAllocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 1024};-- // shape size is aligned to standard page size, align address as well- auto data =- static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));-- {- auto default_tensor = make_tensor(element_type, shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;- OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, default_tensor));-- auto different_shape = Shape{1, 1024};- auto different_tensor = make_tensor(element_type, different_shape, data + 16);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;- ASSERT_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, different_tensor),- ::intel_npu::ZeroMemException);- }-- ::operator delete(data, std::align_val_t(4096));- }-}--TEST_P(ZeroTensorTests, UseBiggerMemoryFromAlreadyImportedStandardAllocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- auto shape = Shape{1, 2048};-- // shape size is aligned to standard page size, align address as well- auto data =- static_cast<float*>(::operator new(ov::shape_size(shape) * element_type.size(), std::align_val_t(4096)));-- {- auto smaller_shape = Shape{1, 1024};- auto smaller_tensor = make_tensor(element_type, smaller_shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor0;- OV_ASSERT_NO_THROW(zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor));-- auto bigger_tensor = make_tensor(element_type, shape, data);- std::shared_ptr<::intel_npu::ZeroTensor> zero_tensor1;- ASSERT_THROW(zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, bigger_tensor),- ::intel_npu::ZeroMemException);- }-- ::operator delete(data, std::align_val_t(4096));- }-}--TEST_P(ZeroTensorTests, CreateSmallerZeroTensorsFromLargerRemoteTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 1024};-- auto host_tensor = std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, element_type, shape);- void* data = host_tensor->data();-- auto smaller_shape0 = Shape{1, 128};- auto smaller_tensor0 = make_tensor(element_type, smaller_shape0, host_tensor->data());- auto zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor0);- EXPECT_EQ(smaller_shape0, zero_tensor0->get_shape());- EXPECT_EQ(host_tensor->data(), smaller_tensor0->data());-- auto smaller_shape1 = Shape{1, 64};- auto smaller_tensor1 = make_tensor(element_type, smaller_shape1, smaller_tensor0->data());- auto zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, smaller_tensor1);- EXPECT_EQ(smaller_shape1, zero_tensor1->get_shape());- EXPECT_EQ(host_tensor->data(), smaller_tensor1->data());-- host_tensor = {};- ASSERT_TRUE(- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor0->data()));-- zero_tensor0 = {};- smaller_tensor0 = {};- ASSERT_TRUE(- ::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), zero_tensor1->data()));-- smaller_tensor1 = {};- zero_tensor1 = {};- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));-}--using ZeroTensorTestsCheckDataType = ZeroTensorTests;--TEST_P(ZeroTensorTestsCheckDataType, CopyZeroTensorAndCheckTensorDataType) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element_type, shape, true);- EXPECT_EQ(element_type, zero_tensor->get_element_type());-- auto copy_zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, zero_tensor);- EXPECT_EQ(zero_tensor->get_element_type(), copy_zero_tensor->get_element_type());-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.cppindex ececb685dfa..50a41f3c8bf 100644--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.cpp@@ -2,12 +2,317 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/backend/zero_variable_state_tests.hpp"+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <random>+#include <thread>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"+#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_host_tensor.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_remote_tensor.hpp"+#include "intel_npu/utils/zero/zero_tensor.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"+#include "openvino/core/any.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "remote_context.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "zero_backend.hpp"+#include "zero_variable_state.hpp"++using CompilationParams = std::tuple<std::string, // Device name+ ov::AnyMap // Config+ >;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class ZeroVariableStateTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ std::tie(targetDevice, configuration) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ std::tie(target_device, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ init_struct = nullptr;+ APIBaseTest::TearDown();+ }+};++TEST_P(ZeroVariableStateTests, CreateZeroStateAndCheckAgainstZeroTensorState) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};+ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));++ EXPECT_EQ(zero_state->get_state()->data(), zero_tensor->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_tensor->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_tensor->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_tensor->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_tensor->get_element_type());++ EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());+}++TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithZeroTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};+ auto zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor0, 1, 1);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));++ auto zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ zero_state->set_state(zero_tensor1);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));++ ASSERT_TRUE(zero_state->state_update_pending());+ ASSERT_TRUE(zero_state->zero_state_update_pending());++ EXPECT_NE(zero_state->get_state()->data(), zero_tensor0->data());++ EXPECT_EQ(zero_state->get_state()->data(), zero_tensor1->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_tensor1->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_tensor1->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_tensor1->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_tensor1->get_element_type());++ EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());+}++TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithNormalTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};+ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_user_state()->data()));++ // shape size is unaligned to standard page size, expect to fail+ auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * sizeof(ov::element::f32)));+ auto tensor = make_tensor(ov::element::f32, shape, data);+ zero_state->set_state(tensor);+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_zero_state()->data()));++ ASSERT_TRUE(zero_state->state_update_pending());+ ASSERT_FALSE(zero_state->zero_state_update_pending());++ EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());+ EXPECT_EQ(zero_state->get_zero_state()->data(), zero_tensor->data());++ EXPECT_EQ(zero_state->get_state()->data(), tensor->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), tensor->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), tensor->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), tensor->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), tensor->get_element_type());++ EXPECT_NE(zero_state->get_state()->data(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());++ ::operator delete(data);+}++TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithNormalTensorAfterGetState) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto shape = Shape{1, 2, 2, 2};+ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));++ // shape size is unaligned to standard page size, expect to fail+ auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * sizeof(ov::element::f32)));+ auto tensor = make_tensor(ov::element::f32, shape, data);+ zero_state->set_state(tensor);+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_zero_state()->data()));++ ASSERT_TRUE(zero_state->state_update_pending());+ ASSERT_TRUE(zero_state->zero_state_update_pending());++ EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());+ EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());++ EXPECT_EQ(zero_state->get_state()->data(), tensor->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), tensor->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), tensor->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), tensor->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), tensor->get_element_type());++ EXPECT_NE(zero_state->get_state()->data(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());++ ::operator delete(data);+}++TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithHostTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 2, 2, 2};++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);++ // shape size is unaligned to standard page size, expect to fail+ auto host_tensor =+ std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, ov::element::f32, shape);+ zero_state->set_state(host_tensor);+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_state()->data()));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_zero_state()->data()));++ ASSERT_TRUE(zero_state->state_update_pending());+ ASSERT_TRUE(zero_state->zero_state_update_pending());++ EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());+ EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());++ EXPECT_EQ(zero_state->get_state()->data(), host_tensor->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), host_tensor->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), host_tensor->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), host_tensor->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), host_tensor->get_element_type());++ EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());+}++TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithRemoteTensor) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();+ auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);+ auto shape = Shape{1, 2, 2, 2};++ auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);+ auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);++ // shape size is unaligned to standard page size, expect to fail+ auto remote_tensor =+ std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, shape);+ zero_state->set_state(remote_tensor);+ auto zero_remote_tensor = std::dynamic_pointer_cast<::intel_npu::ZeroRemoteTensor>(zero_state->get_state()._ptr);++ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_remote_tensor->get_original_memory()));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),+ zero_state->get_zero_state()->data()));++ ASSERT_TRUE(zero_state->state_update_pending());+ ASSERT_TRUE(zero_state->zero_state_update_pending());++ EXPECT_NE(zero_remote_tensor->get_original_memory(), zero_tensor->data());+ EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());++ EXPECT_EQ(zero_remote_tensor->get_original_memory(), remote_tensor->get_original_memory());+ EXPECT_EQ(zero_state->get_state()->get_shape(), remote_tensor->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), remote_tensor->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), remote_tensor->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), remote_tensor->get_element_type());++ EXPECT_EQ(zero_remote_tensor->get_original_memory(), zero_state->get_zero_state()->data());+ EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());+ EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());+ EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());+ EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());++ OV_ASSERT_NO_THROW(zero_state->reset());+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hppdeleted file mode 100644index 87e5f318fbf..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_variable_state_tests.hpp+++ /dev/null@@ -1,317 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <random>-#include <thread>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "functional_test_utils/ov_plugin_cache.hpp"-#include "intel_npu/common/npu.hpp"-#include "intel_npu/config/config.hpp"-#include "intel_npu/config/options.hpp"-#include "intel_npu/utils/zero/zero_host_tensor.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_remote_tensor.hpp"-#include "intel_npu/utils/zero/zero_tensor.hpp"-#include "intel_npu/utils/zero/zero_utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "remote_context.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "zero_backend.hpp"-#include "zero_variable_state.hpp"--using CompilationParams = std::tuple<std::string, // Device name- ov::AnyMap // Config- >;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class ZeroVariableStateTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- std::tie(targetDevice, configuration) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- std::tie(target_device, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();-- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- init_struct = nullptr;- APIBaseTest::TearDown();- }-};--TEST_P(ZeroVariableStateTests, CreateZeroStateAndCheckAgainstZeroTensorState) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));-- EXPECT_EQ(zero_state->get_state()->data(), zero_tensor->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_tensor->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_tensor->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_tensor->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_tensor->get_element_type());-- EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-}--TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithZeroTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};- auto zero_tensor0 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor0, 1, 1);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));-- auto zero_tensor1 = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- zero_state->set_state(zero_tensor1);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));-- ASSERT_TRUE(zero_state->state_update_pending());- ASSERT_TRUE(zero_state->zero_state_update_pending());-- EXPECT_NE(zero_state->get_state()->data(), zero_tensor0->data());-- EXPECT_EQ(zero_state->get_state()->data(), zero_tensor1->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_tensor1->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_tensor1->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_tensor1->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_tensor1->get_element_type());-- EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-}--TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithNormalTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_user_state()->data()));-- // shape size is unaligned to standard page size, expect to fail- auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * sizeof(ov::element::f32)));- auto tensor = make_tensor(ov::element::f32, shape, data);- zero_state->set_state(tensor);- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_zero_state()->data()));-- ASSERT_TRUE(zero_state->state_update_pending());- ASSERT_FALSE(zero_state->zero_state_update_pending());-- EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());- EXPECT_EQ(zero_state->get_zero_state()->data(), zero_tensor->data());-- EXPECT_EQ(zero_state->get_state()->data(), tensor->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), tensor->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), tensor->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), tensor->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), tensor->get_element_type());-- EXPECT_NE(zero_state->get_state()->data(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-- ::operator delete(data);-}--TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithNormalTensorAfterGetState) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto shape = Shape{1, 2, 2, 2};- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));-- // shape size is unaligned to standard page size, expect to fail- auto data = static_cast<float*>(::operator new(ov::shape_size(shape) * sizeof(ov::element::f32)));- auto tensor = make_tensor(ov::element::f32, shape, data);- zero_state->set_state(tensor);- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_zero_state()->data()));-- ASSERT_TRUE(zero_state->state_update_pending());- ASSERT_TRUE(zero_state->zero_state_update_pending());-- EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());- EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());-- EXPECT_EQ(zero_state->get_state()->data(), tensor->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), tensor->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), tensor->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), tensor->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), tensor->get_element_type());-- EXPECT_NE(zero_state->get_state()->data(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-- ::operator delete(data);-}--TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithHostTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 2, 2, 2};-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);-- // shape size is unaligned to standard page size, expect to fail- auto host_tensor =- std::make_shared<::intel_npu::ZeroHostTensor>(zero_context, init_struct, ov::element::f32, shape);- zero_state->set_state(host_tensor);- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_state()->data()));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_zero_state()->data()));-- ASSERT_TRUE(zero_state->state_update_pending());- ASSERT_TRUE(zero_state->zero_state_update_pending());-- EXPECT_NE(zero_state->get_state()->data(), zero_tensor->data());- EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());-- EXPECT_EQ(zero_state->get_state()->data(), host_tensor->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), host_tensor->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), host_tensor->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), host_tensor->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), host_tensor->get_element_type());-- EXPECT_EQ(zero_state->get_state()->data(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-}--TEST_P(ZeroVariableStateTests, CreateZeroStateAndUseSetStateWithRemoteTensor) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::shared_ptr<::intel_npu::IEngineBackend> engine_backend = std::make_shared<::intel_npu::ZeroEngineBackend>();- auto zero_context = std::make_shared<::intel_npu::RemoteContextImpl>(engine_backend);- auto shape = Shape{1, 2, 2, 2};-- auto zero_tensor = std::make_shared<::intel_npu::ZeroTensor>(init_struct, element::f32, shape, true);- auto zero_state = std::make_shared<::intel_npu::ZeroVariableState>(init_struct, "state", zero_tensor, 1, 1);-- // shape size is unaligned to standard page size, expect to fail- auto remote_tensor =- std::make_shared<::intel_npu::ZeroRemoteTensor>(zero_context, init_struct, ov::element::f32, shape);- zero_state->set_state(remote_tensor);- auto zero_remote_tensor = std::dynamic_pointer_cast<::intel_npu::ZeroRemoteTensor>(zero_state->get_state()._ptr);-- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_remote_tensor->get_original_memory()));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(),- zero_state->get_zero_state()->data()));-- ASSERT_TRUE(zero_state->state_update_pending());- ASSERT_TRUE(zero_state->zero_state_update_pending());-- EXPECT_NE(zero_remote_tensor->get_original_memory(), zero_tensor->data());- EXPECT_NE(zero_state->get_zero_state()->data(), zero_tensor->data());-- EXPECT_EQ(zero_remote_tensor->get_original_memory(), remote_tensor->get_original_memory());- EXPECT_EQ(zero_state->get_state()->get_shape(), remote_tensor->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), remote_tensor->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), remote_tensor->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), remote_tensor->get_element_type());-- EXPECT_EQ(zero_remote_tensor->get_original_memory(), zero_state->get_zero_state()->data());- EXPECT_EQ(zero_state->get_state()->get_shape(), zero_state->get_zero_state()->get_shape());- EXPECT_EQ(zero_state->get_state()->get_size(), zero_state->get_zero_state()->get_size());- EXPECT_EQ(zero_state->get_state()->get_byte_size(), zero_state->get_zero_state()->get_byte_size());- EXPECT_EQ(zero_state->get_state()->get_element_type(), zero_state->get_zero_state()->get_element_type());-- OV_ASSERT_NO_THROW(zero_state->reset());-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cppindex da95d1328a2..843f534b0af 100644--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.cpp@@ -2,9 +2,363 @@// SPDX-License-Identifier: Apache-2.0//-#include "vcl_allocator_test.hpp"+#include <algorithm>+#include <gtest/gtest.h>+#include <memory>+#include <vector>#include "common/npu_test_env_cfg.hpp"+#include "common_test_utils/file_utils.hpp"+#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"+#include "intel_npu/utils/utils.hpp"+#include "intel_npu/utils/vcl/vcl_allocator.hpp"+#include "intel_npu/utils/vcl/vcl_api.hpp"+#include "model_serializer.hpp"+#include "openvino/core/except.hpp"+#include "openvino/runtime/make_tensor.hpp"+#include "openvino/runtime/tensor.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov::test::behavior {++class VclAllocatorFuncTests : public ::testing::TestWithParam<std::string> {+public:+ static std::string getTestCaseName(testing::TestParamInfo<std::string> obj) {+ auto targetDevice = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');+ std::ostringstream result;+ result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";+ result << "targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);+ return result.str();+ }++protected:+ std::string targetDevice;+ std::shared_ptr<ov::Model> model;+ std::shared_ptr<::intel_npu::vcl_allocator_2> allocator;++ void SetUp() override {+ targetDevice = GetParam();+ model = ov::test::utils::make_conv_pool_relu();+ allocator = std::make_shared<::intel_npu::vcl_allocator_2>();++ try {+ std::string ov_lib_dir = ov::test::utils::getOpenvinoLibDirectory();+ ::intel_npu::VCLApi::getInstance(ov_lib_dir);+ } catch (const std::exception&) {+ GTEST_SKIP() << "Couldn't load compiler library";+ }+ }++ // Helper struct and function to reduce code duplication+ struct CompilerSetupState {+ std::string buildFlags;+ ::intel_npu::SerializedIR serializedIR;+ vcl_compiler_handle_t compiler = nullptr;+ vcl_log_handle_t logHandle = nullptr;++ CompilerSetupState() = default;+ CompilerSetupState(const CompilerSetupState&) = delete;+ CompilerSetupState& operator=(const CompilerSetupState&) = delete;+ CompilerSetupState(CompilerSetupState&& other) noexcept+ : buildFlags(std::move(other.buildFlags)),+ serializedIR(std::move(other.serializedIR)),+ compiler(other.compiler),+ logHandle(other.logHandle) {+ other.compiler = nullptr;+ other.logHandle = nullptr;+ }+ CompilerSetupState& operator=(CompilerSetupState&& other) noexcept {+ if (this != &other) {+ release();+ buildFlags = std::move(other.buildFlags);+ serializedIR = std::move(other.serializedIR);+ compiler = other.compiler;+ logHandle = other.logHandle;+ other.compiler = nullptr;+ other.logHandle = nullptr;+ }+ return *this;+ }++ ~CompilerSetupState() {+ release();+ }++ private:+ void release() {+ if (compiler != nullptr) {+ ::intel_npu::vclCompilerDestroy(compiler);+ compiler = nullptr;+ }+ }+ };++ CompilerSetupState createCompilerAndDescriptor() {+ CompilerSetupState state;++ state.buildFlags = ::intel_npu::compiler_utils::serializeIOInfo(model, true);++ auto platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);+ if (platform.find("NPU") == 0) {+ platform = platform.substr(3); // Remove "NPU" prefix if present+ }++ state.buildFlags +=+ " --config NPU_PLATFORM=\"" + platform + "\" NPU_COMPILATION_MODE_PARAMS=\"optimization-level=0\"";++ vcl_version_info_t vclVersion = {};+ vcl_version_info_t vclProfilingVersion = {};+ ::intel_npu::vclGetVersion(&vclVersion, &vclProfilingVersion);++ vcl_compiler_desc_t compilerDesc = {};+ compilerDesc.version = vclVersion;+ compilerDesc.debugLevel =+ static_cast<__vcl_log_level_t>(static_cast<int>(::intel_npu::Logger::global().level()) + 1);++ uint32_t defaultTileCount = std::numeric_limits<uint32_t>::max();+ if (vclVersion.major == 7 && vclVersion.minor < 6) {+ defaultTileCount = std::numeric_limits<uint16_t>::max();+ }++ vcl_device_desc_t deviceDesc = {sizeof(vcl_device_desc_t),+ 0x00,+ std::numeric_limits<uint16_t>::max(),+ defaultTileCount};++ ::intel_npu::vclCompilerCreate(&compilerDesc, &deviceDesc, &state.compiler, &state.logHandle);++ if (state.compiler == nullptr) {+ ADD_FAILURE() << "vclCompilerCreate failed";+ return state;+ }++ ze_graph_compiler_version_info_t vclVersionInfo = {0, 0};+ vcl_compiler_properties_t compilerProp = {};+ ::intel_npu::vclCompilerGetProperties(state.compiler, &compilerProp);+ vclVersionInfo.major = compilerProp.version.major;+ vclVersionInfo.minor = compilerProp.version.minor;++ auto isOptionValueSupportedByCompiler = [](const std::string&, const std::optional<std::string>&) {+ return true;+ };++ state.serializedIR =+ ::intel_npu::compiler_utils::serializeIR(model,+ vclVersionInfo,+ 10,+ ::intel_npu::MODEL_SERIALIZER_VERSION::defaultValue(),+ isOptionValueSupportedByCompiler);++ state.buildFlags += " NPU_MODEL_SERIALIZER_VERSION=\"" ++ ::intel_npu::MODEL_SERIALIZER_VERSION::toString(state.serializedIR.serializerVersion) ++ "\"";++ return state;+ }++ static std::string getCompatibilityString(vcl_executable_handle_t executable) {+ uint64_t compatibilityStringSize = 0;+ auto result = ::intel_npu::vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);+ if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {+ ADD_FAILURE() << "Failed to get compatibility string size";+ return {};+ }+ const uint64_t maxSize = static_cast<uint64_t>(std::vector<char>().max_size());+ if (compatibilityStringSize > maxSize) {+ ADD_FAILURE() << "Compatibility string size is too large";+ return {};+ }+ std::vector<char> compatibilityStringBuffer(static_cast<size_t>(compatibilityStringSize), '\0');+ result = ::intel_npu::vclExecutableGetCompatibilityString(executable,+ compatibilityStringBuffer.data(),+ &compatibilityStringSize);+ if (result != VCL_RESULT_SUCCESS) {+ ADD_FAILURE() << "Failed to get compatibility string";+ return {};+ }+ if (compatibilityStringSize > static_cast<uint64_t>(compatibilityStringBuffer.size())) {+ ADD_FAILURE() << "Returned compatibility string size exceeds the allocated buffer size";+ return {};+ }+ size_t outSize = static_cast<size_t>(compatibilityStringSize);+ if (outSize > 0 && compatibilityStringBuffer[outSize - 1] == '\0') {+ --outSize;+ }+ return std::string(compatibilityStringBuffer.data(), outSize);+ }+};++TEST_P(VclAllocatorFuncTests, VerifyAllocation) {+ uint8_t* blobBuffer = nullptr;+ uint64_t blobSize = 0;+ vcl_executable_handle_t executable = nullptr;++ auto setup = createCompilerAndDescriptor();+ ASSERT_NE(setup.compiler, nullptr);++ vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),+ setup.serializedIR.size,+ setup.buildFlags.c_str(),+ setup.buildFlags.size()};++ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,+ desc,+ allocator.get(),+ &blobBuffer,+ &blobSize,+ &executable);++ EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ EXPECT_NE(blobBuffer, nullptr);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());++ // Verify it tracked blob allocation.+ EXPECT_EQ(allocator->m_info.size(), 1);++ auto blobIt = std::find_if(allocator->m_info.begin(),+ allocator->m_info.end(),+ [blobBuffer](const std::pair<uint8_t*, size_t>& item) {+ return item.first == blobBuffer;+ });+ EXPECT_NE(blobIt, allocator->m_info.end());++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);+}++TEST_P(VclAllocatorFuncTests, VerifyDeallocation) {+ uint8_t* blobBuffer = nullptr;+ uint64_t blobSize = 0;+ vcl_executable_handle_t executable = nullptr;++ auto setup = createCompilerAndDescriptor();+ ASSERT_NE(setup.compiler, nullptr);++ vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),+ setup.serializedIR.size,+ setup.buildFlags.c_str(),+ setup.buildFlags.size()};++ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,+ desc,+ allocator.get(),+ &blobBuffer,+ &blobSize,+ &executable);++ EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());++ // Clean up blob buffer tracked by allocator.+ if (blobBuffer != nullptr) {+ allocator->deallocate(allocator.get(), blobBuffer);+ }++ // Verify blob buffer was erased from tracking vector.+ auto blobIt = std::find_if(allocator->m_info.begin(),+ allocator->m_info.end(),+ [blobBuffer](const std::pair<uint8_t*, size_t>& item) {+ return item.first == blobBuffer;+ });+ EXPECT_EQ(blobIt, allocator->m_info.end());+ EXPECT_EQ(allocator->m_info.size(), 0);++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);+}++TEST_P(VclAllocatorFuncTests, VerifyOwnershipTransferToTensor) {+ uint8_t* blobBuffer = nullptr;+ uint64_t blobSize = 0;+ vcl_executable_handle_t executable = nullptr;++ auto setup = createCompilerAndDescriptor();+ ASSERT_NE(setup.compiler, nullptr);++ vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),+ setup.serializedIR.size,+ setup.buildFlags.c_str(),+ setup.buildFlags.size()};++ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,+ desc,+ allocator.get(),+ &blobBuffer,+ &blobSize,+ &executable);++ EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());++ // Retrieve the real allocated size for the blob from the allocator (mirroring compiler_impl.cpp)+ auto it = std::find_if(allocator->m_info.begin(),+ allocator->m_info.end(),+ [blobBuffer](const std::pair<uint8_t*, size_t>& item) {+ return item.first == blobBuffer;+ });+ ASSERT_NE(it, allocator->m_info.end());+ size_t alignedBlobSize = it->second;++ // Wrap Blob in ov::Tensor to test ownership transfer+ {+ ov::Tensor tensor = ::intel_npu::make_tensor_from_aligned_addr(blobBuffer, alignedBlobSize, allocator);+ EXPECT_EQ(tensor.data(), blobBuffer);+ EXPECT_EQ(tensor.get_byte_size(), alignedBlobSize);++ // Remove only the transferred blob, leaving any possible temporary allocations+ // to be safely freed by ~vcl_allocator_3 (mirroring compiler_impl.cpp)+ allocator->m_info.erase(it);+ } // tensor goes out of scope here: custom deleter correctly handles the physical memory free++ // After erasing the blob,+ // the tracking info in the allocator should be empty.+ EXPECT_EQ(allocator->m_info.size(), 0);++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);+}++TEST_P(VclAllocatorFuncTests, VerifyOrphanMemoryCleanupOnDestruction) {+ uint8_t* blobBuffer = nullptr;+ uint64_t blobSize = 0;+ vcl_executable_handle_t executable = nullptr;++ auto setup = createCompilerAndDescriptor();+ ASSERT_NE(setup.compiler, nullptr);++ vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),+ setup.serializedIR.size,+ setup.buildFlags.c_str(),+ setup.buildFlags.size()};++ auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,+ desc,+ allocator.get(),+ &blobBuffer,+ &blobSize,+ &executable);++ EXPECT_EQ(result, VCL_RESULT_SUCCESS);+ ASSERT_NE(executable, nullptr);+ auto compatibilityString = getCompatibilityString(executable);+ EXPECT_FALSE(compatibilityString.empty());+ EXPECT_EQ(allocator->m_info.size(), 1); // 1 allocation: blob++ EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);++ // Purpose: Simulate VCL crash or early return where the memory is temporarily tracked as an orphan leak+ // When the allocator goes out of scope and gets destroyed, it should cleanly free all tracked memory++ allocator.reset();++ EXPECT_EQ(allocator, nullptr);+}++} // namespace ov::test::behaviornamespace {diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hppdeleted file mode 100644index 3fb88671232..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/vcl_allocator_test.hpp+++ /dev/null@@ -1,364 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>--#include <algorithm>-#include <memory>-#include <vector>--#include "common/npu_test_env_cfg.hpp"-#include "common_test_utils/file_utils.hpp"-#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"-#include "intel_npu/utils/utils.hpp"-#include "intel_npu/utils/vcl/vcl_allocator.hpp"-#include "intel_npu/utils/vcl/vcl_api.hpp"-#include "model_serializer.hpp"-#include "openvino/core/except.hpp"-#include "openvino/runtime/make_tensor.hpp"-#include "openvino/runtime/tensor.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov::test::behavior {--class VclAllocatorFuncTests : public ::testing::TestWithParam<std::string> {-public:- static std::string getTestCaseName(testing::TestParamInfo<std::string> obj) {- auto targetDevice = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');- std::ostringstream result;- result << "targetDevice=" << ov::test::utils::getDeviceNameTestCase(targetDevice) << "_";- result << "targetPlatform=" + ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);- return result.str();- }--protected:- std::string targetDevice;- std::shared_ptr<ov::Model> model;- std::shared_ptr<::intel_npu::vcl_allocator_2> allocator;-- void SetUp() override {- targetDevice = GetParam();- model = ov::test::utils::make_conv_pool_relu();- allocator = std::make_shared<::intel_npu::vcl_allocator_2>();-- try {- std::string ov_lib_dir = ov::test::utils::getOpenvinoLibDirectory();- ::intel_npu::VCLApi::getInstance(ov_lib_dir);- } catch (const std::exception&) {- GTEST_SKIP() << "Couldn't load compiler library";- }- }-- // Helper struct and function to reduce code duplication- struct CompilerSetupState {- std::string buildFlags;- ::intel_npu::SerializedIR serializedIR;- vcl_compiler_handle_t compiler = nullptr;- vcl_log_handle_t logHandle = nullptr;-- CompilerSetupState() = default;- CompilerSetupState(const CompilerSetupState&) = delete;- CompilerSetupState& operator=(const CompilerSetupState&) = delete;- CompilerSetupState(CompilerSetupState&& other) noexcept- : buildFlags(std::move(other.buildFlags)),- serializedIR(std::move(other.serializedIR)),- compiler(other.compiler),- logHandle(other.logHandle) {- other.compiler = nullptr;- other.logHandle = nullptr;- }- CompilerSetupState& operator=(CompilerSetupState&& other) noexcept {- if (this != &other) {- release();- buildFlags = std::move(other.buildFlags);- serializedIR = std::move(other.serializedIR);- compiler = other.compiler;- logHandle = other.logHandle;- other.compiler = nullptr;- other.logHandle = nullptr;- }- return *this;- }-- ~CompilerSetupState() {- release();- }-- private:- void release() {- if (compiler != nullptr) {- ::intel_npu::vclCompilerDestroy(compiler);- compiler = nullptr;- }- }- };-- CompilerSetupState createCompilerAndDescriptor() {- CompilerSetupState state;-- state.buildFlags = ::intel_npu::compiler_utils::serializeIOInfo(model, true);-- auto platform = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);- if (platform.find("NPU") == 0) {- platform = platform.substr(3); // Remove "NPU" prefix if present- }-- state.buildFlags +=- " --config NPU_PLATFORM=\"" + platform + "\" NPU_COMPILATION_MODE_PARAMS=\"optimization-level=0\"";-- vcl_version_info_t vclVersion = {};- vcl_version_info_t vclProfilingVersion = {};- ::intel_npu::vclGetVersion(&vclVersion, &vclProfilingVersion);-- vcl_compiler_desc_t compilerDesc = {};- compilerDesc.version = vclVersion;- compilerDesc.debugLevel =- static_cast<__vcl_log_level_t>(static_cast<int>(::intel_npu::Logger::global().level()) + 1);-- uint32_t defaultTileCount = std::numeric_limits<uint32_t>::max();- if (vclVersion.major == 7 && vclVersion.minor < 6) {- defaultTileCount = std::numeric_limits<uint16_t>::max();- }-- vcl_device_desc_t deviceDesc = {sizeof(vcl_device_desc_t),- 0x00,- std::numeric_limits<uint16_t>::max(),- defaultTileCount};-- ::intel_npu::vclCompilerCreate(&compilerDesc, &deviceDesc, &state.compiler, &state.logHandle);-- if (state.compiler == nullptr) {- ADD_FAILURE() << "vclCompilerCreate failed";- return state;- }-- ze_graph_compiler_version_info_t vclVersionInfo = {0, 0};- vcl_compiler_properties_t compilerProp = {};- ::intel_npu::vclCompilerGetProperties(state.compiler, &compilerProp);- vclVersionInfo.major = compilerProp.version.major;- vclVersionInfo.minor = compilerProp.version.minor;-- auto isOptionValueSupportedByCompiler = [](const std::string&, const std::optional<std::string>&) {- return true;- };-- state.serializedIR =- ::intel_npu::compiler_utils::serializeIR(model,- vclVersionInfo,- 10,- ::intel_npu::MODEL_SERIALIZER_VERSION::defaultValue(),- isOptionValueSupportedByCompiler);-- state.buildFlags += " NPU_MODEL_SERIALIZER_VERSION=\"" +- ::intel_npu::MODEL_SERIALIZER_VERSION::toString(state.serializedIR.serializerVersion) +- "\"";-- return state;- }-- static std::string getCompatibilityString(vcl_executable_handle_t executable) {- uint64_t compatibilityStringSize = 0;- auto result = ::intel_npu::vclExecutableGetCompatibilityString(executable, nullptr, &compatibilityStringSize);- if (result != VCL_RESULT_SUCCESS || compatibilityStringSize == 0) {- ADD_FAILURE() << "Failed to get compatibility string size";- return {};- }- const uint64_t maxSize = static_cast<uint64_t>(std::vector<char>().max_size());- if (compatibilityStringSize > maxSize) {- ADD_FAILURE() << "Compatibility string size is too large";- return {};- }- std::vector<char> compatibilityStringBuffer(static_cast<size_t>(compatibilityStringSize), '\0');- result = ::intel_npu::vclExecutableGetCompatibilityString(executable,- compatibilityStringBuffer.data(),- &compatibilityStringSize);- if (result != VCL_RESULT_SUCCESS) {- ADD_FAILURE() << "Failed to get compatibility string";- return {};- }- if (compatibilityStringSize > static_cast<uint64_t>(compatibilityStringBuffer.size())) {- ADD_FAILURE() << "Returned compatibility string size exceeds the allocated buffer size";- return {};- }- size_t outSize = static_cast<size_t>(compatibilityStringSize);- if (outSize > 0 && compatibilityStringBuffer[outSize - 1] == '\0') {- --outSize;- }- return std::string(compatibilityStringBuffer.data(), outSize);- }-};--TEST_P(VclAllocatorFuncTests, VerifyAllocation) {- uint8_t* blobBuffer = nullptr;- uint64_t blobSize = 0;- vcl_executable_handle_t executable = nullptr;-- auto setup = createCompilerAndDescriptor();- ASSERT_NE(setup.compiler, nullptr);-- vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),- setup.serializedIR.size,- setup.buildFlags.c_str(),- setup.buildFlags.size()};-- auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,- desc,- allocator.get(),- &blobBuffer,- &blobSize,- &executable);-- EXPECT_EQ(result, VCL_RESULT_SUCCESS);- EXPECT_NE(blobBuffer, nullptr);- ASSERT_NE(executable, nullptr);- auto compatibilityString = getCompatibilityString(executable);- EXPECT_FALSE(compatibilityString.empty());-- // Verify it tracked blob allocation.- EXPECT_EQ(allocator->m_info.size(), 1);-- auto blobIt = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [blobBuffer](const std::pair<uint8_t*, size_t>& item) {- return item.first == blobBuffer;- });- EXPECT_NE(blobIt, allocator->m_info.end());-- EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);-}--TEST_P(VclAllocatorFuncTests, VerifyDeallocation) {- uint8_t* blobBuffer = nullptr;- uint64_t blobSize = 0;- vcl_executable_handle_t executable = nullptr;-- auto setup = createCompilerAndDescriptor();- ASSERT_NE(setup.compiler, nullptr);-- vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),- setup.serializedIR.size,- setup.buildFlags.c_str(),- setup.buildFlags.size()};-- auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,- desc,- allocator.get(),- &blobBuffer,- &blobSize,- &executable);-- EXPECT_EQ(result, VCL_RESULT_SUCCESS);- ASSERT_NE(executable, nullptr);- auto compatibilityString = getCompatibilityString(executable);- EXPECT_FALSE(compatibilityString.empty());-- // Clean up blob buffer tracked by allocator.- if (blobBuffer != nullptr) {- allocator->deallocate(allocator.get(), blobBuffer);- }-- // Verify blob buffer was erased from tracking vector.- auto blobIt = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [blobBuffer](const std::pair<uint8_t*, size_t>& item) {- return item.first == blobBuffer;- });- EXPECT_EQ(blobIt, allocator->m_info.end());- EXPECT_EQ(allocator->m_info.size(), 0);-- EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);-}--TEST_P(VclAllocatorFuncTests, VerifyOwnershipTransferToTensor) {- uint8_t* blobBuffer = nullptr;- uint64_t blobSize = 0;- vcl_executable_handle_t executable = nullptr;-- auto setup = createCompilerAndDescriptor();- ASSERT_NE(setup.compiler, nullptr);-- vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),- setup.serializedIR.size,- setup.buildFlags.c_str(),- setup.buildFlags.size()};-- auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,- desc,- allocator.get(),- &blobBuffer,- &blobSize,- &executable);-- EXPECT_EQ(result, VCL_RESULT_SUCCESS);- ASSERT_NE(executable, nullptr);- auto compatibilityString = getCompatibilityString(executable);- EXPECT_FALSE(compatibilityString.empty());-- // Retrieve the real allocated size for the blob from the allocator (mirroring compiler_impl.cpp)- auto it = std::find_if(allocator->m_info.begin(),- allocator->m_info.end(),- [blobBuffer](const std::pair<uint8_t*, size_t>& item) {- return item.first == blobBuffer;- });- ASSERT_NE(it, allocator->m_info.end());- size_t alignedBlobSize = it->second;-- // Wrap Blob in ov::Tensor to test ownership transfer- {- ov::Tensor tensor = ::intel_npu::make_tensor_from_aligned_addr(blobBuffer, alignedBlobSize, allocator);- EXPECT_EQ(tensor.data(), blobBuffer);- EXPECT_EQ(tensor.get_byte_size(), alignedBlobSize);-- // Remove only the transferred blob, leaving any possible temporary allocations- // to be safely freed by ~vcl_allocator_3 (mirroring compiler_impl.cpp)- allocator->m_info.erase(it);- } // tensor goes out of scope here: custom deleter correctly handles the physical memory free-- // After erasing the blob,- // the tracking info in the allocator should be empty.- EXPECT_EQ(allocator->m_info.size(), 0);-- EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);-}--TEST_P(VclAllocatorFuncTests, VerifyOrphanMemoryCleanupOnDestruction) {- uint8_t* blobBuffer = nullptr;- uint64_t blobSize = 0;- vcl_executable_handle_t executable = nullptr;-- auto setup = createCompilerAndDescriptor();- ASSERT_NE(setup.compiler, nullptr);-- vcl_executable_desc_t desc = {setup.serializedIR.buffer.get(),- setup.serializedIR.size,- setup.buildFlags.c_str(),- setup.buildFlags.size()};-- auto result = ::intel_npu::vclAllocatedExecutableCreate4(setup.compiler,- desc,- allocator.get(),- &blobBuffer,- &blobSize,- &executable);-- EXPECT_EQ(result, VCL_RESULT_SUCCESS);- ASSERT_NE(executable, nullptr);- auto compatibilityString = getCompatibilityString(executable);- EXPECT_FALSE(compatibilityString.empty());- EXPECT_EQ(allocator->m_info.size(), 1); // 1 allocation: blob-- EXPECT_EQ(::intel_npu::vclExecutableDestroy(executable), VCL_RESULT_SUCCESS);-- // Purpose: Simulate VCL crash or early return where the memory is temporarily tracked as an orphan leak- // When the allocator goes out of scope and gets destroyed, it should cleanly free all tracked memory-- allocator.reset();-- EXPECT_EQ(allocator, nullptr);-}--} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cppindex 1c280430f48..211235e0018 100644--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.cpp@@ -2,9 +2,429 @@// SPDX-License-Identifier: Apache-2.0//-#include "zero_graph.hpp"+#include <common_test_utils/test_assertions.hpp>+#include <gtest/gtest.h>+#include <stdlib.h>+#include "common/npu_test_env_cfg.hpp"+#include "common/utils.hpp"+#include "common/zero_init_mock.hpp"+#include "common_test_utils/subgraph_builders/multi_single_conv.hpp"+#include "driver_compiler_adapter.hpp"+#include "intel_npu/utils/utils.hpp"+#include "intel_npu/utils/zero/zero_mem.hpp"+#include "intel_npu/utils/zero/zero_mem_pool.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"+#include "model_serializer.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"#include "openvino/util/codec_xor.hpp"+#include "plugin_compiler_adapter.hpp"+#include "ze_graph_ext_wrappers.hpp"++using namespace intel_npu;++using CompilationParamsAndExtensionVersion = std::tuple<std::string, // Device name+ ov::AnyMap, // Config+ int>; // Extension Version+namespace {+size_t calculate_size_with_alignment_padding(size_t size, size_t alignment) {+ return size + alignment - (size % alignment);+}+} // namespace++namespace ov::test::behavior {+class ZeroGraphTest : public ::testing::TestWithParam<CompilationParamsAndExtensionVersion> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndExtensionVersion>& obj) {+ std::string targetDevice;+ ov::AnyMap configuration;+ uint32_t zeGraphNpuExtVersion;+ std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = obj.param;+ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }+ result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." ++ std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion));++ return result.str();+ }++ size_t make_blob() {+ size_t alignedSize = 0;+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor = {};+ serializeIR();+ localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache());+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize = 0;+ localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize);++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ blob = ::operator new(alignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ std::memcpy(blob, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);++ return alignedSize;+ }++protected:+ void SetUp() override {+ _logGuard.emplace(ov::log::Level::ERR);+ SKIP_IF_CURRENT_TEST_IS_DISABLED();++ std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = this->GetParam();++ model = ov::test::utils::make_multi_single_conv();+ blob = nullptr;++ std::shared_ptr<ZeroInitStructsMock> zeroInitMock =+ std::make_shared<ZeroInitStructsMock>(::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,+ zeGraphNpuExtVersion);+ zeroInitStruct = std::reinterpret_pointer_cast<ZeroInitStructsHolder>(zeroInitMock);+ zeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ }++ void TearDown() override {+ if (zeGraphExt != nullptr) {+ zeGraphExt->destroyGraph(graphDescriptor);+ }+ if (blob) {+ ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ }+ _logGuard.reset();+ }++ void serializeIR() {+ auto compilerProperties = zeroInitStruct->getCompilerProperties();+ const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported;+ // The test is not concerned with validating the serialization algorithm. Choose the "all-weights-copy" as the+ // safest version.+ serializedIR =+ ::intel_npu::compiler_utils::serializeIR(model,+ compilerProperties.compilerVersion,+ maxOpsetVersion,+ ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY,+ [](const std::string&, const std::optional<std::string>&) {+ return true;+ });+ }++ bool bypassUmdCache() {+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ if (configItem.first == ov::cache_dir.name()) {+ const auto set_cache_dir = configItem.second;+ if (!set_cache_dir.empty()) {+ return true;+ }+ }+ if (configItem.first == ov::intel_npu::bypass_umd_caching.name()) {+ if (configItem.second.as<bool>()) {+ return true;+ }+ }+ }+ }++ return false;+ }++ std::shared_ptr<ZeroInitStructsHolder> zeroInitStruct;+ std::shared_ptr<ZeGraphExtWrappers> zeGraphExt;+ ov::AnyMap configuration;++ ::intel_npu::SerializedIR serializedIR;+ GraphDescriptor graphDescriptor;++ std::shared_ptr<ov::Model> model;+ void* blob;++ std::string targetDevice;+ std::string blobPath;+ uint32_t zeGraphNpuExtVersion;+ std::optional<utils::LoggerLevelGuard> _logGuard;+};++using ZeroGraphCompilationTests = ZeroGraphTest;++TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) {+ serializeIR();+ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));+}++TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) {+ serializeIR();+ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ size_t totalSize = 1 * 3 * 24 * 24 * sizeof(float);+ std::shared_ptr<ZeroMem> buffer;+ OV_ASSERT_NO_THROW(+ buffer = ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, totalSize, ::utils::STANDARD_PAGE_SIZE, false));++ OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));+}++TEST_P(ZeroGraphTest, GetGraphInitBlob) {+ size_t alignedSize = 0;+ OV_ASSERT_NO_THROW(alignedSize = make_blob());++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));+}++TEST_P(ZeroGraphTest, GetNetworkMeta) {+ serializeIR();+ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));++ OV_ASSERT_NO_THROW(NetworkMetadata meta = zeGraphExt->getNetworkMeta(graphDescriptor));+}++TEST_P(ZeroGraphTest, QueryGraph) {+ serializeIR();+ OV_ASSERT_NO_THROW(zeGraphExt->queryGraph(std::move(serializedIR), ""));+}++TEST_P(ZeroGraphTest, GetGraphBinary) {+ size_t alignedSize = 0;+ OV_ASSERT_NO_THROW(alignedSize = make_blob());++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec;+ OV_ASSERT_NO_THROW(zeGraphExt->getGraphBinary(graphDescriptor, blobVec, blobPtr, alignedSize));+}++TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) {+ serializeIR();++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ ASSERT_ANY_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, nullptr));+}++TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob) {+ size_t alignedSize = 0;+ OV_ASSERT_NO_THROW(alignedSize = make_blob());++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ std::shared_ptr<ZeroMem> buffer;+ OV_ASSERT_NO_THROW(+ buffer =+ ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, alignedSize, ::utils::STANDARD_PAGE_SIZE, false));++ OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));+}++TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob) {+ size_t alignedSize = 0;+ OV_ASSERT_NO_THROW(alignedSize = make_blob());++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ std::shared_ptr<ZeroMem> buffer;+ OV_ASSERT_NO_THROW(+ buffer =+ ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, alignedSize, ::utils::STANDARD_PAGE_SIZE, false));++ OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, static_cast<char*>(buffer->data()) + 1));+}++TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) {+ // create blob -> compile model first+ void* blobAddressUnaligned = nullptr;+ size_t alignedSize;+ {+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor;+ serializeIR();+ OV_ASSERT_NO_THROW(localGraphDescriptor =+ localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize = 0;+ OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ size_t unalignedSize = alignedSize + 16;+ blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ blobAddressUnaligned = static_cast<uint8_t*>(blob) + 16;+ std::memcpy(blobAddressUnaligned, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);+ }++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blobAddressUnaligned, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));+ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));+}++TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) {+ // create blob -> compile model first+ size_t alignedSize;+ size_t unalignedSize;+ {+ // use local zeGraphExt;+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ GraphDescriptor localGraphDescriptor;+ serializeIR();+ OV_ASSERT_NO_THROW(localGraphDescriptor =+ localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));+ const uint8_t* blobPtr = nullptr;+ std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers+ size_t blobSize = 0;+ OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));++ alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);+ unalignedSize = alignedSize + 16;+ blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));+ std::memcpy(blob, blobPtr, blobSize);+ localZeGraphExt->destroyGraph(localGraphDescriptor);+ }++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, unalignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));++ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));+}++TEST_P(ZeroGraphTest, SetAlignedBlob) {+ // create blob -> compile model first+ size_t alignedSize = 0;+ OV_ASSERT_NO_THROW(alignedSize = make_blob());++ OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));+ OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));+ if (zeroInitStruct->getGraphDdiTable().version() >= ZE_MAKE_VERSION(1, 13) &&+ zeroInitStruct->isExternalMemoryStandardAllocationSupported()) {+ ASSERT_TRUE(zeGraphExt->isBlobDataImported(graphDescriptor));+ } else {+ ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));+ }+}++#ifdef _WIN32+TEST_P(ZeroGraphTest, CheckNoThrowOnUnsupportedFeature) {+ if (zeroInitStruct->getGraphDdiTable().version() >= ZE_MAKE_VERSION(1, 11)) {+ // Driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here+ if (zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(zeroInitStruct->getDevice(),+ ZE_NPU_DRIVER_OPTIONS,+ "NO_THROW_ON_UNSUPPORTED_FEATURE",+ nullptr) != ZE_RESULT_SUCCESS) {+ ADD_FAILURE() << "NO_THROW_ON_UNSUPPORTED_FEATURE shall be supported.";+ }+ }+}+#endif++TEST_P(ZeroGraphTest, DontDestroyZeroGraphWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logsMutex;++ std::function<void(std::string_view)> logCb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logsMutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto localZeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> localZeroInitStruct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(localZeroInitMock);++ {+ utils::LogCallbackGuard log_callback_guard(logCb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto localZeroGraphExt = std::make_shared<ZeGraphExtWrappers>(localZeroInitStruct);+ serializeIR();+ GraphDescriptor localGraphDescriptor;+ OV_ASSERT_NO_THROW(localGraphDescriptor = localZeroGraphExt->getGraphDescriptor(serializedIR, ""));+ OV_ASSERT_NO_THROW(localZeroGraphExt->initializeGraph(localGraphDescriptor));++ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(localZeroInitMock);++ try {+ localZeroGraphExt->destroyGraph(localGraphDescriptor);+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or graph is null while trying to destroy graph."), std::string::npos);+ ASSERT_EQ(logs.find("failed to destroy graph handle"), std::string::npos);+}++using IsOptionSupported = ZeroGraphTest;++TEST_P(IsOptionSupported, GetCompilerSupportedOptions) {+ std::optional<std::string> compilerSupportedOptions;+ OV_ASSERT_NO_THROW(compilerSupportedOptions = zeGraphExt->getCompilerSupportedOptions());+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {+ ASSERT_FALSE(compilerSupportedOptions.has_value());+ } else {+ ASSERT_TRUE(compilerSupportedOptions.has_value());+ }+}++TEST_P(IsOptionSupported, PropertyNotSupportedByDriver) {+ std::optional<bool> isOptionSupportedResult;+ OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("FAKE_OPTION"));+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {+ ASSERT_FALSE(isOptionSupportedResult.has_value());+ } else {+ ASSERT_TRUE(isOptionSupportedResult.has_value());+ ASSERT_FALSE(isOptionSupportedResult.value());+ }+}++TEST_P(IsOptionSupported, PropertySupportedByDriver) {+ std::optional<bool> isOptionSupportedResult;+ OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("PERFORMANCE_HINT"));+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {+ ASSERT_FALSE(isOptionSupportedResult.has_value());+ } else {+ ASSERT_TRUE(isOptionSupportedResult.has_value());+ ASSERT_TRUE(isOptionSupportedResult.value());+ }+}++using EncryptionCallbacks = ZeroGraphTest;++TEST_P(EncryptionCallbacks, EncryptionCallbacksSetSecureCompileFlag) {+ auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);+ serializeIR();+ if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 17)) {+ OV_EXPECT_THROW(+ localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache(), /* secureCompile = */ true),+ ov::Exception,+ testing::HasSubstr(+ "Secure compilation was requested, but the current driver version does not support it."));+ } else {+ OV_ASSERT_NO_THROW(+ localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache(), /* secureCompile = */ true));+ }+}++} // namespace ov::test::behaviornamespace {const std::vector<ov::AnyMap> configsGraphCompilationTests = {{},diff --git a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp b/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hppdeleted file mode 100644index 27767366227..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/compiler_adapter/zero_graph.hpp+++ /dev/null@@ -1,429 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gtest/gtest.h>-#include <stdlib.h>--#include <common_test_utils/test_assertions.hpp>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common/zero_init_mock.hpp"-#include "common_test_utils/subgraph_builders/multi_single_conv.hpp"-#include "driver_compiler_adapter.hpp"-#include "intel_npu/utils/utils.hpp"-#include "intel_npu/utils/zero/zero_mem.hpp"-#include "intel_npu/utils/zero/zero_mem_pool.hpp"-#include "intel_npu/utils/zero/zero_utils.hpp"-#include "model_serializer.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"-#include "plugin_compiler_adapter.hpp"-#include "ze_graph_ext_wrappers.hpp"--using namespace intel_npu;--using CompilationParamsAndExtensionVersion = std::tuple<std::string, // Device name- ov::AnyMap, // Config- int>; // Extension Version-namespace {-size_t calculate_size_with_alignment_padding(size_t size, size_t alignment) {- return size + alignment - (size % alignment);-}-} // namespace--namespace ov::test::behavior {-class ZeroGraphTest : public ::testing::TestWithParam<CompilationParamsAndExtensionVersion> {-public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParamsAndExtensionVersion>& obj) {- std::string targetDevice;- ov::AnyMap configuration;- uint32_t zeGraphNpuExtVersion;- std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = obj.param;- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }- result << "zeGraphNpuExtVersion=" + std::to_string(ZE_MAJOR_VERSION(zeGraphNpuExtVersion)) + "." +- std::to_string(ZE_MINOR_VERSION(zeGraphNpuExtVersion));-- return result.str();- }-- size_t make_blob() {- size_t alignedSize = 0;- // use local zeGraphExt;- auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);- GraphDescriptor localGraphDescriptor = {};- serializeIR();- localGraphDescriptor = localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache());- const uint8_t* blobPtr = nullptr;- std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers- size_t blobSize = 0;- localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize);-- alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);- blob = ::operator new(alignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));- std::memcpy(blob, blobPtr, blobSize);- localZeGraphExt->destroyGraph(localGraphDescriptor);-- return alignedSize;- }--protected:- void SetUp() override {- _logGuard.emplace(ov::log::Level::ERR);- SKIP_IF_CURRENT_TEST_IS_DISABLED();-- std::tie(targetDevice, configuration, zeGraphNpuExtVersion) = this->GetParam();-- model = ov::test::utils::make_multi_single_conv();- blob = nullptr;-- std::shared_ptr<ZeroInitStructsMock> zeroInitMock =- std::make_shared<ZeroInitStructsMock>(::intel_npu::test_constants::TARGET_ZE_DRIVER_NPU_EXT_VERSION,- zeGraphNpuExtVersion);- zeroInitStruct = std::reinterpret_pointer_cast<ZeroInitStructsHolder>(zeroInitMock);- zeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);- }-- void TearDown() override {- if (zeGraphExt != nullptr) {- zeGraphExt->destroyGraph(graphDescriptor);- }- if (blob) {- ::operator delete(blob, std::align_val_t(::utils::STANDARD_PAGE_SIZE));- }- _logGuard.reset();- }-- void serializeIR() {- auto compilerProperties = zeroInitStruct->getCompilerProperties();- const auto maxOpsetVersion = compilerProperties.maxOVOpsetVersionSupported;- // The test is not concerned with validating the serialization algorithm. Choose the "all-weights-copy" as the- // safest version.- serializedIR =- ::intel_npu::compiler_utils::serializeIR(model,- compilerProperties.compilerVersion,- maxOpsetVersion,- ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY,- [](const std::string&, const std::optional<std::string>&) {- return true;- });- }-- bool bypassUmdCache() {- if (!configuration.empty()) {- for (auto& configItem : configuration) {- if (configItem.first == ov::cache_dir.name()) {- const auto set_cache_dir = configItem.second;- if (!set_cache_dir.empty()) {- return true;- }- }- if (configItem.first == ov::intel_npu::bypass_umd_caching.name()) {- if (configItem.second.as<bool>()) {- return true;- }- }- }- }-- return false;- }-- std::shared_ptr<ZeroInitStructsHolder> zeroInitStruct;- std::shared_ptr<ZeGraphExtWrappers> zeGraphExt;- ov::AnyMap configuration;-- ::intel_npu::SerializedIR serializedIR;- GraphDescriptor graphDescriptor;-- std::shared_ptr<ov::Model> model;- void* blob;-- std::string targetDevice;- std::string blobPath;- uint32_t zeGraphNpuExtVersion;- std::optional<utils::LoggerLevelGuard> _logGuard;-};--using ZeroGraphCompilationTests = ZeroGraphTest;--TEST_P(ZeroGraphCompilationTests, GetGraphInitIR) {- serializeIR();- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-}--TEST_P(ZeroGraphCompilationTests, GetInitSetArgsDestroyGraphAlignedMemoryIR) {- serializeIR();- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- size_t totalSize = 1 * 3 * 24 * 24 * sizeof(float);- std::shared_ptr<ZeroMem> buffer;- OV_ASSERT_NO_THROW(- buffer = ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, totalSize, ::utils::STANDARD_PAGE_SIZE, false));-- OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));-}--TEST_P(ZeroGraphTest, GetGraphInitBlob) {- size_t alignedSize = 0;- OV_ASSERT_NO_THROW(alignedSize = make_blob());-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-}--TEST_P(ZeroGraphTest, GetNetworkMeta) {- serializeIR();- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));-- OV_ASSERT_NO_THROW(NetworkMetadata meta = zeGraphExt->getNetworkMeta(graphDescriptor));-}--TEST_P(ZeroGraphTest, QueryGraph) {- serializeIR();- OV_ASSERT_NO_THROW(zeGraphExt->queryGraph(std::move(serializedIR), ""));-}--TEST_P(ZeroGraphTest, GetGraphBinary) {- size_t alignedSize = 0;- OV_ASSERT_NO_THROW(alignedSize = make_blob());-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- const uint8_t* blobPtr = nullptr;- std::vector<uint8_t> blobVec;- OV_ASSERT_NO_THROW(zeGraphExt->getGraphBinary(graphDescriptor, blobVec, blobPtr, alignedSize));-}--TEST_P(ZeroGraphTest, SetGraphArgOnNullBuffer) {- serializeIR();-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- ASSERT_ANY_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, nullptr));-}--TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphAlignedMemoryMallocBlob) {- size_t alignedSize = 0;- OV_ASSERT_NO_THROW(alignedSize = make_blob());-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- std::shared_ptr<ZeroMem> buffer;- OV_ASSERT_NO_THROW(- buffer =- ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, alignedSize, ::utils::STANDARD_PAGE_SIZE, false));-- OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, buffer->data()));-}--TEST_P(ZeroGraphTest, GetInitSetArgsDestroyGraphNotAlignedMemoryMallocBlob) {- size_t alignedSize = 0;- OV_ASSERT_NO_THROW(alignedSize = make_blob());-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- std::shared_ptr<ZeroMem> buffer;- OV_ASSERT_NO_THROW(- buffer =- ::intel_npu::zero_mem::allocate_memory(zeroInitStruct, alignedSize, ::utils::STANDARD_PAGE_SIZE, false));-- OV_ASSERT_NO_THROW(zeGraphExt->setGraphArgumentValue(graphDescriptor, 0, static_cast<char*>(buffer->data()) + 1));-}--TEST_P(ZeroGraphTest, SetUnalignedAddressBlob) {- // create blob -> compile model first- void* blobAddressUnaligned = nullptr;- size_t alignedSize;- {- // use local zeGraphExt;- auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);- GraphDescriptor localGraphDescriptor;- serializeIR();- OV_ASSERT_NO_THROW(localGraphDescriptor =- localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));- const uint8_t* blobPtr = nullptr;- std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers- size_t blobSize = 0;- OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));-- alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);- size_t unalignedSize = alignedSize + 16;- blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));- blobAddressUnaligned = static_cast<uint8_t*>(blob) + 16;- std::memcpy(blobAddressUnaligned, blobPtr, blobSize);- localZeGraphExt->destroyGraph(localGraphDescriptor);- }-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blobAddressUnaligned, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));- ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));-}--TEST_P(ZeroGraphTest, SetUnalignedSizeBlob) {- // create blob -> compile model first- size_t alignedSize;- size_t unalignedSize;- {- // use local zeGraphExt;- auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);- GraphDescriptor localGraphDescriptor;- serializeIR();- OV_ASSERT_NO_THROW(localGraphDescriptor =- localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache()));- const uint8_t* blobPtr = nullptr;- std::vector<uint8_t> blobVec; // plugin needs to keep a copy of the blob for older drivers- size_t blobSize = 0;- OV_ASSERT_NO_THROW(localZeGraphExt->getGraphBinary(localGraphDescriptor, blobVec, blobPtr, blobSize));-- alignedSize = calculate_size_with_alignment_padding(blobSize, ::utils::STANDARD_PAGE_SIZE);- unalignedSize = alignedSize + 16;- blob = ::operator new(unalignedSize, std::align_val_t(::utils::STANDARD_PAGE_SIZE));- std::memcpy(blob, blobPtr, blobSize);- localZeGraphExt->destroyGraph(localGraphDescriptor);- }-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, unalignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));-- ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));-}--TEST_P(ZeroGraphTest, SetAlignedBlob) {- // create blob -> compile model first- size_t alignedSize = 0;- OV_ASSERT_NO_THROW(alignedSize = make_blob());-- OV_ASSERT_NO_THROW(graphDescriptor = zeGraphExt->getGraphDescriptor(blob, alignedSize));- OV_ASSERT_NO_THROW(zeGraphExt->initializeGraph(graphDescriptor));- if (zeroInitStruct->getGraphDdiTable().version() >= ZE_MAKE_VERSION(1, 13) &&- zeroInitStruct->isExternalMemoryStandardAllocationSupported()) {- ASSERT_TRUE(zeGraphExt->isBlobDataImported(graphDescriptor));- } else {- ASSERT_FALSE(zeGraphExt->isBlobDataImported(graphDescriptor));- }-}--#ifdef _WIN32-TEST_P(ZeroGraphTest, CheckNoThrowOnUnsupportedFeature) {- if (zeroInitStruct->getGraphDdiTable().version() >= ZE_MAKE_VERSION(1, 11)) {- // Driver shall return NO_THROW_ON_UNSUPPORTED_FEATURE as supported to go further here- if (zeroInitStruct->getGraphDdiTable().pfnCompilerIsOptionSupported(zeroInitStruct->getDevice(),- ZE_NPU_DRIVER_OPTIONS,- "NO_THROW_ON_UNSUPPORTED_FEATURE",- nullptr) != ZE_RESULT_SUCCESS) {- ADD_FAILURE() << "NO_THROW_ON_UNSUPPORTED_FEATURE shall be supported.";- }- }-}-#endif--TEST_P(ZeroGraphTest, DontDestroyZeroGraphWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logsMutex;-- std::function<void(std::string_view)> logCb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logsMutex);- logs.append(msg);- logs.push_back('\n');- };-- auto localZeroInitMock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> localZeroInitStruct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(localZeroInitMock);-- {- utils::LogCallbackGuard log_callback_guard(logCb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto localZeroGraphExt = std::make_shared<ZeGraphExtWrappers>(localZeroInitStruct);- serializeIR();- GraphDescriptor localGraphDescriptor;- OV_ASSERT_NO_THROW(localGraphDescriptor = localZeroGraphExt->getGraphDescriptor(serializedIR, ""));- OV_ASSERT_NO_THROW(localZeroGraphExt->initializeGraph(localGraphDescriptor));-- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(localZeroInitMock);-- try {- localZeroGraphExt->destroyGraph(localGraphDescriptor);- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or graph is null while trying to destroy graph."), std::string::npos);- ASSERT_EQ(logs.find("failed to destroy graph handle"), std::string::npos);-}--using IsOptionSupported = ZeroGraphTest;--TEST_P(IsOptionSupported, GetCompilerSupportedOptions) {- std::optional<std::string> compilerSupportedOptions;- OV_ASSERT_NO_THROW(compilerSupportedOptions = zeGraphExt->getCompilerSupportedOptions());- if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {- ASSERT_FALSE(compilerSupportedOptions.has_value());- } else {- ASSERT_TRUE(compilerSupportedOptions.has_value());- }-}--TEST_P(IsOptionSupported, PropertyNotSupportedByDriver) {- std::optional<bool> isOptionSupportedResult;- OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("FAKE_OPTION"));- if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {- ASSERT_FALSE(isOptionSupportedResult.has_value());- } else {- ASSERT_TRUE(isOptionSupportedResult.has_value());- ASSERT_FALSE(isOptionSupportedResult.value());- }-}--TEST_P(IsOptionSupported, PropertySupportedByDriver) {- std::optional<bool> isOptionSupportedResult;- OV_ASSERT_NO_THROW(isOptionSupportedResult = zeGraphExt->isOptionSupported("PERFORMANCE_HINT"));- if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 11)) {- ASSERT_FALSE(isOptionSupportedResult.has_value());- } else {- ASSERT_TRUE(isOptionSupportedResult.has_value());- ASSERT_TRUE(isOptionSupportedResult.value());- }-}--using EncryptionCallbacks = ZeroGraphTest;--TEST_P(EncryptionCallbacks, EncryptionCallbacksSetSecureCompileFlag) {- auto localZeGraphExt = std::make_shared<ZeGraphExtWrappers>(zeroInitStruct);- serializeIR();- if (zeroInitStruct->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 17)) {- OV_EXPECT_THROW(- localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache(), /* secureCompile = */ true),- ov::Exception,- testing::HasSubstr(- "Secure compilation was requested, but the current driver version does not support it."));- } else {- OV_ASSERT_NO_THROW(- localZeGraphExt->getGraphDescriptor(serializedIR, "", bypassUmdCache(), /* secureCompile = */ true));- }-}--} // namespace ov::test::behaviordiff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cppindex 9a479ab02f4..3ac8ea79bc7 100644--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.cpp@@ -2,10 +2,404 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/plugin/test_properties.hpp"+#include <algorithm>+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <random>+#include <thread>+#include <vector>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"+#include "intel_npu/common/compiler_adapter_factory.hpp"+#include "intel_npu/common/filtered_config.hpp"+#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/npuw.hpp"+#include "intel_npu/config/options.hpp"+#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/npuw_private_properties.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/log.hpp"+#include "openvino/runtime/core.hpp"+#include "openvino/runtime/intel_npu/properties.hpp"+#include "plugin_property_manager.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"+#include "zero_backend.hpp"++using ::testing::AllOf;+using ::testing::HasSubstr;++using ConfigParams = std::tuple<std::string, // Device name+ std::string>; // Config name++namespace ov {+namespace test {+namespace behavior {+class PropertiesManagerTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<ConfigParams> {+protected:+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();+ ::intel_npu::FilteredConfig npu_config = ::intel_npu::FilteredConfig(options);+ ov::SoPtr<::intel_npu::IEngineBackend> backend;+ std::unique_ptr<::intel_npu::PluginPropertyManager> propertiesManager;++ std::string configuration;+ std::string targetDevice;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<ConfigParams>& obj) {+ std::string targetDevice;+ std::string configuration;+ std::tie(targetDevice, configuration) = obj.param;++ std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << targetDevice << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";+ result << "config=" << configuration << "_";++ return result.str();+ }++ void SetUp() override {+ using namespace ::intel_npu;++ std::tie(targetDevice, configuration) = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());++ options->reset();++#define REGISTER_OPTION(OPT_TYPE) \+ do { \+ auto dummyopt = details::makeOptionModel<OPT_TYPE>(); \+ std::string o_name = dummyopt.key().data(); \+ options->add<OPT_TYPE>(); \+ npu_config.enable(std::move(o_name), false); \+ } while (0)+ REGISTER_OPTION(LOG_LEVEL);+ REGISTER_OPTION(COMPILE_LOG_LEVEL);+ REGISTER_OPTION(CACHE_DIR);+ REGISTER_OPTION(CACHE_MODE);+ REGISTER_OPTION(COMPILED_BLOB);+ REGISTER_OPTION(DEVICE_ID);+ REGISTER_OPTION(NUM_STREAMS);+ REGISTER_OPTION(PERF_COUNT);+ REGISTER_OPTION(LOADED_FROM_CACHE);+ REGISTER_OPTION(COMPILATION_NUM_THREADS);+ REGISTER_OPTION(PERFORMANCE_HINT);+ REGISTER_OPTION(EXECUTION_MODE_HINT);+ REGISTER_OPTION(PERFORMANCE_HINT_NUM_REQUESTS);+ OPENVINO_SUPPRESS_DEPRECATED_START+ REGISTER_OPTION(ENABLE_CPU_PINNING);+ OPENVINO_SUPPRESS_DEPRECATED_END+ REGISTER_OPTION(INFERENCE_PRECISION_HINT);+ REGISTER_OPTION(MODEL_PRIORITY);+ REGISTER_OPTION(COMPILATION_MODE_PARAMS);+ REGISTER_OPTION(DMA_ENGINES);+ REGISTER_OPTION(TILES);+ REGISTER_OPTION(COMPILATION_MODE);+ REGISTER_OPTION(COMPILER_TYPE);+ REGISTER_OPTION(PLATFORM);+ REGISTER_OPTION(CREATE_EXECUTOR);+ REGISTER_OPTION(DYNAMIC_SHAPE_TO_STATIC);+ REGISTER_OPTION(PROFILING_TYPE);+ REGISTER_OPTION(BACKEND_COMPILATION_PARAMS);+ REGISTER_OPTION(BATCH_MODE);+ REGISTER_OPTION(BYPASS_UMD_CACHING);+ REGISTER_OPTION(DEFER_WEIGHTS_LOAD);+ REGISTER_OPTION(WEIGHTS_PATH);+ REGISTER_OPTION(RUN_INFERENCES_SEQUENTIALLY);+ REGISTER_OPTION(COMPILER_DYNAMIC_QUANTIZATION);+ REGISTER_OPTION(QDQ_OPTIMIZATION);+ REGISTER_OPTION(QDQ_OPTIMIZATION_AGGRESSIVE);+ REGISTER_OPTION(STEPPING);+ REGISTER_OPTION(DISABLE_VERSION_CHECK);+ REGISTER_OPTION(EXPORT_RAW_BLOB);+ REGISTER_OPTION(IMPORT_RAW_BLOB);+ REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);+ REGISTER_OPTION(TURBO);+ REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);+ REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);+ REGISTER_OPTION(MODEL_SERIALIZER_VERSION);+ REGISTER_OPTION(ENABLE_STRIDES_FOR);+ REGISTER_OPTION(SHARED_COMMON_QUEUE);++ if (backend) {+ REGISTER_OPTION(MAX_TILES);++ if (backend->isCommandQueueExtSupported()) {+ REGISTER_OPTION(WORKLOAD_TYPE);+ }+ if (backend->isContextExtSupported()) {+ REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);+ }+ }++ for_each_exposed_npuw_option([&](auto tag) {+ using Opt = typename decltype(tag)::type;+ REGISTER_OPTION(Opt);+ });++ npu_config.enableRuntimeOptions();++ // Special cases - options with OptionMode::Both must be enabled for the plugin even if the compiler does not+ // support them, because they may be used by the plugin itself or by the driver.+ // We still check compiler support to decide whether these options should be removed from the config string.++ // NPU_TURBO might be supported by the driver+ if (backend && backend->isCommandQueueExtSupported()) {+ npu_config.enable(ov::intel_npu::turbo.name(), true);+ }++ // LOG_LEVEL, PERFORMANCE_HINT and PERF_COUNT are needed by runtime options+ npu_config.enable(ov::log::level.name(), true);+ npu_config.enable(ov::hint::performance_mode.name(), true);+ npu_config.enable(ov::enable_profiling.name(), true);++ if (npu_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && backend != nullptr) {+ auto device = backend->getDevice();+ if (device) {+ auto platformName = device->getName();+ CompilerAdapterFactory compilerFactory;+ auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);+ if (compileType == ov::intel_npu::CompilerType::DRIVER) {+ npu_config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});+ }+ }+ }++ propertiesManager =+ std::make_unique<PluginPropertyManager>(npu_config, backend, ::intel_npu::Logger::global());+ }++ void TearDown() override {+ APIBaseTest::TearDown();+ }+};++TEST_P(PropertiesManagerTests, ExpectRunTimeSpecialBothPropertyIsSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool isSupported = false;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ propertiesManager->setProperty({{ov::log::level(ov::log::Level::INFO)}});+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});+ isSupported = propertiesManager->isPropertySupported(configuration);+ }++ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+ ASSERT_TRUE(isSupported);+}++using CompileLogLevelPropertyTests = PropertiesManagerTests;++TEST_P(CompileLogLevelPropertyTests, InheritsPluginLogLevelWhenUnset) {+ propertiesManager->setProperty({{ov::log::level(ov::log::Level::DEBUG)}});++ ov::Any retrieved;+ OV_ASSERT_NO_THROW(retrieved = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));+ ASSERT_EQ(retrieved.as<ov::log::Level>(), ov::log::Level::DEBUG);+}++TEST_P(CompileLogLevelPropertyTests, IsIndependentFromLogLevel) {+ propertiesManager->setProperty(+ {{ov::log::level(ov::log::Level::DEBUG)}, {ov::intel_npu::compile_log_level(ov::log::Level::ERR)}});++ ov::Any compilerLevel;+ OV_ASSERT_NO_THROW(compilerLevel = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));+ ASSERT_EQ(compilerLevel.as<ov::log::Level>(), ov::log::Level::ERR);++ ov::Any pluginLevel;+ OV_ASSERT_NO_THROW(pluginLevel = propertiesManager->getProperty(ov::log::level.name()));+ ASSERT_EQ(pluginLevel.as<ov::log::Level>(), ov::log::Level::DEBUG);+}++using CompatibilityCheckTests = PropertiesManagerTests;++TEST_P(CompatibilityCheckTests, ExpectArgumentIsNotSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool isSupported = true;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ ov::AnyMap arguments = {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),+ {"DUMMY_PROPERTY", "DUMMY_VALUE"}};++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);++ try {+ propertiesManager->setProperty(arguments);+ isSupported = true;+ } catch (...) {+ isSupported = false;+ }+ }++ ASSERT_FALSE(isSupported);+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++TEST_P(CompatibilityCheckTests, CompatibilityCheckUsesPluginCompilerAdapterOnlyWhenDriverVersionIsInsufficient) {+ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ // Determine at runtime whether the driver version is sufficient to handle the+ // compatibility check without falling back to PluginCompilerAdapter.+ const auto initStructs = backend ? backend->getInitStructs() : nullptr;+ const bool driverHandlesCompatibilityCheck =+ initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);++ bool isSupported = false;+ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ isSupported = propertiesManager->isPropertySupported(ov::compatibility_check.name());+ }++ if (driverHandlesCompatibilityCheck) {+ // Driver version >= 1.16: Property must be reported as supported.+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter complete"), std::string::npos);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_TRUE(isSupported);+ } else {+ if (logs.find("initialize PluginCompilerAdapter complete") == std::string::npos) {+ // Driver version < 1.16: Because CiP can not be loaded on this path in CI, the property must be reported as+ // unsupported.+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_FALSE(isSupported);+ } else {+ // Driver version < 1.16: Because CiP can be loaded on this path in CI, the property must be reported as+ // supported.+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_TRUE(isSupported);+ }+ }+}++TEST_P(CompatibilityCheckTests, ExpectTurboPropertyAndCompatibilityCheckAreSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool turboSupported = false;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ const bool turboSupportedByDevice = backend && backend->isCommandQueueExtSupported();++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});+ turboSupported = propertiesManager->isPropertySupported(ov::intel_npu::turbo.name());+ }++ if (turboSupportedByDevice) {+ // Turbo is supported by device, so checking support must not trigger compiler adapters.+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_TRUE(turboSupported);+ } else {+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_FALSE(turboSupported);+ }+}++using ExpectLoadingCompilerPropertySupported = PropertiesManagerTests;++TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool isSupported = false;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});+ isSupported = propertiesManager->isPropertySupported(configuration);+ }++ ASSERT_TRUE(isSupported);+ ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++using ExpectLoadingCompilerPropertyNotSupported = PropertiesManagerTests;++TEST_P(ExpectLoadingCompilerPropertyNotSupported, ExpectCompilerPropertyIsNotSupported) {+ std::string logs;+ std::mutex logs_mutex;+ bool isSupported = true;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);+ propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});+ isSupported = propertiesManager->isPropertySupported(configuration);+ }++ ASSERT_FALSE(isSupported);+ ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);+ ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp b/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hppdeleted file mode 100644index f79dbb471da..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/plugin/test_properties.hpp+++ /dev/null@@ -1,405 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <algorithm>-#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <random>-#include <thread>-#include <vector>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "functional_test_utils/ov_plugin_cache.hpp"-#include "intel_npu/common/compiler_adapter_factory.hpp"-#include "intel_npu/common/filtered_config.hpp"-#include "intel_npu/common/npu.hpp"-#include "intel_npu/config/npuw.hpp"-#include "intel_npu/config/options.hpp"-#include "intel_npu/npu_private_properties.hpp"-#include "intel_npu/npuw_private_properties.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/log.hpp"-#include "openvino/runtime/core.hpp"-#include "openvino/runtime/intel_npu/properties.hpp"-#include "plugin_property_manager.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"-#include "zero_backend.hpp"--using ::testing::AllOf;-using ::testing::HasSubstr;--using ConfigParams = std::tuple<std::string, // Device name- std::string>; // Config name--namespace ov {-namespace test {-namespace behavior {-class PropertiesManagerTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<ConfigParams> {-protected:- std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();- ::intel_npu::FilteredConfig npu_config = ::intel_npu::FilteredConfig(options);- ov::SoPtr<::intel_npu::IEngineBackend> backend;- std::unique_ptr<::intel_npu::PluginPropertyManager> propertiesManager;-- std::string configuration;- std::string targetDevice;--public:- static std::string getTestCaseName(const testing::TestParamInfo<ConfigParams>& obj) {- std::string targetDevice;- std::string configuration;- std::tie(targetDevice, configuration) = obj.param;-- std::replace(targetDevice.begin(), targetDevice.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << targetDevice << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(targetDevice) << "_";- result << "config=" << configuration << "_";-- return result.str();- }-- void SetUp() override {- using namespace ::intel_npu;-- std::tie(targetDevice, configuration) = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();-- backend = ov::SoPtr<IEngineBackend>(std::make_shared<ZeroEngineBackend>());-- options->reset();--#define REGISTER_OPTION(OPT_TYPE) \- do { \- auto dummyopt = details::makeOptionModel<OPT_TYPE>(); \- std::string o_name = dummyopt.key().data(); \- options->add<OPT_TYPE>(); \- npu_config.enable(std::move(o_name), false); \- } while (0)- REGISTER_OPTION(LOG_LEVEL);- REGISTER_OPTION(COMPILE_LOG_LEVEL);- REGISTER_OPTION(CACHE_DIR);- REGISTER_OPTION(CACHE_MODE);- REGISTER_OPTION(COMPILED_BLOB);- REGISTER_OPTION(DEVICE_ID);- REGISTER_OPTION(NUM_STREAMS);- REGISTER_OPTION(PERF_COUNT);- REGISTER_OPTION(LOADED_FROM_CACHE);- REGISTER_OPTION(COMPILATION_NUM_THREADS);- REGISTER_OPTION(PERFORMANCE_HINT);- REGISTER_OPTION(EXECUTION_MODE_HINT);- REGISTER_OPTION(PERFORMANCE_HINT_NUM_REQUESTS);- OPENVINO_SUPPRESS_DEPRECATED_START- REGISTER_OPTION(ENABLE_CPU_PINNING);- OPENVINO_SUPPRESS_DEPRECATED_END- REGISTER_OPTION(INFERENCE_PRECISION_HINT);- REGISTER_OPTION(MODEL_PRIORITY);- REGISTER_OPTION(COMPILATION_MODE_PARAMS);- REGISTER_OPTION(DMA_ENGINES);- REGISTER_OPTION(TILES);- REGISTER_OPTION(COMPILATION_MODE);- REGISTER_OPTION(COMPILER_TYPE);- REGISTER_OPTION(PLATFORM);- REGISTER_OPTION(CREATE_EXECUTOR);- REGISTER_OPTION(DYNAMIC_SHAPE_TO_STATIC);- REGISTER_OPTION(PROFILING_TYPE);- REGISTER_OPTION(BACKEND_COMPILATION_PARAMS);- REGISTER_OPTION(BATCH_MODE);- REGISTER_OPTION(BYPASS_UMD_CACHING);- REGISTER_OPTION(DEFER_WEIGHTS_LOAD);- REGISTER_OPTION(WEIGHTS_PATH);- REGISTER_OPTION(RUN_INFERENCES_SEQUENTIALLY);- REGISTER_OPTION(COMPILER_DYNAMIC_QUANTIZATION);- REGISTER_OPTION(QDQ_OPTIMIZATION);- REGISTER_OPTION(QDQ_OPTIMIZATION_AGGRESSIVE);- REGISTER_OPTION(STEPPING);- REGISTER_OPTION(DISABLE_VERSION_CHECK);- REGISTER_OPTION(EXPORT_RAW_BLOB);- REGISTER_OPTION(IMPORT_RAW_BLOB);- REGISTER_OPTION(BATCH_COMPILER_MODE_SETTINGS);- REGISTER_OPTION(TURBO);- REGISTER_OPTION(SEPARATE_WEIGHTS_VERSION);- REGISTER_OPTION(WS_COMPILE_CALL_NUMBER);- REGISTER_OPTION(MODEL_SERIALIZER_VERSION);- REGISTER_OPTION(ENABLE_STRIDES_FOR);- REGISTER_OPTION(SHARED_COMMON_QUEUE);-- if (backend) {- REGISTER_OPTION(MAX_TILES);-- if (backend->isCommandQueueExtSupported()) {- REGISTER_OPTION(WORKLOAD_TYPE);- }- if (backend->isContextExtSupported()) {- REGISTER_OPTION(DISABLE_IDLE_MEMORY_PRUNING);- }- }-- for_each_exposed_npuw_option([&](auto tag) {- using Opt = typename decltype(tag)::type;- REGISTER_OPTION(Opt);- });-- npu_config.enableRuntimeOptions();-- // Special cases - options with OptionMode::Both must be enabled for the plugin even if the compiler does not- // support them, because they may be used by the plugin itself or by the driver.- // We still check compiler support to decide whether these options should be removed from the config string.-- // NPU_TURBO might be supported by the driver- if (backend && backend->isCommandQueueExtSupported()) {- npu_config.enable(ov::intel_npu::turbo.name(), true);- }-- // LOG_LEVEL, PERFORMANCE_HINT and PERF_COUNT are needed by runtime options- npu_config.enable(ov::log::level.name(), true);- npu_config.enable(ov::hint::performance_mode.name(), true);- npu_config.enable(ov::enable_profiling.name(), true);-- if (npu_config.get<COMPILER_TYPE>() == ov::intel_npu::CompilerType::PREFER_PLUGIN && backend != nullptr) {- auto device = backend->getDevice();- if (device) {- auto platformName = device->getName();- CompilerAdapterFactory compilerFactory;- auto compileType = compilerFactory.determineAppropriateCompilerTypeBasedOnPlatform(platformName);- if (compileType == ov::intel_npu::CompilerType::DRIVER) {- npu_config.update({{ov::intel_npu::compiler_type.name(), COMPILER_TYPE::toString(compileType)}});- }- }- }-- propertiesManager =- std::make_unique<PluginPropertyManager>(npu_config, backend, ::intel_npu::Logger::global());- }-- void TearDown() override {- APIBaseTest::TearDown();- }-};--TEST_P(PropertiesManagerTests, ExpectRunTimeSpecialBothPropertyIsSupported) {- std::string logs;- std::mutex logs_mutex;- bool isSupported = false;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- propertiesManager->setProperty({{ov::log::level(ov::log::Level::INFO)}});- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});- isSupported = propertiesManager->isPropertySupported(configuration);- }-- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);- ASSERT_TRUE(isSupported);-}--using CompileLogLevelPropertyTests = PropertiesManagerTests;--TEST_P(CompileLogLevelPropertyTests, InheritsPluginLogLevelWhenUnset) {- propertiesManager->setProperty({{ov::log::level(ov::log::Level::DEBUG)}});-- ov::Any retrieved;- OV_ASSERT_NO_THROW(retrieved = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));- ASSERT_EQ(retrieved.as<ov::log::Level>(), ov::log::Level::DEBUG);-}--TEST_P(CompileLogLevelPropertyTests, IsIndependentFromLogLevel) {- propertiesManager->setProperty(- {{ov::log::level(ov::log::Level::DEBUG)}, {ov::intel_npu::compile_log_level(ov::log::Level::ERR)}});-- ov::Any compilerLevel;- OV_ASSERT_NO_THROW(compilerLevel = propertiesManager->getProperty(ov::intel_npu::compile_log_level.name()));- ASSERT_EQ(compilerLevel.as<ov::log::Level>(), ov::log::Level::ERR);-- ov::Any pluginLevel;- OV_ASSERT_NO_THROW(pluginLevel = propertiesManager->getProperty(ov::log::level.name()));- ASSERT_EQ(pluginLevel.as<ov::log::Level>(), ov::log::Level::DEBUG);-}--using CompatibilityCheckTests = PropertiesManagerTests;--TEST_P(CompatibilityCheckTests, ExpectArgumentIsNotSupported) {- std::string logs;- std::mutex logs_mutex;- bool isSupported = true;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- ov::AnyMap arguments = {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),- {"DUMMY_PROPERTY", "DUMMY_VALUE"}};-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);-- try {- propertiesManager->setProperty(arguments);- isSupported = true;- } catch (...) {- isSupported = false;- }- }-- ASSERT_FALSE(isSupported);- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-}--TEST_P(CompatibilityCheckTests, CompatibilityCheckUsesPluginCompilerAdapterOnlyWhenDriverVersionIsInsufficient) {- std::string logs;- std::mutex logs_mutex;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- // Determine at runtime whether the driver version is sufficient to handle the- // compatibility check without falling back to PluginCompilerAdapter.- const auto initStructs = backend ? backend->getInitStructs() : nullptr;- const bool driverHandlesCompatibilityCheck =- initStructs != nullptr && initStructs->getZeDrvApiVersion() >= ZE_MAKE_VERSION(1, 16);-- bool isSupported = false;- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- isSupported = propertiesManager->isPropertySupported(ov::compatibility_check.name());- }-- if (driverHandlesCompatibilityCheck) {- // Driver version >= 1.16: Property must be reported as supported.- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter complete"), std::string::npos);- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_TRUE(isSupported);- } else {- if (logs.find("initialize PluginCompilerAdapter complete") == std::string::npos) {- // Driver version < 1.16: Because CiP can not be loaded on this path in CI, the property must be reported as- // unsupported.- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_FALSE(isSupported);- } else {- // Driver version < 1.16: Because CiP can be loaded on this path in CI, the property must be reported as- // supported.- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_TRUE(isSupported);- }- }-}--TEST_P(CompatibilityCheckTests, ExpectTurboPropertyAndCompatibilityCheckAreSupported) {- std::string logs;- std::mutex logs_mutex;- bool turboSupported = false;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- const bool turboSupportedByDevice = backend && backend->isCommandQueueExtSupported();-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});- turboSupported = propertiesManager->isPropertySupported(ov::intel_npu::turbo.name());- }-- if (turboSupportedByDevice) {- // Turbo is supported by device, so checking support must not trigger compiler adapters.- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_TRUE(turboSupported);- } else {- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_FALSE(turboSupported);- }-}--using ExpectLoadingCompilerPropertySupported = PropertiesManagerTests;--TEST_P(ExpectLoadingCompilerPropertySupported, ExpectCompilerPropertyIsSupported) {- std::string logs;- std::mutex logs_mutex;- bool isSupported = false;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});- isSupported = propertiesManager->isPropertySupported(configuration);- }-- ASSERT_TRUE(isSupported);- ASSERT_NE(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-}--using ExpectLoadingCompilerPropertyNotSupported = PropertiesManagerTests;--TEST_P(ExpectLoadingCompilerPropertyNotSupported, ExpectCompilerPropertyIsNotSupported) {- std::string logs;- std::mutex logs_mutex;- bool isSupported = true;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::INFO);- propertiesManager->setProperty({{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER)}});- isSupported = propertiesManager->isPropertySupported(configuration);- }-- ASSERT_FALSE(isSupported);- ASSERT_EQ(logs.find("initialize DriverCompilerAdapter start"), std::string::npos);- ASSERT_EQ(logs.find("initialize PluginCompilerAdapter start"), std::string::npos);-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cppindex 643e7c29766..d8bf8bee25c 100644--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.cpp@@ -2,9 +2,498 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/utils/zero/zero_cmd_queue_pool_tests.hpp"+#include <algorithm>+#include <array>+#include <atomic>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <level_zero/ze_api.h>+#include <memory>+#include <mutex>+#include <random>+#include <sstream>+#include <thread>+#include <vector>+#include <ze_command_queue_npu_ext.h>+#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "intel_npu/utils/zero/zero_cmd_queue_pool.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_wrappers.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class ZeroCmdQueuePoolTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<std::string> {+protected:+ ov::AnyMap configuration;+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;++public:+ static std::string getTestCaseName(const testing::TestParamInfo<std::string>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ target_device = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '_');++ std::ostringstream result;+ result << "targetDevice=" << target_device << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ target_device = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();+ }++ void TearDown() override {+ init_struct = nullptr;+ APIBaseTest::TearDown();+ }+};++TEST_P(ZeroCmdQueuePoolTests, SetWorkloadType) {+ ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_BACKGROUND,+ 0,+ nullptr,+ true};++ if (init_struct->getCommandQueueDdiTable().version() > 0) {+ OV_ASSERT_NO_THROW(+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc));+ } else {+ OV_EXPECT_THROW_HAS_SUBSTRING(+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc),+ ov::Exception,+ "The WorkloadType property is not supported by the current Driver Version!");+ }+}++TEST_P(ZeroCmdQueuePoolTests, SetWorkloadTypeOnExistingQueue) {+ if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {+ GTEST_SKIP() << "The WorkloadType property is not supported by the current driver.\n";+ }++ int owner = 1;+ ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ 0,+ &owner,+ false};++ auto cmd_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);+ ASSERT_NE(cmd_queue, nullptr);++ OV_ASSERT_NO_THROW(cmd_queue->setWorkloadType(ZE_WORKLOAD_TYPE_BACKGROUND));+ OV_ASSERT_NO_THROW(cmd_queue->setWorkloadType(ZE_WORKLOAD_TYPE_DEFAULT));+}++TEST_P(ZeroCmdQueuePoolTests, SharedCommonQueueDisabledRequiresOwnerTag) {+ OV_EXPECT_THROW_HAS_SUBSTRING((::intel_npu::CommandQueueDesc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ std::nullopt,+ 0,+ nullptr,+ false}),+ ov::Exception,+ "owner_tag must not be null");+}++TEST_P(ZeroCmdQueuePoolTests, PoolReusabilityTest) {+ // Test that the pool correctly reuses queues after weak_ptr cleanup+ ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, 0, nullptr, true};++ // First allocation+ std::shared_ptr<::intel_npu::CommandQueue> queue1 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);+ EXPECT_NE(queue1, nullptr);++ // Second allocation with same descriptor should return the same instance (while ref is held)+ std::shared_ptr<::intel_npu::CommandQueue> queue2 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);+ EXPECT_EQ(queue1.get(), queue2.get()) << "Same descriptor should return pooled queue while alive";++ // Release first reference+ queue1.reset();++ std::shared_ptr<::intel_npu::CommandQueue> queue3 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);+ EXPECT_NE(queue3, nullptr) << "Should always be able to allocate a queue";+ EXPECT_EQ(queue2.get(), queue3.get()) << "Same descriptor should return pooled queue while alive";++ queue2.reset();+ queue3.reset();+}++TEST_P(ZeroCmdQueuePoolTests, PoolReusabilityDisabledTest) {+ // Test that the pool correctly reuses queues after weak_ptr cleanup+ int pointer1 = 1; // Just a dummy pointer value for testing+ ::intel_npu::CommandQueueDesc command_queue_desc1{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ std::nullopt,+ 0,+ &pointer1,+ false};++ // First allocation+ std::shared_ptr<::intel_npu::CommandQueue> queue1 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc1);+ EXPECT_NE(queue1, nullptr);++ int pointer2 = 2; // Just a dummy pointer value for testing+ ::intel_npu::CommandQueueDesc command_queue_desc2{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ std::nullopt,+ 0,+ &pointer2,+ false};++ // Second allocation with same descriptor should return the same instance (while ref is held)+ std::shared_ptr<::intel_npu::CommandQueue> queue2 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc2);+ EXPECT_NE(queue2, nullptr) << "Should always be able to allocate a queue";+ EXPECT_NE(queue1.get(), queue2.get()) << "Same descriptor with different owner_tag should not return the same "+ "pooled queue when shared_common_queue is false";++ int pointer3 = 3; // Just a dummy pointer value for testing+ ::intel_npu::CommandQueueDesc command_queue_desc3{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ std::nullopt,+ 0,+ &pointer3,+ false};++ std::shared_ptr<::intel_npu::CommandQueue> queue3 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc3);+ EXPECT_NE(queue3, nullptr) << "Should always be able to allocate a queue";+ EXPECT_NE(queue1.get(), queue3.get()) << "Same descriptor with different owner_tag should not return the same "+ "pooled queue when shared_common_queue is false";+ EXPECT_NE(queue2.get(), queue3.get()) << "Same descriptor with different owner_tag should not return the same "+ "pooled queue when shared_common_queue is false";++ queue1.reset();+ queue2.reset();+ queue3.reset();+}++TEST_P(ZeroCmdQueuePoolTests, SharedCommonQueueDisabledUsesNewQueueWhenDescriptorChanges) {+ int owner = 1;++ ::intel_npu::CommandQueueDesc base_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, 0, &owner, false};+ auto base_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, base_desc);+ auto same_base_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, base_desc);++ ASSERT_NE(base_queue, nullptr);+ ASSERT_EQ(base_queue.get(), same_base_queue.get()) << "Same descriptor and owner_tag should reuse the same queue";++ ::intel_npu::CommandQueueDesc priority_desc{+ ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH,+ std::nullopt,+ 0,+ &owner,+ false,+ };+ auto priority_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, priority_desc);++ ASSERT_NE(priority_queue, nullptr);+ EXPECT_NE(base_queue.get(), priority_queue.get())+ << "Changing model priority should create a different queue for shared_common_queue=false";++ if (init_struct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {+ ::intel_npu::CommandQueueDesc workload_desc{+ ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_BACKGROUND,+ 0,+ &owner,+ false,+ };+ auto workload_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, workload_desc);++ ASSERT_NE(workload_queue, nullptr);+ EXPECT_NE(base_queue.get(), workload_queue.get())+ << "Changing workload type should create a different queue for shared_common_queue=false";+ }++ if (init_struct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {+ ::intel_npu::CommandQueueDesc option_desc{+ ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ std::nullopt,+ ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,+ &owner,+ false,+ };+ auto option_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, option_desc);++ ASSERT_NE(option_queue, nullptr);+ EXPECT_NE(base_queue.get(), option_queue.get())+ << "Changing command queue options should create a different queue for shared_common_queue=false";+ }+}++TEST_P(ZeroCmdQueuePoolTests, AllCommandQueueOptionsCombinations) {+ if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {+ GTEST_SKIP() << "Not all the command queue options are supported by the current driver.\n";+ }++ // Exhaustively test all combinations of command queue creation options+ std::vector<ze_command_queue_priority_t> priorities{ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW,+ ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH};++ std::vector<_ze_command_queue_workload_type_t> workload_types{ZE_WORKLOAD_TYPE_DEFAULT,+ ZE_WORKLOAD_TYPE_BACKGROUND};++ std::vector<uint32_t> option_combinations{+ 0,+ ZE_NPU_COMMAND_QUEUE_OPTION_TURBO,+ ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,+ ZE_NPU_COMMAND_QUEUE_OPTION_TURBO | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC};++ int successful_allocations = 0;++ for (auto priority : priorities) {+ for (auto workload_type : workload_types) {+ for (auto options : option_combinations) {+ static int owner = 1; // Just a dummy pointer value for testing+ ::intel_npu::CommandQueueDesc cmd_desc{priority, workload_type, options, &owner, true};++ auto cmd_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, cmd_desc);++ EXPECT_NE(cmd_queue, nullptr) << "Failed to allocate command queue for priority=" << (int)priority+ << " workload_type=" << (int)workload_type << " options=" << options;+ successful_allocations++;++ // Verify we get the same instance for the same descriptor+ auto cmd_queue2 = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, cmd_desc);+ EXPECT_EQ(cmd_queue.get(), cmd_queue2.get()) << "Same descriptor should return the same pooled queue";+ }+ }+ }++ const int all_combinations =+ static_cast<int>(priorities.size() * workload_types.size() * option_combinations.size());+ EXPECT_EQ(all_combinations, 24) << "Expected 3 priorities * 2 workload types * 4 option combinations";+ EXPECT_EQ(successful_allocations, all_combinations)+ << "The test must cover and create all command queue combinations exactly once";+}++TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOption) {+ if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {+ GTEST_SKIP()+ << "ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC command queue option is not supported by the current driver.\n";+ }++ int owner_a = 1;+ int owner_b = 2;++ // With DEVICE_SYNC enabled, owner_tag participates in the pool key.+ ::intel_npu::CommandQueueDesc device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,+ &owner_a,+ true};+ auto queue_device_sync_a_1 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_a);+ auto queue_device_sync_a_2 =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_a);++ EXPECT_NE(queue_device_sync_a_1, nullptr);+ EXPECT_EQ(queue_device_sync_a_1.get(), queue_device_sync_a_2.get())+ << "Same DEVICE_SYNC owner_tag should reuse the same pooled queue";++ ::intel_npu::CommandQueueDesc device_sync_desc_b{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,+ &owner_b,+ true};+ auto queue_device_sync_b =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_b);++ EXPECT_NE(queue_device_sync_b, nullptr);+ EXPECT_NE(queue_device_sync_a_1.get(), queue_device_sync_b.get())+ << "Different DEVICE_SYNC owner_tag pointers should create different pooled queues";++ // Without DEVICE_SYNC, owner_tag must not affect pooling.+ ::intel_npu::CommandQueueDesc no_device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ 0,+ &owner_a,+ true};+ ::intel_npu::CommandQueueDesc no_device_sync_desc_b{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,+ ZE_WORKLOAD_TYPE_DEFAULT,+ 0,+ &owner_b,+ true};+ auto queue_no_device_sync_a =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, no_device_sync_desc_a);+ auto queue_no_device_sync_b =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, no_device_sync_desc_b);++ EXPECT_NE(queue_no_device_sync_a, nullptr);+ EXPECT_EQ(queue_no_device_sync_a.get(), queue_no_device_sync_b.get())+ << "owner_tag should be ignored when DEVICE_SYNC option is not set";+}++TEST_P(ZeroCmdQueuePoolTests, MultiThreadingTest) {+ if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {+ GTEST_SKIP() << "Workload type and turbo options are not supported by the current driver.\n";+ }++ // Systematically cover all combinations of priorities, workload types, and turbo+ // Priorities: LOW (0), HIGH (1), NORMAL (2) = 3 options+ // Workload types: BACKGROUND (0), DEFAULT (1) = 2 options (when version > 0)+ // Turbo options: without TURBO (0), with TURBO (1) = 2 options (when version > 0)+ // Total combinations: 3 * 2 * 2 = 12 (with version > 0) or 3 (with version <= 0)++ constexpr int threads_no = 256;+ std::array<std::thread, threads_no> threads;+ std::vector<std::shared_ptr<::intel_npu::CommandQueue>> queue_refs(threads_no);+ std::mutex results_mutex;+ int successful_allocations = 0;++ for (int i = 0; i < threads_no; ++i) {+ threads[i] = std::thread([&, i]() -> void {+ // Cycle through all priority options+ ze_command_queue_priority_t priority;+ int priority_idx = i % 3;+ if (priority_idx == 0) {+ priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;+ } else if (priority_idx == 1) {+ priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH;+ } else {+ priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;+ }++ _ze_command_queue_workload_type_t workload_type = ZE_WORKLOAD_TYPE_DEFAULT;+ uint32_t commandQueueOptions = 0;++ // Cycle through workload types (2 options)+ int workload_idx = (i / 3) % 2;+ workload_type = (workload_idx == 0) ? ZE_WORKLOAD_TYPE_BACKGROUND : ZE_WORKLOAD_TYPE_DEFAULT;++ // Cycle through command queue options (2 options: with/without TURBO)+ int options_idx = (i / 6) % 2;+ if (options_idx == 0) {+ commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;+ }+ // else: no options (commandQueueOptions = 0)++ ::intel_npu::CommandQueueDesc command_queue_desc{priority,+ workload_type,+ commandQueueOptions,+ nullptr,+ true};+ auto cmd_queue =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);++ {+ std::lock_guard<std::mutex> lock(results_mutex);+ queue_refs[i] = cmd_queue;+ successful_allocations++;+ }+ });+ }++ for (int i = 0; i < threads_no; ++i) {+ threads[i].join();+ }++ // Verify that all threads successfully obtained command queues+ EXPECT_GT(successful_allocations, 0) << "At least some command queues should be allocated";++ // Verify that we attempted allocations with different parameters+ int unique_combinations_requested = 12;+ int threads_per_combination = threads_no / unique_combinations_requested;+ EXPECT_GE(successful_allocations, threads_per_combination)+ << "Should have successfully allocated at least one thread per combination type";++ // Keep refs alive for the duration and then let them be cleaned up+ queue_refs.clear();+}++TEST_P(ZeroCmdQueuePoolTests, MultiThreadingTestWithDestroyCmdQueue) {+ if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {+ GTEST_SKIP() << "Workload type and turbo options are not supported by the current driver.\n";+ }++ constexpr int threads_no = 128;+ constexpr int iterations_per_thread = 16;+ std::array<std::thread, threads_no> threads;+ std::atomic<int> successful_cycles{0};++ for (int i = 0; i < threads_no; ++i) {+ threads[i] = std::thread([&, i]() -> void {+ for (int iteration = 0; iteration < iterations_per_thread; ++iteration) {+ // Cycle through all priority options+ ze_command_queue_priority_t priority;+ const int priority_idx = (i + iteration) % 3;+ if (priority_idx == 0) {+ priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;+ } else if (priority_idx == 1) {+ priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH;+ } else {+ priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;+ }++ _ze_command_queue_workload_type_t workload_type = ZE_WORKLOAD_TYPE_DEFAULT;+ uint32_t commandQueueOptions = 0;++ // Cycle through workload types (2 options)+ const int workload_idx = ((i + iteration) / 3) % 2;+ workload_type = (workload_idx == 0) ? ZE_WORKLOAD_TYPE_BACKGROUND : ZE_WORKLOAD_TYPE_DEFAULT;++ // Cycle through command queue options (2 options: with/without TURBO)+ const int options_idx = ((i + iteration) / 6) % 2;+ if (options_idx == 0) {+ commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;+ }+ // else: no options (commandQueueOptions = 0)++ ::intel_npu::CommandQueueDesc command_queue_desc{priority,+ workload_type,+ commandQueueOptions,+ nullptr,+ true};+ auto cmd_queue =+ ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);+ ASSERT_NE(cmd_queue, nullptr);++ // Explicitly release right after creation to stress the pool deleter path.+ cmd_queue.reset();+ ++successful_cycles;+ }+ });+ }++ for (int i = 0; i < threads_no; ++i) {+ threads[i].join();+ }++ EXPECT_EQ(successful_cycles.load(), threads_no * iterations_per_thread)+ << "All create/destroy cycles must complete";+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.hppdeleted file mode 100644index 8ed99daf1bc..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_cmd_queue_pool_tests.hpp+++ /dev/null@@ -1,498 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>-#include <level_zero/ze_api.h>-#include <ze_command_queue_npu_ext.h>--#include <algorithm>-#include <array>-#include <atomic>-#include <cstddef>-#include <exception>-#include <memory>-#include <mutex>-#include <random>-#include <sstream>-#include <thread>-#include <vector>--#include "common/npu_test_env_cfg.hpp"-#include "intel_npu/utils/zero/zero_cmd_queue_pool.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_wrappers.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class ZeroCmdQueuePoolTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<std::string> {-protected:- ov::AnyMap configuration;- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;--public:- static std::string getTestCaseName(const testing::TestParamInfo<std::string>& obj) {- std::string target_device;- ov::AnyMap configuration;- target_device = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '_');-- std::ostringstream result;- result << "targetDevice=" << target_device << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- target_device = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();-- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();- }-- void TearDown() override {- init_struct = nullptr;- APIBaseTest::TearDown();- }-};--TEST_P(ZeroCmdQueuePoolTests, SetWorkloadType) {- ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_BACKGROUND,- 0,- nullptr,- true};-- if (init_struct->getCommandQueueDdiTable().version() > 0) {- OV_ASSERT_NO_THROW(- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc));- } else {- OV_EXPECT_THROW_HAS_SUBSTRING(- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc),- ov::Exception,- "The WorkloadType property is not supported by the current Driver Version!");- }-}--TEST_P(ZeroCmdQueuePoolTests, SetWorkloadTypeOnExistingQueue) {- if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {- GTEST_SKIP() << "The WorkloadType property is not supported by the current driver.\n";- }-- int owner = 1;- ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_DEFAULT,- 0,- &owner,- false};-- auto cmd_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);- ASSERT_NE(cmd_queue, nullptr);-- OV_ASSERT_NO_THROW(cmd_queue->setWorkloadType(ZE_WORKLOAD_TYPE_BACKGROUND));- OV_ASSERT_NO_THROW(cmd_queue->setWorkloadType(ZE_WORKLOAD_TYPE_DEFAULT));-}--TEST_P(ZeroCmdQueuePoolTests, SharedCommonQueueDisabledRequiresOwnerTag) {- OV_EXPECT_THROW_HAS_SUBSTRING((::intel_npu::CommandQueueDesc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- std::nullopt,- 0,- nullptr,- false}),- ov::Exception,- "owner_tag must not be null");-}--TEST_P(ZeroCmdQueuePoolTests, PoolReusabilityTest) {- // Test that the pool correctly reuses queues after weak_ptr cleanup- ::intel_npu::CommandQueueDesc command_queue_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, 0, nullptr, true};-- // First allocation- std::shared_ptr<::intel_npu::CommandQueue> queue1 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);- EXPECT_NE(queue1, nullptr);-- // Second allocation with same descriptor should return the same instance (while ref is held)- std::shared_ptr<::intel_npu::CommandQueue> queue2 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);- EXPECT_EQ(queue1.get(), queue2.get()) << "Same descriptor should return pooled queue while alive";-- // Release first reference- queue1.reset();-- std::shared_ptr<::intel_npu::CommandQueue> queue3 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);- EXPECT_NE(queue3, nullptr) << "Should always be able to allocate a queue";- EXPECT_EQ(queue2.get(), queue3.get()) << "Same descriptor should return pooled queue while alive";-- queue2.reset();- queue3.reset();-}--TEST_P(ZeroCmdQueuePoolTests, PoolReusabilityDisabledTest) {- // Test that the pool correctly reuses queues after weak_ptr cleanup- int pointer1 = 1; // Just a dummy pointer value for testing- ::intel_npu::CommandQueueDesc command_queue_desc1{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- std::nullopt,- 0,- &pointer1,- false};-- // First allocation- std::shared_ptr<::intel_npu::CommandQueue> queue1 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc1);- EXPECT_NE(queue1, nullptr);-- int pointer2 = 2; // Just a dummy pointer value for testing- ::intel_npu::CommandQueueDesc command_queue_desc2{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- std::nullopt,- 0,- &pointer2,- false};-- // Second allocation with same descriptor should return the same instance (while ref is held)- std::shared_ptr<::intel_npu::CommandQueue> queue2 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc2);- EXPECT_NE(queue2, nullptr) << "Should always be able to allocate a queue";- EXPECT_NE(queue1.get(), queue2.get()) << "Same descriptor with different owner_tag should not return the same "- "pooled queue when shared_common_queue is false";-- int pointer3 = 3; // Just a dummy pointer value for testing- ::intel_npu::CommandQueueDesc command_queue_desc3{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- std::nullopt,- 0,- &pointer3,- false};-- std::shared_ptr<::intel_npu::CommandQueue> queue3 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc3);- EXPECT_NE(queue3, nullptr) << "Should always be able to allocate a queue";- EXPECT_NE(queue1.get(), queue3.get()) << "Same descriptor with different owner_tag should not return the same "- "pooled queue when shared_common_queue is false";- EXPECT_NE(queue2.get(), queue3.get()) << "Same descriptor with different owner_tag should not return the same "- "pooled queue when shared_common_queue is false";-- queue1.reset();- queue2.reset();- queue3.reset();-}--TEST_P(ZeroCmdQueuePoolTests, SharedCommonQueueDisabledUsesNewQueueWhenDescriptorChanges) {- int owner = 1;-- ::intel_npu::CommandQueueDesc base_desc{ZE_COMMAND_QUEUE_PRIORITY_NORMAL, std::nullopt, 0, &owner, false};- auto base_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, base_desc);- auto same_base_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, base_desc);-- ASSERT_NE(base_queue, nullptr);- ASSERT_EQ(base_queue.get(), same_base_queue.get()) << "Same descriptor and owner_tag should reuse the same queue";-- ::intel_npu::CommandQueueDesc priority_desc{- ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH,- std::nullopt,- 0,- &owner,- false,- };- auto priority_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, priority_desc);-- ASSERT_NE(priority_queue, nullptr);- EXPECT_NE(base_queue.get(), priority_queue.get())- << "Changing model priority should create a different queue for shared_common_queue=false";-- if (init_struct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 0)) {- ::intel_npu::CommandQueueDesc workload_desc{- ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_BACKGROUND,- 0,- &owner,- false,- };- auto workload_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, workload_desc);-- ASSERT_NE(workload_queue, nullptr);- EXPECT_NE(base_queue.get(), workload_queue.get())- << "Changing workload type should create a different queue for shared_common_queue=false";- }-- if (init_struct->getCommandQueueDdiTable().version() >= ZE_MAKE_VERSION(1, 1)) {- ::intel_npu::CommandQueueDesc option_desc{- ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- std::nullopt,- ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,- &owner,- false,- };- auto option_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, option_desc);-- ASSERT_NE(option_queue, nullptr);- EXPECT_NE(base_queue.get(), option_queue.get())- << "Changing command queue options should create a different queue for shared_common_queue=false";- }-}--TEST_P(ZeroCmdQueuePoolTests, AllCommandQueueOptionsCombinations) {- if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {- GTEST_SKIP() << "Not all the command queue options are supported by the current driver.\n";- }-- // Exhaustively test all combinations of command queue creation options- std::vector<ze_command_queue_priority_t> priorities{ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW,- ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH};-- std::vector<_ze_command_queue_workload_type_t> workload_types{ZE_WORKLOAD_TYPE_DEFAULT,- ZE_WORKLOAD_TYPE_BACKGROUND};-- std::vector<uint32_t> option_combinations{- 0,- ZE_NPU_COMMAND_QUEUE_OPTION_TURBO,- ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,- ZE_NPU_COMMAND_QUEUE_OPTION_TURBO | ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC};-- int successful_allocations = 0;-- for (auto priority : priorities) {- for (auto workload_type : workload_types) {- for (auto options : option_combinations) {- static int owner = 1; // Just a dummy pointer value for testing- ::intel_npu::CommandQueueDesc cmd_desc{priority, workload_type, options, &owner, true};-- auto cmd_queue = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, cmd_desc);-- EXPECT_NE(cmd_queue, nullptr) << "Failed to allocate command queue for priority=" << (int)priority- << " workload_type=" << (int)workload_type << " options=" << options;- successful_allocations++;-- // Verify we get the same instance for the same descriptor- auto cmd_queue2 = ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, cmd_desc);- EXPECT_EQ(cmd_queue.get(), cmd_queue2.get()) << "Same descriptor should return the same pooled queue";- }- }- }-- const int all_combinations =- static_cast<int>(priorities.size() * workload_types.size() * option_combinations.size());- EXPECT_EQ(all_combinations, 24) << "Expected 3 priorities * 2 workload types * 4 option combinations";- EXPECT_EQ(successful_allocations, all_combinations)- << "The test must cover and create all command queue combinations exactly once";-}--TEST_P(ZeroCmdQueuePoolTests, CreateDifferentCommandQueueForEachDeviceSyncOption) {- if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 1)) {- GTEST_SKIP()- << "ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC command queue option is not supported by the current driver.\n";- }-- int owner_a = 1;- int owner_b = 2;-- // With DEVICE_SYNC enabled, owner_tag participates in the pool key.- ::intel_npu::CommandQueueDesc device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_DEFAULT,- ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,- &owner_a,- true};- auto queue_device_sync_a_1 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_a);- auto queue_device_sync_a_2 =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_a);-- EXPECT_NE(queue_device_sync_a_1, nullptr);- EXPECT_EQ(queue_device_sync_a_1.get(), queue_device_sync_a_2.get())- << "Same DEVICE_SYNC owner_tag should reuse the same pooled queue";-- ::intel_npu::CommandQueueDesc device_sync_desc_b{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_DEFAULT,- ZE_NPU_COMMAND_QUEUE_OPTION_DEVICE_SYNC,- &owner_b,- true};- auto queue_device_sync_b =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, device_sync_desc_b);-- EXPECT_NE(queue_device_sync_b, nullptr);- EXPECT_NE(queue_device_sync_a_1.get(), queue_device_sync_b.get())- << "Different DEVICE_SYNC owner_tag pointers should create different pooled queues";-- // Without DEVICE_SYNC, owner_tag must not affect pooling.- ::intel_npu::CommandQueueDesc no_device_sync_desc_a{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_DEFAULT,- 0,- &owner_a,- true};- ::intel_npu::CommandQueueDesc no_device_sync_desc_b{ZE_COMMAND_QUEUE_PRIORITY_NORMAL,- ZE_WORKLOAD_TYPE_DEFAULT,- 0,- &owner_b,- true};- auto queue_no_device_sync_a =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, no_device_sync_desc_a);- auto queue_no_device_sync_b =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, no_device_sync_desc_b);-- EXPECT_NE(queue_no_device_sync_a, nullptr);- EXPECT_EQ(queue_no_device_sync_a.get(), queue_no_device_sync_b.get())- << "owner_tag should be ignored when DEVICE_SYNC option is not set";-}--TEST_P(ZeroCmdQueuePoolTests, MultiThreadingTest) {- if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {- GTEST_SKIP() << "Workload type and turbo options are not supported by the current driver.\n";- }-- // Systematically cover all combinations of priorities, workload types, and turbo- // Priorities: LOW (0), HIGH (1), NORMAL (2) = 3 options- // Workload types: BACKGROUND (0), DEFAULT (1) = 2 options (when version > 0)- // Turbo options: without TURBO (0), with TURBO (1) = 2 options (when version > 0)- // Total combinations: 3 * 2 * 2 = 12 (with version > 0) or 3 (with version <= 0)-- constexpr int threads_no = 256;- std::array<std::thread, threads_no> threads;- std::vector<std::shared_ptr<::intel_npu::CommandQueue>> queue_refs(threads_no);- std::mutex results_mutex;- int successful_allocations = 0;-- for (int i = 0; i < threads_no; ++i) {- threads[i] = std::thread([&, i]() -> void {- // Cycle through all priority options- ze_command_queue_priority_t priority;- int priority_idx = i % 3;- if (priority_idx == 0) {- priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;- } else if (priority_idx == 1) {- priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH;- } else {- priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;- }-- _ze_command_queue_workload_type_t workload_type = ZE_WORKLOAD_TYPE_DEFAULT;- uint32_t commandQueueOptions = 0;-- // Cycle through workload types (2 options)- int workload_idx = (i / 3) % 2;- workload_type = (workload_idx == 0) ? ZE_WORKLOAD_TYPE_BACKGROUND : ZE_WORKLOAD_TYPE_DEFAULT;-- // Cycle through command queue options (2 options: with/without TURBO)- int options_idx = (i / 6) % 2;- if (options_idx == 0) {- commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;- }- // else: no options (commandQueueOptions = 0)-- ::intel_npu::CommandQueueDesc command_queue_desc{priority,- workload_type,- commandQueueOptions,- nullptr,- true};- auto cmd_queue =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);-- {- std::lock_guard<std::mutex> lock(results_mutex);- queue_refs[i] = cmd_queue;- successful_allocations++;- }- });- }-- for (int i = 0; i < threads_no; ++i) {- threads[i].join();- }-- // Verify that all threads successfully obtained command queues- EXPECT_GT(successful_allocations, 0) << "At least some command queues should be allocated";-- // Verify that we attempted allocations with different parameters- int unique_combinations_requested = 12;- int threads_per_combination = threads_no / unique_combinations_requested;- EXPECT_GE(successful_allocations, threads_per_combination)- << "Should have successfully allocated at least one thread per combination type";-- // Keep refs alive for the duration and then let them be cleaned up- queue_refs.clear();-}--TEST_P(ZeroCmdQueuePoolTests, MultiThreadingTestWithDestroyCmdQueue) {- if (init_struct->getCommandQueueDdiTable().version() < ZE_MAKE_VERSION(1, 0)) {- GTEST_SKIP() << "Workload type and turbo options are not supported by the current driver.\n";- }-- constexpr int threads_no = 128;- constexpr int iterations_per_thread = 16;- std::array<std::thread, threads_no> threads;- std::atomic<int> successful_cycles{0};-- for (int i = 0; i < threads_no; ++i) {- threads[i] = std::thread([&, i]() -> void {- for (int iteration = 0; iteration < iterations_per_thread; ++iteration) {- // Cycle through all priority options- ze_command_queue_priority_t priority;- const int priority_idx = (i + iteration) % 3;- if (priority_idx == 0) {- priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW;- } else if (priority_idx == 1) {- priority = ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH;- } else {- priority = ZE_COMMAND_QUEUE_PRIORITY_NORMAL;- }-- _ze_command_queue_workload_type_t workload_type = ZE_WORKLOAD_TYPE_DEFAULT;- uint32_t commandQueueOptions = 0;-- // Cycle through workload types (2 options)- const int workload_idx = ((i + iteration) / 3) % 2;- workload_type = (workload_idx == 0) ? ZE_WORKLOAD_TYPE_BACKGROUND : ZE_WORKLOAD_TYPE_DEFAULT;-- // Cycle through command queue options (2 options: with/without TURBO)- const int options_idx = ((i + iteration) / 6) % 2;- if (options_idx == 0) {- commandQueueOptions = commandQueueOptions | ZE_NPU_COMMAND_QUEUE_OPTION_TURBO;- }- // else: no options (commandQueueOptions = 0)-- ::intel_npu::CommandQueueDesc command_queue_desc{priority,- workload_type,- commandQueueOptions,- nullptr,- true};- auto cmd_queue =- ::intel_npu::ZeroCmdQueuePool::getInstance().getCommandQueue(init_struct, command_queue_desc);- ASSERT_NE(cmd_queue, nullptr);-- // Explicitly release right after creation to stress the pool deleter path.- cmd_queue.reset();- ++successful_cycles;- }- });- }-- for (int i = 0; i < threads_no; ++i) {- threads[i].join();- }-- EXPECT_EQ(successful_cycles.load(), threads_no * iterations_per_thread)- << "All create/destroy cycles must complete";-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.cppindex 26a1ce80290..9a4ffca1368 100644--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.cpp@@ -2,12 +2,440 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/utils/zero/zero_mem_pool_tests.hpp"+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <random>+#include <thread>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common/zero_init_mock.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"+#include "intel_npu/common/npu.hpp"+#include "intel_npu/config/config.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_mem.hpp"+#include "intel_npu/utils/zero/zero_mem_pool.hpp"+#include "intel_npu/utils/zero/zero_utils.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/log.hpp"+#include "openvino/runtime/core.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++#ifdef _WIN32+# include <windows.h>+# define SLEEP_MS(x) Sleep(x)+#else+# include <unistd.h>+# define SLEEP_MS(x) usleep((x) * 1000)+#endif++using CompilationParams = std::string;++using ::testing::AllOf;+using ::testing::HasSubstr;++namespace ov {+namespace test {+namespace behavior {+class ZeroMemPoolTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+protected:+ std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();+ ov::AnyMap configuration;+ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;+ std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();+ ::intel_npu::Config npu_config = ::intel_npu::Config(options);++public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ target_device = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '_');+ target_device = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << target_device << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ target_device = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();++ init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();+ }++ void TearDown() override {+ if (!configuration.empty()) {+ utils::PluginCache::get().reset();+ }++ init_struct = nullptr;+ APIBaseTest::TearDown();+ }+};++TEST_P(ZeroMemPoolTests, GetZeroMemoryData) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ void* data = ::operator new(4096, std::align_val_t(4096));++ std::shared_ptr<::intel_npu::ZeroMem> get_zero_mem;++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ OV_ASSERT_NO_THROW(get_zero_mem =+ ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data, 4096));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));+ } else {+ ASSERT_THROW(get_zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data, 4096),+ ::intel_npu::ZeroMemException);+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));+ }++ get_zero_mem = {};+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));++ ::operator delete(data, std::align_val_t(4096));+}++TEST_P(ZeroMemPoolTests, MultiThreadingReUseAlreadyAllocatedImportedMemory) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ const int threads_no = 256;+ std::array<std::thread, threads_no> threads;+ std::array<std::shared_ptr<::intel_npu::ZeroMem>, 5> zero_mem;+ std::array<void*, 3> data;++ // Prep: add few entries in the pool+ for (int i = 0; i < 3; i++) {+ data[i] = ::operator new(4096, std::align_val_t(4096));+ zero_mem[i] = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data[i], 4096);+ }+ zero_mem[3] = ::intel_npu::zero_mem::allocate_memory(init_struct, 4096, 4096);+ zero_mem[4] = ::intel_npu::zero_mem::allocate_memory(init_struct, 4096, 4096);++ for (int i = 0; i < threads_no; ++i) {+ threads[i] = std::thread([this, &zero_mem, i]() -> void {+ for (int j = 0; j < 256; j++) {+ std::shared_ptr<::intel_npu::ZeroMem> get_zero_mem;+ OV_ASSERT_NO_THROW(+ get_zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct,+ zero_mem[i % 5]->data(),+ 4096));+ SLEEP_MS(0);+ }+ });+ }++ for (int i = 0; i < threads_no; ++i) {+ threads[i].join();+ }++ for (int i = 0; i < 3; i++) {+ zero_mem[i] = {};+ ::operator delete(data[i], std::align_val_t(4096));+ }+ }+}++TEST_P(ZeroMemPoolTests, MultiThreadingImportMemoryReUseAndDestroyIt) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (init_struct->isExternalMemoryStandardAllocationSupported()) {+ constexpr int threads_no = 256;+ constexpr int no_of_buffers = 5;+ std::array<std::thread, threads_no> threads;+ std::array<void*, no_of_buffers> data;++ for (int i = 0; i < no_of_buffers; i++) {+ data[i] = ::operator new(4096, std::align_val_t(4096));+ }++ for (int i = 0; i < threads_no; ++i) {+ threads[i] = std::thread([&]() -> void {+ std::shared_ptr<::intel_npu::ZeroMem> zero_mem;+ for (int j = 0; j < threads_no; j++) {+ OV_ASSERT_NO_THROW(+ zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct,+ data[j % no_of_buffers],+ 4096));+ SLEEP_MS(0);+ if (j % 2 == 0) {+ zero_mem = {};+ }+ }++ zero_mem = {};+ });+ }++ for (int i = 0; i < threads_no; ++i) {+ threads[i].join();+ }++ for (int i = 0; i < no_of_buffers; i++) {+ ::operator delete(data[i], std::align_val_t(4096));+ }+ }+}++TEST_P(ZeroMemPoolTests, GetPoolReturnsSamePoolForSameInitStruct) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);+ auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ auto mem0 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096);+ auto mem1 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096);+ ASSERT_EQ(zero_init_mock->getZeroMemPool().mem_pool.size(), 2u);++ mem0 = {};+ mem1 = {};+ ASSERT_EQ(zero_init_mock->getZeroMemPool().mem_pool.size(), 0u);+}++TEST_P(ZeroMemPoolTests, CheckDifferentZeroStructsHolderPools) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0);+ auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1);+ auto local_init_struct_2 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2);++ auto& pool_init_0 = zero_init_mock_0->getZeroMemPool().mem_pool;+ auto& pool_init_1 = zero_init_mock_1->getZeroMemPool().mem_pool;+ auto& pool_init_2 = zero_init_mock_2->getZeroMemPool().mem_pool;++ auto mem0_struct_global = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096);+ auto mem0_struct_1 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096);+ auto mem0_struct_2 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096);+ auto mem1_struct_2 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096);++ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_0->getContext(),+ mem0_struct_global->data()));+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_2->getContext(),+ mem0_struct_1->data()));+ ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_0->getContext(),+ mem1_struct_2->data()));++ ASSERT_EQ(pool_init_0.size(), 1u);+ ASSERT_EQ(pool_init_1.size(), 1u);+ ASSERT_EQ(pool_init_2.size(), 2u);++ mem0_struct_2 = {};+ ASSERT_EQ(pool_init_2.size(), 1u);+ local_init_struct_2 = {};+ zero_init_mock_2 = {};+ ASSERT_EQ(pool_init_2.size(), 1u);+}++TEST_P(ZeroMemPoolTests, MultiThreadingDifferentZeroInitStructsHaveIsolatedPools) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ constexpr size_t threads_per_pool = 32;+ constexpr size_t total_threads = threads_per_pool * 3;++ auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0);+ auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1);+ auto local_init_struct_2 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2);++ std::array<std::thread, total_threads> threads;+ std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_0;+ std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_1;+ std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_2;++ for (size_t i = 0; i < threads_per_pool; ++i) {+ threads[i] = std::thread([&, i]() -> void {+ OV_ASSERT_NO_THROW(mem_pool_0[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096));+ });+ threads[i + threads_per_pool] = std::thread([&, i]() -> void {+ OV_ASSERT_NO_THROW(mem_pool_1[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096));+ });+ threads[i + (threads_per_pool * 2)] = std::thread([&, i]() -> void {+ OV_ASSERT_NO_THROW(mem_pool_2[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096));+ });+ }++ for (auto& t : threads) {+ t.join();+ }++ ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), threads_per_pool);+ ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), threads_per_pool);+ ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), threads_per_pool);++ for (size_t i = 0; i < threads_per_pool; ++i) {+ mem_pool_0[i] = {};+ mem_pool_1[i] = {};+ mem_pool_2[i] = {};+ }++ ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), 0u);+ ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), 0u);+ ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), 0u);+}++TEST_P(ZeroMemPoolTests, MultiThreadingImportMemoryReUseAndDestroyItWithMultipleInitStructs) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (!init_struct->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "Test requires support for importing standard allocated memory as external memory, which is "+ "not available on this platform.";+ }++ constexpr size_t init_structs_no = 3;+ constexpr size_t threads_per_pool = 32;+ constexpr size_t no_of_buffers = 5;++ auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();+ auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::array<std::shared_ptr<::intel_npu::ZeroInitStructsHolder>, init_structs_no> init_structs = {+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0),+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1),+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2)};++ std::array<std::array<void*, no_of_buffers>, init_structs_no> data = {};+ for (size_t s = 0; s < init_structs_no; ++s) {+ for (size_t i = 0; i < no_of_buffers; ++i) {+ data[s][i] = ::operator new(4096, std::align_val_t(4096));+ }+ }++ std::array<std::thread, threads_per_pool * init_structs_no> threads;+ for (size_t s = 0; s < init_structs_no; ++s) {+ for (size_t i = 0; i < threads_per_pool; ++i) {+ threads[s * threads_per_pool + i] = std::thread([&, s]() -> void {+ std::shared_ptr<::intel_npu::ZeroMem> zero_mem;+ for (size_t j = 0; j < threads_per_pool; ++j) {+ OV_ASSERT_NO_THROW(+ zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_structs[s],+ data[s][j % no_of_buffers],+ 4096));+ SLEEP_MS(0);+ if (j % 2 == 0) {+ zero_mem = {};+ }+ }+ zero_mem = {};+ });+ }+ }++ for (auto& t : threads) {+ t.join();+ }++ ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), 0u);+ ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), 0u);+ ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), 0u);++ for (size_t s = 0; s < init_structs_no; ++s) {+ for (size_t i = 0; i < no_of_buffers; ++i) {+ ::operator delete(data[s][i], std::align_val_t(4096));+ }+ }+}++TEST_P(ZeroMemPoolTests, ImportMemoryAdjacentToAlreadyImportedAllocation) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ if (!init_struct->isExternalMemoryStandardAllocationSupported()) {+ GTEST_SKIP() << "Test requires support for importing standard allocated memory as external memory, which is "+ "not available on this platform.";+ }++ // Allocate a single, contiguous two-page block so the two halves are guaranteed to be page-adjacent.+ constexpr size_t page = 4096;+ void* block = ::operator new(2 * page, std::align_val_t(page));+ auto* lower = static_cast<uint8_t*>(block);+ auto* upper = lower + page;++ // Import the upper page first so that it is a registered allocation in the L0 context.+ std::shared_ptr<::intel_npu::ZeroMem> upper_mem;+ OV_ASSERT_NO_THROW(upper_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, upper, page));++ // The lower page's exclusive end pointer (lower + page) aliases the base of the already-imported upper page.+ // This must NOT be treated as an overlap: the regions merely abut, they do not overlap. Importing the lower+ // page must succeed.+ std::shared_ptr<::intel_npu::ZeroMem> lower_mem;+ OV_ASSERT_NO_THROW(lower_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, lower, page));++ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), lower));+ ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), upper));++ lower_mem = {};+ upper_mem = {};+ ::operator delete(block, std::align_val_t(page));+}++TEST_P(ZeroMemPoolTests, DontDestroyZeroMemoryWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto zero_memory = ::intel_npu::zero_mem::allocate_memory(zero_init_struct, 4096, 4096);+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ zero_memory = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context is null while trying to free memory with id"), std::string::npos);+ ASSERT_EQ(logs.find("L0 zeMemFree result:"), std::string::npos);+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.hppdeleted file mode 100644index f11547382bb..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_mem_pool_tests.hpp+++ /dev/null@@ -1,440 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <random>-#include <thread>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common/zero_init_mock.hpp"-#include "functional_test_utils/ov_plugin_cache.hpp"-#include "intel_npu/common/npu.hpp"-#include "intel_npu/config/config.hpp"-#include "intel_npu/config/options.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_mem.hpp"-#include "intel_npu/utils/zero/zero_mem_pool.hpp"-#include "intel_npu/utils/zero/zero_utils.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/log.hpp"-#include "openvino/runtime/core.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--#ifdef _WIN32-# include <windows.h>-# define SLEEP_MS(x) Sleep(x)-#else-# include <unistd.h>-# define SLEEP_MS(x) usleep((x) * 1000)-#endif--using CompilationParams = std::string;--using ::testing::AllOf;-using ::testing::HasSubstr;--namespace ov {-namespace test {-namespace behavior {-class ZeroMemPoolTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-protected:- std::shared_ptr<ov::Core> core = utils::PluginCache::get().core();- ov::AnyMap configuration;- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> init_struct;- std::shared_ptr<::intel_npu::OptionsDesc> options = std::make_shared<::intel_npu::OptionsDesc>();- ::intel_npu::Config npu_config = ::intel_npu::Config(options);--public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- target_device = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '_');- target_device = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << target_device << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- target_device = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();-- init_struct = ::intel_npu::ZeroInitStructsHolder::getInstance();- }-- void TearDown() override {- if (!configuration.empty()) {- utils::PluginCache::get().reset();- }-- init_struct = nullptr;- APIBaseTest::TearDown();- }-};--TEST_P(ZeroMemPoolTests, GetZeroMemoryData) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- void* data = ::operator new(4096, std::align_val_t(4096));-- std::shared_ptr<::intel_npu::ZeroMem> get_zero_mem;-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- OV_ASSERT_NO_THROW(get_zero_mem =- ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data, 4096));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));- } else {- ASSERT_THROW(get_zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data, 4096),- ::intel_npu::ZeroMemException);- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));- }-- get_zero_mem = {};- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), data));-- ::operator delete(data, std::align_val_t(4096));-}--TEST_P(ZeroMemPoolTests, MultiThreadingReUseAlreadyAllocatedImportedMemory) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- const int threads_no = 256;- std::array<std::thread, threads_no> threads;- std::array<std::shared_ptr<::intel_npu::ZeroMem>, 5> zero_mem;- std::array<void*, 3> data;-- // Prep: add few entries in the pool- for (int i = 0; i < 3; i++) {- data[i] = ::operator new(4096, std::align_val_t(4096));- zero_mem[i] = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, data[i], 4096);- }- zero_mem[3] = ::intel_npu::zero_mem::allocate_memory(init_struct, 4096, 4096);- zero_mem[4] = ::intel_npu::zero_mem::allocate_memory(init_struct, 4096, 4096);-- for (int i = 0; i < threads_no; ++i) {- threads[i] = std::thread([this, &zero_mem, i]() -> void {- for (int j = 0; j < 256; j++) {- std::shared_ptr<::intel_npu::ZeroMem> get_zero_mem;- OV_ASSERT_NO_THROW(- get_zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct,- zero_mem[i % 5]->data(),- 4096));- SLEEP_MS(0);- }- });- }-- for (int i = 0; i < threads_no; ++i) {- threads[i].join();- }-- for (int i = 0; i < 3; i++) {- zero_mem[i] = {};- ::operator delete(data[i], std::align_val_t(4096));- }- }-}--TEST_P(ZeroMemPoolTests, MultiThreadingImportMemoryReUseAndDestroyIt) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (init_struct->isExternalMemoryStandardAllocationSupported()) {- constexpr int threads_no = 256;- constexpr int no_of_buffers = 5;- std::array<std::thread, threads_no> threads;- std::array<void*, no_of_buffers> data;-- for (int i = 0; i < no_of_buffers; i++) {- data[i] = ::operator new(4096, std::align_val_t(4096));- }-- for (int i = 0; i < threads_no; ++i) {- threads[i] = std::thread([&]() -> void {- std::shared_ptr<::intel_npu::ZeroMem> zero_mem;- for (int j = 0; j < threads_no; j++) {- OV_ASSERT_NO_THROW(- zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct,- data[j % no_of_buffers],- 4096));- SLEEP_MS(0);- if (j % 2 == 0) {- zero_mem = {};- }- }-- zero_mem = {};- });- }-- for (int i = 0; i < threads_no; ++i) {- threads[i].join();- }-- for (int i = 0; i < no_of_buffers; i++) {- ::operator delete(data[i], std::align_val_t(4096));- }- }-}--TEST_P(ZeroMemPoolTests, GetPoolReturnsSamePoolForSameInitStruct) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);- auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- auto mem0 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096);- auto mem1 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096);- ASSERT_EQ(zero_init_mock->getZeroMemPool().mem_pool.size(), 2u);-- mem0 = {};- mem1 = {};- ASSERT_EQ(zero_init_mock->getZeroMemPool().mem_pool.size(), 0u);-}--TEST_P(ZeroMemPoolTests, CheckDifferentZeroStructsHolderPools) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0);- auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1);- auto local_init_struct_2 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2);-- auto& pool_init_0 = zero_init_mock_0->getZeroMemPool().mem_pool;- auto& pool_init_1 = zero_init_mock_1->getZeroMemPool().mem_pool;- auto& pool_init_2 = zero_init_mock_2->getZeroMemPool().mem_pool;-- auto mem0_struct_global = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096);- auto mem0_struct_1 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096);- auto mem0_struct_2 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096);- auto mem1_struct_2 = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096);-- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_0->getContext(),- mem0_struct_global->data()));- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_2->getContext(),- mem0_struct_1->data()));- ASSERT_FALSE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(local_init_struct_0->getContext(),- mem1_struct_2->data()));-- ASSERT_EQ(pool_init_0.size(), 1u);- ASSERT_EQ(pool_init_1.size(), 1u);- ASSERT_EQ(pool_init_2.size(), 2u);-- mem0_struct_2 = {};- ASSERT_EQ(pool_init_2.size(), 1u);- local_init_struct_2 = {};- zero_init_mock_2 = {};- ASSERT_EQ(pool_init_2.size(), 1u);-}--TEST_P(ZeroMemPoolTests, MultiThreadingDifferentZeroInitStructsHaveIsolatedPools) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- constexpr size_t threads_per_pool = 32;- constexpr size_t total_threads = threads_per_pool * 3;-- auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- auto local_init_struct_0 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0);- auto local_init_struct_1 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1);- auto local_init_struct_2 = std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2);-- std::array<std::thread, total_threads> threads;- std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_0;- std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_1;- std::array<std::shared_ptr<::intel_npu::ZeroMem>, threads_per_pool> mem_pool_2;-- for (size_t i = 0; i < threads_per_pool; ++i) {- threads[i] = std::thread([&, i]() -> void {- OV_ASSERT_NO_THROW(mem_pool_0[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_0, 4096, 4096));- });- threads[i + threads_per_pool] = std::thread([&, i]() -> void {- OV_ASSERT_NO_THROW(mem_pool_1[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_1, 4096, 4096));- });- threads[i + (threads_per_pool * 2)] = std::thread([&, i]() -> void {- OV_ASSERT_NO_THROW(mem_pool_2[i] = ::intel_npu::zero_mem::allocate_memory(local_init_struct_2, 4096, 4096));- });- }-- for (auto& t : threads) {- t.join();- }-- ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), threads_per_pool);- ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), threads_per_pool);- ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), threads_per_pool);-- for (size_t i = 0; i < threads_per_pool; ++i) {- mem_pool_0[i] = {};- mem_pool_1[i] = {};- mem_pool_2[i] = {};- }-- ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), 0u);- ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), 0u);- ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), 0u);-}--TEST_P(ZeroMemPoolTests, MultiThreadingImportMemoryReUseAndDestroyItWithMultipleInitStructs) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (!init_struct->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "Test requires support for importing standard allocated memory as external memory, which is "- "not available on this platform.";- }-- constexpr size_t init_structs_no = 3;- constexpr size_t threads_per_pool = 32;- constexpr size_t no_of_buffers = 5;-- auto zero_init_mock_0 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_1 = std::make_shared<::intel_npu::ZeroInitStructsMock>();- auto zero_init_mock_2 = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::array<std::shared_ptr<::intel_npu::ZeroInitStructsHolder>, init_structs_no> init_structs = {- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_0),- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_1),- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock_2)};-- std::array<std::array<void*, no_of_buffers>, init_structs_no> data = {};- for (size_t s = 0; s < init_structs_no; ++s) {- for (size_t i = 0; i < no_of_buffers; ++i) {- data[s][i] = ::operator new(4096, std::align_val_t(4096));- }- }-- std::array<std::thread, threads_per_pool * init_structs_no> threads;- for (size_t s = 0; s < init_structs_no; ++s) {- for (size_t i = 0; i < threads_per_pool; ++i) {- threads[s * threads_per_pool + i] = std::thread([&, s]() -> void {- std::shared_ptr<::intel_npu::ZeroMem> zero_mem;- for (size_t j = 0; j < threads_per_pool; ++j) {- OV_ASSERT_NO_THROW(- zero_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_structs[s],- data[s][j % no_of_buffers],- 4096));- SLEEP_MS(0);- if (j % 2 == 0) {- zero_mem = {};- }- }- zero_mem = {};- });- }- }-- for (auto& t : threads) {- t.join();- }-- ASSERT_EQ(zero_init_mock_0->getZeroMemPool().mem_pool.size(), 0u);- ASSERT_EQ(zero_init_mock_1->getZeroMemPool().mem_pool.size(), 0u);- ASSERT_EQ(zero_init_mock_2->getZeroMemPool().mem_pool.size(), 0u);-- for (size_t s = 0; s < init_structs_no; ++s) {- for (size_t i = 0; i < no_of_buffers; ++i) {- ::operator delete(data[s][i], std::align_val_t(4096));- }- }-}--TEST_P(ZeroMemPoolTests, ImportMemoryAdjacentToAlreadyImportedAllocation) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- if (!init_struct->isExternalMemoryStandardAllocationSupported()) {- GTEST_SKIP() << "Test requires support for importing standard allocated memory as external memory, which is "- "not available on this platform.";- }-- // Allocate a single, contiguous two-page block so the two halves are guaranteed to be page-adjacent.- constexpr size_t page = 4096;- void* block = ::operator new(2 * page, std::align_val_t(page));- auto* lower = static_cast<uint8_t*>(block);- auto* upper = lower + page;-- // Import the upper page first so that it is a registered allocation in the L0 context.- std::shared_ptr<::intel_npu::ZeroMem> upper_mem;- OV_ASSERT_NO_THROW(upper_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, upper, page));-- // The lower page's exclusive end pointer (lower + page) aliases the base of the already-imported upper page.- // This must NOT be treated as an overlap: the regions merely abut, they do not overlap. Importing the lower- // page must succeed.- std::shared_ptr<::intel_npu::ZeroMem> lower_mem;- OV_ASSERT_NO_THROW(lower_mem = ::intel_npu::zero_mem::import_standard_allocation_memory(init_struct, lower, page));-- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), lower));- ASSERT_TRUE(::intel_npu::zeroUtils::get_l0_context_memory_allocation_id(init_struct->getContext(), upper));-- lower_mem = {};- upper_mem = {};- ::operator delete(block, std::align_val_t(page));-}--TEST_P(ZeroMemPoolTests, DontDestroyZeroMemoryWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto zero_memory = ::intel_npu::zero_mem::allocate_memory(zero_init_struct, 4096, 4096);- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- zero_memory = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context is null while trying to free memory with id"), std::string::npos);- ASSERT_EQ(logs.find("L0 zeMemFree result:"), std::string::npos);-}--} // namespace behavior-} // namespace test-} // namespace ovdiff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.cppindex ecbd805397b..ffa421dc1bb 100644--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.cpp+++ b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.cpp@@ -2,12 +2,251 @@// SPDX-License-Identifier: Apache-2.0//-#include "internal/utils/zero/zero_wrappers_tests.hpp"+#include <array>+#include <cstddef>+#include <exception>+#include <gmock/gmock-matchers.h>+#include <gmock/gmock.h>+#include <gtest/gtest.h>+#include <memory>+#include <random>+#include <thread>#include "common/npu_test_env_cfg.hpp"#include "common/utils.hpp"+#include "common/zero_init_mock.hpp"+#include "functional_test_utils/ov_plugin_cache.hpp"#include "intel_npu/config/options.hpp"#include "intel_npu/npu_private_properties.hpp"+#include "intel_npu/utils/zero/zero_init.hpp"+#include "intel_npu/utils/zero/zero_wrappers.hpp"+#include "openvino/core/any.hpp"+#include "openvino/core/log.hpp"+#include "openvino/runtime/core.hpp"+#include "shared_test_classes/base/ov_behavior_test_utils.hpp"++namespace ov {+namespace test {+namespace behavior {+using CompilationParams = std::string;++using ::testing::AllOf;+using ::testing::HasSubstr;+class ZeroWrappersTests : public ov::test::behavior::OVPluginTestBase,+ public testing::WithParamInterface<CompilationParams> {+public:+ static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {+ std::string target_device;+ ov::AnyMap configuration;+ target_device = obj.param;+ std::replace(target_device.begin(), target_device.end(), ':', '_');+ target_device = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);++ std::ostringstream result;+ result << "targetDevice=" << target_device << "_";+ result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";+ if (!configuration.empty()) {+ for (auto& configItem : configuration) {+ result << "configItem=" << configItem.first << "_";+ configItem.second.print(result);+ }+ }++ return result.str();+ }++ void SetUp() override {+ target_device = this->GetParam();++ SKIP_IF_CURRENT_TEST_IS_DISABLED()+ OVPluginTestBase::SetUp();+ }++ void TearDown() override {+ APIBaseTest::TearDown();+ }+};++TEST_P(ZeroWrappersTests, DontDestroyZeroCommandListWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ // Keep this std::function alive while logging is active.+ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto command_list = std::make_shared<::intel_npu::CommandList>(zero_init_struct);+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ command_list = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or CommandList handle is null during destruction."), std::string::npos);+ ASSERT_EQ(logs.find("zeCommandListDestroy failed"), std::string::npos);+}++TEST_P(ZeroWrappersTests, DontDestroyZeroCommandQueueWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto command_queue =+ std::make_shared<::intel_npu::CommandQueue>(zero_init_struct, ::intel_npu::CommandQueueDesc{});+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ command_queue = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or CommandQueue handle is null during destruction."), std::string::npos);+ ASSERT_EQ(logs.find("zeCommandQueueDestroy failed"), std::string::npos);+}++TEST_P(ZeroWrappersTests, DontDestroyZeroFenceWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto command_queue =+ std::make_shared<::intel_npu::CommandQueue>(zero_init_struct, ::intel_npu::CommandQueueDesc{});+ auto fence = std::make_shared<::intel_npu::Fence>(command_queue);+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ fence = {};+ command_queue = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or Fence handle is null during destruction."), std::string::npos);+ ASSERT_EQ(logs.find("zeFenceDestroy failed"), std::string::npos);+}++TEST_P(ZeroWrappersTests, DontDestroyZeroEventPoolWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto event_pool = std::make_shared<::intel_npu::EventPool>(zero_init_struct, 1);+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ event_pool = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or EventPool handle is null during destruction."), std::string::npos);+ ASSERT_EQ(logs.find("zeEventPoolDestroy failed"), std::string::npos);+}++TEST_P(ZeroWrappersTests, DontDestroyZeroEventWhenZeroContextIsDestroyed) {+ SKIP_IF_CURRENT_TEST_IS_DISABLED()++ std::string logs;+ std::mutex logs_mutex;++ std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {+ std::lock_guard<std::mutex> lock(logs_mutex);+ logs.append(msg);+ logs.push_back('\n');+ };++ auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();++ std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =+ std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);++ {+ utils::LogCallbackGuard log_callback_guard(log_cb);+ utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);++ auto event_pool = std::make_shared<::intel_npu::EventPool>(zero_init_struct, 1);+ auto event = std::make_shared<::intel_npu::Event>(event_pool, 0);+ ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);++ try {+ event = {};+ event_pool = {};+ } catch (const std::exception& ex) {+ ASSERT_FALSE(true) << ex.what();+ }+ }+ ASSERT_NE(logs.find("Context or Event handle is null during destruction."), std::string::npos);+ ASSERT_EQ(logs.find("zeEventDestroy failed"), std::string::npos);+}++} // namespace behavior+} // namespace test+} // namespace ovusing namespace ov::test::behavior;diff --git a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.hppdeleted file mode 100644index 19a379daef4..00000000000--- a/src/plugins/intel_npu/tests/functional/internal/utils/zero/zero_wrappers_tests.hpp+++ /dev/null@@ -1,250 +0,0 @@-// Copyright (C) 2018-2026 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#pragma once--#include <gmock/gmock-matchers.h>-#include <gmock/gmock.h>-#include <gtest/gtest.h>--#include <array>-#include <cstddef>-#include <exception>-#include <memory>-#include <random>-#include <thread>--#include "common/npu_test_env_cfg.hpp"-#include "common/utils.hpp"-#include "common/zero_init_mock.hpp"-#include "functional_test_utils/ov_plugin_cache.hpp"-#include "intel_npu/utils/zero/zero_init.hpp"-#include "intel_npu/utils/zero/zero_wrappers.hpp"-#include "openvino/core/any.hpp"-#include "openvino/core/log.hpp"-#include "openvino/runtime/core.hpp"-#include "shared_test_classes/base/ov_behavior_test_utils.hpp"--namespace ov {-namespace test {-namespace behavior {-using CompilationParams = std::string;--using ::testing::AllOf;-using ::testing::HasSubstr;-class ZeroWrappersTests : public ov::test::behavior::OVPluginTestBase,- public testing::WithParamInterface<CompilationParams> {-public:- static std::string getTestCaseName(const testing::TestParamInfo<CompilationParams>& obj) {- std::string target_device;- ov::AnyMap configuration;- target_device = obj.param;- std::replace(target_device.begin(), target_device.end(), ':', '_');- target_device = ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU);-- std::ostringstream result;- result << "targetDevice=" << target_device << "_";- result << "targetPlatform=" << ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device) << "_";- if (!configuration.empty()) {- for (auto& configItem : configuration) {- result << "configItem=" << configItem.first << "_";- configItem.second.print(result);- }- }-- return result.str();- }-- void SetUp() override {- target_device = this->GetParam();-- SKIP_IF_CURRENT_TEST_IS_DISABLED()- OVPluginTestBase::SetUp();- }-- void TearDown() override {- APIBaseTest::TearDown();- }-};--TEST_P(ZeroWrappersTests, DontDestroyZeroCommandListWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- // Keep this std::function alive while logging is active.- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto command_list = std::make_shared<::intel_npu::CommandList>(zero_init_struct);- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- command_list = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or CommandList handle is null during destruction."), std::string::npos);- ASSERT_EQ(logs.find("zeCommandListDestroy failed"), std::string::npos);-}--TEST_P(ZeroWrappersTests, DontDestroyZeroCommandQueueWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto command_queue =- std::make_shared<::intel_npu::CommandQueue>(zero_init_struct, ::intel_npu::CommandQueueDesc{});- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- command_queue = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or CommandQueue handle is null during destruction."), std::string::npos);- ASSERT_EQ(logs.find("zeCommandQueueDestroy failed"), std::string::npos);-}--TEST_P(ZeroWrappersTests, DontDestroyZeroFenceWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto command_queue =- std::make_shared<::intel_npu::CommandQueue>(zero_init_struct, ::intel_npu::CommandQueueDesc{});- auto fence = std::make_shared<::intel_npu::Fence>(command_queue);- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- fence = {};- command_queue = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or Fence handle is null during destruction."), std::string::npos);- ASSERT_EQ(logs.find("zeFenceDestroy failed"), std::string::npos);-}--TEST_P(ZeroWrappersTests, DontDestroyZeroEventPoolWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto event_pool = std::make_shared<::intel_npu::EventPool>(zero_init_struct, 1);- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- event_pool = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or EventPool handle is null during destruction."), std::string::npos);- ASSERT_EQ(logs.find("zeEventPoolDestroy failed"), std::string::npos);-}--TEST_P(ZeroWrappersTests, DontDestroyZeroEventWhenZeroContextIsDestroyed) {- SKIP_IF_CURRENT_TEST_IS_DISABLED()-- std::string logs;- std::mutex logs_mutex;-- std::function<void(std::string_view)> log_cb = [&](std::string_view msg) {- std::lock_guard<std::mutex> lock(logs_mutex);- logs.append(msg);- logs.push_back('\n');- };-- auto zero_init_mock = std::make_shared<::intel_npu::ZeroInitStructsMock>();-- std::shared_ptr<::intel_npu::ZeroInitStructsHolder> zero_init_struct =- std::reinterpret_pointer_cast<::intel_npu::ZeroInitStructsHolder>(zero_init_mock);-- {- utils::LogCallbackGuard log_callback_guard(log_cb);- utils::LoggerLevelGuard logger_level_guard(ov::log::Level::WARNING);-- auto event_pool = std::make_shared<::intel_npu::EventPool>(zero_init_struct, 1);- auto event = std::make_shared<::intel_npu::Event>(event_pool, 0);- ::intel_npu::ZeroInitStructsMock::destroyContextForInstance(zero_init_mock);-- try {- event = {};- event_pool = {};- } catch (const std::exception& ex) {- ASSERT_FALSE(true) << ex.what();- }- }- ASSERT_NE(logs.find("Context or Event handle is null during destruction."), std::string::npos);- ASSERT_EQ(logs.find("zeEventDestroy failed"), std::string::npos);-}--} // namespace behavior-} // namespace test-} // namespace ov