From 9fae91256aaab472aba68312ac4585bea0ea9a05 Mon Sep 17 00:00:00 2001 From: sbalandi Date: Tue, 9 Jan 2024 16:06:27 +0100 Subject: [PATCH] [Op Conformance] Update compare accuracy function --- .../behavior/ov_plugin/core_integration.cpp | 93 +- .../behavior/ov_plugin/properties_tests.cpp | 1 + .../ov_executable_network/exec_graph_info.hpp | 81 - .../exec_network_base.hpp | 636 ------- .../ov_executable_network/get_metric.hpp | 112 -- .../ov_executable_network/properties.hpp | 50 - .../behavior/ov_plugin/core_integration.hpp | 1676 ----------------- .../ov_plugin/core_integration_sw.hpp | 23 + .../ov_executable_network/exec_graph_info.cpp | 789 -------- .../ov_executable_network/get_metric.cpp | 352 ---- .../ov_executable_network/properties.cpp | 138 -- .../behavior/ov_plugin/properties_tests.cpp | 2 +- .../common_test_utils/src/ov_tensor_utils.cpp | 54 +- 13 files changed, 78 insertions(+), 3929 deletions(-) delete mode 100644 src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp delete mode 100644 src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_network_base.hpp delete mode 100644 src/tests/functional/plugin/shared/include/behavior/ov_executable_network/get_metric.hpp delete mode 100644 src/tests/functional/plugin/shared/include/behavior/ov_executable_network/properties.hpp delete mode 100644 src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp delete mode 100644 src/tests/functional/plugin/shared/src/behavior/ov_executable_network/exec_graph_info.cpp delete mode 100644 src/tests/functional/plugin/shared/src/behavior/ov_executable_network/get_metric.cpp delete mode 100644 src/tests/functional/plugin/shared/src/behavior/ov_executable_network/properties.cpp diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/core_integration.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/core_integration.cpp index 8bff5ce426b757..7bf4ad2e6ab75c 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/core_integration.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/core_integration.cpp @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "behavior/ov_plugin/core_integration.hpp" - #include "behavior/ov_plugin/core_integration_sw.hpp" #include "behavior/ov_plugin/query_model.hpp" @@ -11,90 +9,11 @@ using namespace ov::test::behavior; namespace { -INSTANTIATE_TEST_SUITE_P(smoke_OVClassBasicTestP, OVClassBasicTestP, - ::testing::Values(std::make_pair(std::string("openvino_intel_gpu_plugin"), std::string(ov::test::utils::DEVICE_GPU)))); - -INSTANTIATE_TEST_SUITE_P(smoke_OVClassNetworkTestP, OVClassNetworkTestP, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU))); - -// -// OV Class GetMetric -// - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU), - std::string(ov::test::utils::DEVICE_HETERO), - std::string(ov::test::utils::DEVICE_BATCH)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_SUPPORTED_METRICS, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU), - std::string(ov::test::utils::DEVICE_HETERO), - std::string(ov::test::utils::DEVICE_BATCH)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_AVAILABLE_DEVICES, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_FULL_DEVICE_NAME, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU), - std::string(ov::test::utils::DEVICE_HETERO), - std::string(ov::test::utils::DEVICE_BATCH)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); +INSTANTIATE_TEST_SUITE_P(smoke_OVClassModelTestP, OVClassModelTestP, + ::testing::Values(std::string(ov::test::utils::DEVICE_GPU))); -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_DEVICE_GOPS, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_DEVICE_TYPE, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_RANGE_FOR_STREAMS, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetMetricTest, OVClassGetMetricTest_ThrowUnsupported, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU), - std::string(ov::test::utils::DEVICE_HETERO), - std::string(ov::test::utils::DEVICE_BATCH)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetConfigTest, OVClassGetConfigTest_ThrowUnsupported, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU), - std::string(ov::test::utils::DEVICE_HETERO), - std::string(ov::test::utils::DEVICE_BATCH)) -); - -INSTANTIATE_TEST_SUITE_P( - nightly_OVClassGetAvailableDevices, OVClassGetAvailableDevices, - ::testing::Values(std::string(ov::test::utils::DEVICE_GPU)) -); - -// IE Class Common tests with -// -INSTANTIATE_TEST_SUITE_P(nightly_OVClassModelTestP, OVClassModelTestP, ::testing::Values("GPU")); -INSTANTIATE_TEST_SUITE_P(nightly_OVClassModelOptionalTestP, OVClassModelOptionalTestP, ::testing::Values("GPU")); +INSTANTIATE_TEST_SUITE_P(nightly_OVClassModelOptionalTestP, OVClassModelOptionalTestP, + ::testing::Values(std::string(ov::test::utils::DEVICE_GPU))); // Several devices case INSTANTIATE_TEST_SUITE_P(nightly_OVClassSeveralDevicesTest, @@ -109,10 +28,6 @@ INSTANTIATE_TEST_SUITE_P(nightly_OVClassSeveralDevicesTest, OVClassSeveralDevicesTestDefaultCore, ::testing::Values(std::vector({"GPU.0", "GPU.1"}))); -// Set config for all GPU devices - -INSTANTIATE_TEST_SUITE_P(nightly_OVClassSetGlobalConfigTest, OVClassSetGlobalConfigTest, ::testing::Values("GPU")); - // IE Class Query network INSTANTIATE_TEST_SUITE_P(smoke_OVClassQueryModelTest, OVClassQueryModelTest, ::testing::Values("GPU")); diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp index 4d49a8441413d6..53be28eff74ee0 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp @@ -103,6 +103,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_OVClassSetDevicePriorityConfigPropsTest, // // GPU specific metrics // + using OVGetMetricPropsTest_GPU_DEVICE_TOTAL_MEM_SIZE = OVClassBaseTestP; TEST_P(OVGetMetricPropsTest_GPU_DEVICE_TOTAL_MEM_SIZE, GetMetricAndPrintNoThrow) { ov::Core ie; diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp deleted file mode 100644 index b8f6f691cf5737..00000000000000 --- a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_graph_info.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifcorer: Apache-2.0 -// -#pragma once - -#include - -#include "base/ov_behavior_test_utils.hpp" -#include "openvino/runtime/exec_model_info.hpp" -#include "pugixml.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace behavior { - -typedef std::tuple - OVExecGraphImportExportTestParams; - -class OVExecGraphImportExportTest : public testing::WithParamInterface, - public OVCompiledNetworkTestBase { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - - void SetUp() override; - - void TearDown() override; - -protected: - std::shared_ptr core = utils::PluginCache::get().core(); - ov::AnyMap configuration; - ov::element::Type elementType; - std::shared_ptr function; -}; - -class OVExecGraphUniqueNodeNames : public testing::WithParamInterface, - public OVCompiledNetworkTestBase { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override; - -protected: - std::shared_ptr fnPtr; -}; - -class OVExecGraphSerializationTest : public testing::WithParamInterface, - public OVCompiledNetworkTestBase { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override; - void TearDown() override; - -private: - // walker traverse (DFS) xml document and store layer & data nodes in - // vector which is later used for comparison - struct exec_graph_walker : pugi::xml_tree_walker { - std::vector nodes; - bool for_each(pugi::xml_node &node) override; - }; - - // compare_docs() helper - std::pair compare_nodes(const pugi::xml_node &node1, - const pugi::xml_node &node2); - -protected: - // checks if two exec graph xml's are equivalent: - // - the same count of and nodes - // - the same count of attributes of each node - // - the same name of each attribute (value is not checked, since it can differ - // beetween different devices) - std::pair compare_docs(const pugi::xml_document &doc1, - const pugi::xml_document &doc2); - - std::string m_out_xml_path, m_out_bin_path; -}; -} // namespace behavior -} // namespace test -} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_network_base.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_network_base.hpp deleted file mode 100644 index d035e65a811a89..00000000000000 --- a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/exec_network_base.hpp +++ /dev/null @@ -1,636 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifcorer: Apache-2.0 -// - -#include - -#include "base/ov_behavior_test_utils.hpp" -#include "common_test_utils/file_utils.hpp" -#include "common_test_utils/ov_test_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/multiple_input_outpput_double_concat.hpp" -#include "common_test_utils/subgraph_builders/single_concat_with_constant.hpp" -#include "common_test_utils/subgraph_builders/single_split.hpp" -#include "common_test_utils/subgraph_builders/split_concat.hpp" -#include "functional_test_utils/plugin_cache.hpp" -#include "openvino/op/concat.hpp" -#include "openvino/pass/serialize.hpp" -#include "openvino/runtime/exec_model_info.hpp" -#include "openvino/runtime/tensor.hpp" - -namespace ov { -namespace test { -namespace behavior { - -// ===================== DEPRECATED ===================== - -class OVExecutableNetworkBaseTest : public testing::WithParamInterface, - public OVCompiledNetworkTestBase { -public: - static std::string getTestCaseName(testing::TestParamInfo 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 << "_"; - if (!configuration.empty()) { - for (auto& configItem : configuration) { - result << "configItem=" << configItem.first << "_"; - configItem.second.print(result); - result << "_"; - } - } - return result.str(); - } - - void SetUp() override { - std::tie(target_device, configuration) = this->GetParam(); - // Skip test according to plugin specific disabledTestPatterns() (if any) - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - function = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); - } - - void TearDown() override { - if (!configuration.empty()) { - utils::PluginCache::get().reset(); - } - APIBaseTest::TearDown(); - } - -protected: - std::shared_ptr core = utils::PluginCache::get().core(); - ov::AnyMap configuration; - std::shared_ptr function; - - void set_api_entity() override { api_entity = ov::test::utils::ov_entity::ov_compiled_model; } -}; - -using OVAutoExecutableNetworkTest = OVExecutableNetworkBaseTest; - -TEST_P(OVExecutableNetworkBaseTest, canLoadCorrectNetworkToGetExecutable) { - EXPECT_NO_THROW(auto execNet = core->compile_model(function, target_device, configuration)); -} - -TEST_P(OVExecutableNetworkBaseTest, canLoadNetworkFromMemory) { - std::string model = R"V0G0N( - - - - - - - 1 - 3 - 22 - 22 - - - - - - - - 1 - 3 - 22 - 22 - - - - - - - 1 - 3 - 22 - 22 - - - 1 - 3 - 22 - 22 - - - - - 1 - 6 - 22 - 22 - - - - - - - 1 - 6 - 22 - 22 - - - - - - - - - - - )V0G0N"; - EXPECT_NO_THROW(auto execNet = core->compile_model(model, ov::Tensor(), target_device, configuration)); -} - -TEST(OVExecutableNetworkBaseTest, smoke_LoadNetworkToDefaultDeviceNoThrow) { - std::shared_ptr core = utils::PluginCache::get().core(); - std::shared_ptr function = ov::test::utils::make_single_concat_with_constant(); - EXPECT_NO_THROW(auto execNet = core->compile_model(function)); -} - -TEST_P(OVExecutableNetworkBaseTest, canLoadCorrectNetworkToGetExecutableAndCreateInferRequest) { - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(auto req = execNet.create_infer_request()); -} - -TEST_P(OVExecutableNetworkBaseTest, checkGetExecGraphInfoIsNotNullptr) { - auto execNet = core->compile_model(function, target_device, configuration); - auto execGraph = execNet.get_runtime_model(); - EXPECT_NE(execGraph, nullptr); -} - -TEST_P(OVExecutableNetworkBaseTest, checkGetMetric) { - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(execNet.get_property(ov::supported_properties)); -} - -TEST_P(OVExecutableNetworkBaseTest, canLoadCorrectNetworkToGetExecutableAndCheckConfig) { - auto execNet = core->compile_model(function, target_device, configuration); - for (const auto& configItem : configuration) { - ov::Any param; - EXPECT_NO_THROW(param = execNet.get_property(configItem.first)); - EXPECT_FALSE(param.empty()); - EXPECT_EQ(param, configItem.second); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CanSetConfigToExecNet) { - auto execNet = core->compile_model(function, target_device); - std::map config; - for (const auto& confItem : configuration) { - config.emplace(confItem.first, confItem.second); - } - EXPECT_NO_THROW(execNet.set_property(config)); -} - -TEST_P(OVExecutableNetworkBaseTest, CanSetConfigToExecNetWithIncorrectConfig) { - auto execNet = core->compile_model(function, target_device); - std::map incorrectConfig = {{"abc", "def"}}; - std::map config; - for (const auto& confItem : incorrectConfig) { - config.emplace(confItem.first, confItem.second); - } - EXPECT_ANY_THROW(execNet.set_property(config)); -} - -TEST_P(OVExecutableNetworkBaseTest, CanSetConfigToExecNetAndCheckConfigAndCheck) { - auto execNet = core->compile_model(function, target_device); - std::map config; - for (const auto& confItem : configuration) { - config.emplace(confItem.first, confItem.second); - } - execNet.set_property(config); - for (const auto& configItem : configuration) { - ov::Any param; - EXPECT_NO_THROW(param = execNet.get_property(configItem.first)); - EXPECT_FALSE(param.empty()); - EXPECT_EQ(param, configItem.second); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CanCreateTwoExeNetworks) { - std::vector vec; - for (auto i = 0; i < 2; i++) { - EXPECT_NO_THROW(vec.push_back(core->compile_model(function, target_device, configuration))); - EXPECT_NE(nullptr, function); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CanCreateTwoExeNetworksAndCheckFunction) { - std::vector vec; - for (auto i = 0; i < 2; i++) { - EXPECT_NO_THROW(vec.push_back(core->compile_model(function, target_device, configuration))); - EXPECT_NE(nullptr, vec[i].get_runtime_model()); - EXPECT_NE(vec.begin()->get_runtime_model(), vec[i].get_runtime_model()); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CanGetInputsInfo) { - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(auto inInfo = execNet.inputs()); -} - -TEST_P(OVExecutableNetworkBaseTest, CanGetOutputsInfo) { - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(auto outInfo = execNet.outputs()); -} - -TEST_P(OVExecutableNetworkBaseTest, CanGetInputsInfoAndCheck) { - auto execNet = core->compile_model(function, target_device, configuration); - auto inputs = execNet.inputs(); - std::vector paramVec; - for (const auto& input : inputs) { - paramVec.push_back(*input.get_tensor().get_names().begin()); - } - auto params = function->get_parameters(); - for (const auto& param : params) { - EXPECT_NE(std::find(paramVec.begin(), paramVec.end(), *param->get_output_tensor(0).get_names().begin()), - paramVec.end()); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CanGetOutputsInfoAndCheck) { - auto execNet = core->compile_model(function, target_device, configuration); - auto outputs = execNet.outputs(); - std::vector resVec; - for (const auto& out : outputs) { - resVec.push_back(*out.get_tensor().get_names().begin()); - } - auto results = function->get_results(); - for (const auto& param : results) { - EXPECT_NE(std::find(resVec.begin(), resVec.end(), *param->get_output_tensor(0).get_names().begin()), - resVec.end()); - } -} - -TEST_P(OVExecutableNetworkBaseTest, CheckExecGraphInfoBeforeExecution) { - std::shared_ptr execGraph; - // Load CNNNetwork to target plugins - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(execGraph = execNet.get_runtime_model()); - std::map originalLayersMap; - for (const auto& layer : function->get_ops()) { - originalLayersMap[layer->get_friendly_name()] = 0; - } - int constCnt = 0; - - std::shared_ptr getFunction = std::dynamic_pointer_cast(execGraph); - EXPECT_NE(getFunction, nullptr); - - for (const auto& op : getFunction->get_ops()) { - const ov::RTMap& rtInfo = op->get_rt_info(); - - auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string { - auto it = rtInfo.find(paramName); - IE_ASSERT(rtInfo.end() != it); - return it->second.as(); - }; - - // Each layer from the execGraphInfo network must have PM data option set - EXPECT_EQ("not_executed", getExecValue(ov::exec_model_info::PERF_COUNTER)); - // Parse origin layer names (fused/merged layers) from the executable graph - // and compare with layers from the original model - auto origFromExecLayer = getExecValue(ov::exec_model_info::ORIGINAL_NAMES); - if (origFromExecLayer.empty()) { - constCnt++; - } else { - auto origFromExecLayerSep = ov::test::utils::splitStringByDelimiter(origFromExecLayer); - std::for_each(origFromExecLayerSep.begin(), origFromExecLayerSep.end(), [&](const std::string& op) { - auto origLayer = originalLayersMap.find(op); - EXPECT_NE(originalLayersMap.end(), origLayer) << op; - origLayer->second++; - }); - } - } - - // All layers from the original IR must be present with in ExecGraphInfo - for (auto& layer : originalLayersMap) { - if ((layer.second == 0) && (constCnt > 0)) { - constCnt--; - } else { - EXPECT_GE(layer.second, 0); - } - } -} - -TEST_P(OVExecutableNetworkBaseTest, CheckExecGraphInfoAfterExecution) { - std::shared_ptr execGraph; - // Load CNNNetwork to target plugins - auto execNet = core->compile_model(function, target_device, configuration); - EXPECT_NO_THROW(execGraph = execNet.get_runtime_model()); - std::map originalLayersMap; - for (const auto& layer : function->get_ops()) { - originalLayersMap[layer->get_friendly_name()] = 0; - } - int constCnt = 0; - // Store all the layers from the executable graph information represented as CNNNetwork - bool hasOpWithValidTime = false; - auto getFunction = std::dynamic_pointer_cast(execGraph); - EXPECT_NE(nullptr, getFunction); - - for (const auto& op : getFunction->get_ops()) { - const auto& rtInfo = op->get_rt_info(); - - auto getExecValue = [&rtInfo](const std::string& paramName) -> std::string { - auto it = rtInfo.find(paramName); - IE_ASSERT(rtInfo.end() != it); - return it->second.as(); - }; - - // At least one layer in the topology should be executed and have valid perf counter value - try { - float x = static_cast(std::atof(getExecValue(ov::exec_model_info::PERF_COUNTER).c_str())); - std::cout << "TIME: " << x << std::endl; - EXPECT_GE(x, 0.0f); - hasOpWithValidTime = true; - } catch (std::exception&) { - } - - // Parse origin layer names (fused/merged layers) from the executable graph - // and compare with layers from the original model - auto origFromExecLayer = getExecValue(ov::exec_model_info::ORIGINAL_NAMES); - std::vector origFromExecLayerSep = ov::test::utils::splitStringByDelimiter(origFromExecLayer); - if (origFromExecLayer.empty()) { - constCnt++; - } else { - std::for_each(origFromExecLayerSep.begin(), origFromExecLayerSep.end(), [&](const std::string& layer) { - auto origLayer = originalLayersMap.find(layer); - EXPECT_NE(originalLayersMap.end(), origLayer) << layer; - origLayer->second++; - }); - } - } - - EXPECT_TRUE(hasOpWithValidTime); - - // All layers from the original IR must be present within ExecGraphInfo - for (auto& layer : originalLayersMap) { - if ((layer.second == 0) && (constCnt > 0)) { - constCnt--; - } else { - EXPECT_GE(layer.second, 0); - } - } -} - -TEST_P(OVExecutableNetworkBaseTest, LoadNetworkCreateDefaultExecGraphResult) { - auto net = core->compile_model(function, target_device, configuration); - auto runtime_function = net.get_runtime_model(); - ASSERT_NE(nullptr, runtime_function); - auto actual_parameters = runtime_function->get_parameters(); - auto actual_results = runtime_function->get_results(); - auto expected_parameters = function->get_parameters(); - auto expected_results = function->get_results(); - ASSERT_EQ(expected_parameters.size(), actual_parameters.size()); - for (std::size_t i = 0; i < expected_parameters.size(); ++i) { - auto expected_element_type = expected_parameters[i]->get_output_element_type(0); - auto actual_element_type = actual_parameters[i]->get_output_element_type(0); - ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i; - auto expected_shape = expected_parameters[i]->get_output_shape(0); - auto actual_shape = actual_parameters[i]->get_output_shape(0); - ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i; - } - ASSERT_EQ(expected_results.size(), actual_results.size()); - for (std::size_t i = 0; i < expected_results.size(); ++i) { - auto expected_element_type = expected_results[i]->get_input_element_type(0); - auto actual_element_type = actual_results[i]->get_input_element_type(0); - ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i; - auto expected_shape = expected_results[i]->get_input_shape(0); - auto actual_shape = actual_results[i]->get_input_shape(0); - ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i; - } -} - -TEST_P(OVExecutableNetworkBaseTest, canExport) { - auto ts = ov::test::utils::GetTimestamp(); - std::string modelName = GetTestName().substr(0, ov::test::utils::maxFileNameLength) + "_" + ts; - auto execNet = core->compile_model(function, target_device, configuration); - std::ofstream out(modelName, std::ios::out); - EXPECT_NO_THROW(execNet.export_model(out)); - out.close(); - EXPECT_TRUE(ov::test::utils::fileExists(modelName)); - ov::test::utils::removeFile(modelName); -} - -TEST_P(OVExecutableNetworkBaseTest, pluginDoesNotChangeOriginalNetwork) { - // compare 2 networks - auto referenceNetwork = ov::test::utils::make_conv_pool_relu(); - compare_functions(function, referenceNetwork); -} - -TEST_P(OVExecutableNetworkBaseTest, getInputFromFunctionWithSingleInput) { - ov::CompiledModel execNet; - - function = ov::test::utils::make_split_concat(); - - execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(function->inputs().size(), 1); - EXPECT_EQ(function->inputs().size(), execNet.inputs().size()); - EXPECT_NO_THROW(execNet.input()); - EXPECT_EQ(function->input().get_tensor().get_names(), execNet.input().get_tensor().get_names()); - EXPECT_EQ(function->input().get_tensor().get_partial_shape(), execNet.input().get_tensor().get_partial_shape()); - EXPECT_EQ(function->input().get_tensor().get_element_type(), execNet.input().get_tensor().get_element_type()); -} - -TEST_P(OVExecutableNetworkBaseTest, getOutputFromFunctionWithSingleInput) { - ov::CompiledModel execNet; - - function = ov::test::utils::make_split_concat(); - - execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(function->outputs().size(), 1); - EXPECT_EQ(function->outputs().size(), execNet.outputs().size()); - EXPECT_NO_THROW(execNet.output()); - EXPECT_EQ(function->output().get_tensor().get_names(), execNet.output().get_tensor().get_names()); - EXPECT_EQ(function->output().get_tensor().get_partial_shape(), execNet.output().get_tensor().get_partial_shape()); - EXPECT_EQ(function->output().get_tensor().get_element_type(), execNet.output().get_tensor().get_element_type()); -} - -TEST_P(OVExecutableNetworkBaseTest, getInputsFromFunctionWithSeveralInputs) { - ov::CompiledModel execNet; - - function = ov::test::utils::make_concat_with_params(); - - execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(function->inputs().size(), 2); - EXPECT_EQ(function->inputs().size(), execNet.inputs().size()); - EXPECT_THROW(execNet.input(), ov::Exception); - EXPECT_EQ(function->input(0).get_tensor().get_names(), execNet.input(0).get_tensor().get_names()); - EXPECT_EQ(function->input(0).get_tensor().get_partial_shape(), execNet.input(0).get_tensor().get_partial_shape()); - EXPECT_EQ(function->input(0).get_tensor().get_element_type(), execNet.input(0).get_tensor().get_element_type()); - EXPECT_EQ(function->input(1).get_tensor().get_names(), execNet.input(1).get_tensor().get_names()); - EXPECT_EQ(function->input(1).get_tensor().get_partial_shape(), execNet.input(1).get_tensor().get_partial_shape()); - EXPECT_EQ(function->input(1).get_tensor().get_element_type(), execNet.input(1).get_tensor().get_element_type()); - EXPECT_EQ(function->input(0).get_node(), function->input("data1").get_node()); - EXPECT_NE(function->input(1).get_node(), function->input("data1").get_node()); - EXPECT_EQ(function->input(1).get_node(), function->input("data2").get_node()); - EXPECT_NE(function->input(0).get_node(), function->input("data2").get_node()); -} - -TEST_P(OVExecutableNetworkBaseTest, getOutputsFromFunctionWithSeveralOutputs) { - ov::CompiledModel execNet; - - function = ov::test::utils::make_multiple_input_output_double_concat(); - - execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(function->outputs().size(), 2); - EXPECT_EQ(function->outputs().size(), execNet.outputs().size()); - EXPECT_THROW(execNet.output(), ov::Exception); - EXPECT_EQ(function->output(0).get_tensor().get_names(), execNet.output(0).get_tensor().get_names()); - EXPECT_EQ(function->output(0).get_tensor().get_partial_shape(), execNet.output(0).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(0).get_tensor().get_element_type(), execNet.output(0).get_tensor().get_element_type()); - EXPECT_EQ(function->output(1).get_tensor().get_names(), execNet.output(1).get_tensor().get_names()); - EXPECT_EQ(function->output(1).get_tensor().get_partial_shape(), execNet.output(1).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(1).get_tensor().get_element_type(), execNet.output(1).get_tensor().get_element_type()); - EXPECT_EQ(function->output(0).get_node(), function->output("concat1").get_node()); - EXPECT_NE(function->output(0).get_node(), function->output("concat2").get_node()); - EXPECT_EQ(function->output(1).get_node(), function->output("concat2").get_node()); - EXPECT_NE(function->output(1).get_node(), function->output("concat1").get_node()); -} - -TEST_P(OVExecutableNetworkBaseTest, getOutputsFromSplitFunctionWithSeveralOutputs) { - ov::CompiledModel execNet; - - function = ov::test::utils::make_single_split(); - - execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(function->outputs().size(), 2); - EXPECT_EQ(function->outputs().size(), execNet.outputs().size()); - EXPECT_THROW(execNet.output(), ov::Exception); - EXPECT_EQ(function->output(0).get_tensor().get_names(), execNet.output(0).get_tensor().get_names()); - EXPECT_EQ(function->output(0).get_tensor().get_partial_shape(), execNet.output(0).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(0).get_tensor().get_element_type(), execNet.output(0).get_tensor().get_element_type()); - EXPECT_EQ(function->output(1).get_tensor().get_names(), execNet.output(1).get_tensor().get_names()); - EXPECT_EQ(function->output(1).get_tensor().get_partial_shape(), execNet.output(1).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(1).get_tensor().get_element_type(), execNet.output(1).get_tensor().get_element_type()); - EXPECT_EQ(function->output(0).get_node(), function->output("tensor_split_1").get_node()); - EXPECT_NE(function->output(1).get_node(), function->output("tensor_split_1").get_node()); - EXPECT_EQ(function->output(1).get_node(), function->output("tensor_split_2").get_node()); - EXPECT_NE(function->output(0).get_node(), function->output("tensor_split_2").get_node()); -} - -// Load correct network to Plugin to get executable network -TEST_P(OVExecutableNetworkBaseTest, precisionsAsInOriginalFunction) { - ov::CompiledModel execNet; - EXPECT_NO_THROW(execNet = core->compile_model(function, target_device, configuration)); - - EXPECT_EQ(function->get_parameters().size(), execNet.inputs().size()); - auto ref_parameter = function->get_parameters().back(); - auto actual_parameter = execNet.inputs().back().get_node_shared_ptr(); - EXPECT_EQ(ref_parameter->get_element_type(), actual_parameter->get_element_type()); - EXPECT_EQ(ref_parameter->get_shape(), actual_parameter->get_shape()); - EXPECT_EQ(ref_parameter->get_friendly_name(), actual_parameter->get_friendly_name()); - - EXPECT_EQ(function->get_results().size(), execNet.outputs().size()); - auto ref_result = function->get_results().back(); - auto actual_result = execNet.outputs().back().get_node_shared_ptr(); - EXPECT_EQ(ref_result->get_element_type(), actual_result->get_element_type()); - EXPECT_EQ(ref_result->get_shape(), actual_result->get_shape()); - EXPECT_EQ(ref_result->get_friendly_name(), actual_result->get_friendly_name()); -} - -// Load correct network to Plugin to get executable network -TEST_P(OVExecutableNetworkBaseTest, precisionsAsInOriginalIR) { - auto filePrefix = ov::test::utils::generateTestFilePrefix(); - const std::string m_out_xml_path_1 = filePrefix + "precisionsAsInOriginalIR.xml"; - const std::string m_out_bin_path_1 = filePrefix + "precisionsAsInOriginalIR.bin"; - ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(function); - - ov::CompiledModel execNet; - EXPECT_NO_THROW(execNet = core->compile_model(m_out_xml_path_1, target_device, configuration)); - ov::test::utils::removeIRFiles(m_out_xml_path_1, m_out_bin_path_1); - - EXPECT_EQ(function->get_parameters().size(), execNet.inputs().size()); - auto ref_parameter = function->get_parameters().back(); - auto actual_parameter = execNet.inputs().back().get_node_shared_ptr(); - EXPECT_EQ(ref_parameter->get_element_type(), actual_parameter->get_element_type()); - EXPECT_EQ(ref_parameter->get_shape(), actual_parameter->get_shape()); - EXPECT_EQ(ref_parameter->get_friendly_name(), actual_parameter->get_friendly_name()); - - EXPECT_EQ(function->get_results().size(), execNet.outputs().size()); - auto ref_result = function->get_results().back(); - auto actual_result = execNet.outputs().back().get_node_shared_ptr(); - EXPECT_EQ(ref_result->get_element_type(), actual_result->get_element_type()); - EXPECT_EQ(ref_result->get_shape(), actual_result->get_shape()); - EXPECT_EQ(ref_result->get_friendly_name(), actual_result->get_friendly_name()); -} - -TEST_P(OVExecutableNetworkBaseTest, getCompiledModelFromInferRequest) { - ov::InferRequest req; - { - ov::CompiledModel compiled_model; - ASSERT_NO_THROW(compiled_model = core->compile_model(function, target_device, configuration)); - ASSERT_NO_THROW(req = compiled_model.create_infer_request()); - ASSERT_NO_THROW(req.infer()); - } - { - ov::CompiledModel restored_compiled_model; - ov::InferRequest another_req; - ASSERT_NO_THROW(restored_compiled_model = req.get_compiled_model()); - ASSERT_NO_THROW(another_req = restored_compiled_model.create_infer_request()); - ASSERT_NO_THROW(another_req.infer()); - } -} - -TEST_P(OVExecutableNetworkBaseTest, loadIncorrectV10Model) { - ov::CompiledModel execNet; - - // Create simple function - { - auto param1 = std::make_shared(element::Type_t::f32, ngraph::Shape({1, 3, 24, 24})); - param1->set_friendly_name("param1"); - param1->output(0).get_tensor().set_names({"data1"}); - auto param2 = std::make_shared(element::Type_t::f32, ngraph::Shape({1, 3, 24, 24})); - param2->set_friendly_name("param2"); - param2->output(0).get_tensor().set_names({"data2"}); - auto concat = std::make_shared(OutputVector{param1, param2}, 1); - concat->set_friendly_name("data1"); - concat->output(0).get_tensor().set_names({"concat"}); - auto result = std::make_shared(concat); - result->set_friendly_name("result"); - function = std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{param1, param2}); - function->get_rt_info()["version"] = int64_t(10); - function->set_friendly_name("SimpleConcat"); - } - EXPECT_THROW(core->compile_model(function, target_device, configuration), ov::Exception); -} - -TEST_P(OVExecutableNetworkBaseTest, loadIncorrectV11Model) { - ov::CompiledModel execNet; - - // Create simple function - { - auto param1 = std::make_shared(element::Type_t::f32, ngraph::Shape({1, 3, 24, 24})); - param1->set_friendly_name("param1"); - param1->output(0).get_tensor().set_names({"data1"}); - auto param2 = std::make_shared(element::Type_t::f32, ngraph::Shape({1, 3, 24, 24})); - param2->set_friendly_name("param2"); - param2->output(0).get_tensor().set_names({"data2"}); - auto concat = std::make_shared(OutputVector{param1, param2}, 1); - concat->set_friendly_name("data1"); - concat->output(0).get_tensor().set_names({"concat"}); - auto result = std::make_shared(concat); - result->set_friendly_name("result"); - function = std::make_shared(ngraph::ResultVector{result}, ngraph::ParameterVector{param1, param2}); - function->get_rt_info()["version"] = int64_t(11); - function->set_friendly_name("SimpleConcat"); - } - EXPECT_NO_THROW(core->compile_model(function, target_device, configuration)); -} - -TEST_P(OVAutoExecutableNetworkTest, AutoNotImplementedSetConfigToExecNet) { - std::map config; - for (const auto& confItem : configuration) { - config.emplace(confItem.first, confItem.second); - } - auto execNet = core->compile_model(function, target_device, config); - EXPECT_ANY_THROW(execNet.set_property(config)); -} - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/get_metric.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/get_metric.hpp deleted file mode 100644 index a306d741276241..00000000000000 --- a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/get_metric.hpp +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include -#include "common_test_utils/subgraph_builders/single_conv.hpp" - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# include -# define GTEST_COUT std::cerr << "[ ] [ INFO ] " -# include -# include - -#endif - -namespace ov { -namespace test { -namespace behavior { - -#define ASSERT_EXEC_METRIC_SUPPORTED(property) \ - { \ - auto properties = compiled_model.get_property(ov::supported_properties);\ - auto it = std::find(properties.begin(), properties.end(), property); \ - ASSERT_NE(properties.end(), it); \ - } - -using PriorityParams = std::tuple< - std::string, // Device name - ov::AnyMap // device priority Configuration key ->; -class OVClassExecutableNetworkGetMetricTest_Priority : public ::testing::WithParamInterface, - public OVCompiledNetworkTestBase { -protected: - ov::AnyMap configuration; - std::shared_ptr simpleNetwork; - -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override { - std::tie(target_device, configuration) = GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - simpleNetwork = ov::test::utils::make_single_conv(); - } -}; -using OVClassExecutableNetworkGetMetricTest_DEVICE_PRIORITY = OVClassExecutableNetworkGetMetricTest_Priority; -using OVClassExecutableNetworkGetMetricTest_MODEL_PRIORITY = OVClassExecutableNetworkGetMetricTest_Priority; - -using OVCompiledModelClassBaseTest = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkImportExportTestP = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetMetricTest_NETWORK_NAME = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetMetricTest_ThrowsUnsupported = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkGetConfigTest = OVCompiledModelClassBaseTestP; -using OVClassExecutableNetworkSetConfigTest = OVCompiledModelClassBaseTestP; - -class OVClassExecutableNetworkGetMetricTestForSpecificConfig : - public OVClassNetworkTest, - public ::testing::WithParamInterface>>, - public OVCompiledNetworkTestBase { -protected: - std::string configKey; - ov::Any configValue; - -public: - void SetUp() override { - target_device = std::get<0>(GetParam()); - std::tie(configKey, configValue) = std::get<1>(GetParam()); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - OVClassNetworkTest::SetUp(); - } -}; - -using OVClassExecutableNetworkSupportedConfigTest = OVClassExecutableNetworkGetMetricTestForSpecificConfig; -using OVClassExecutableNetworkUnsupportedConfigTest = OVClassExecutableNetworkGetMetricTestForSpecificConfig; - -// -// Hetero Executable network case -// -class OVClassHeteroExecutableNetworkGetMetricTest : - public OVClassNetworkTest, - public ::testing::WithParamInterface, - public OVCompiledNetworkTestBase { -protected: - std::string heteroDeviceName; - void SetCpuAffinity(ov::Core& core, std::vector& expectedTargets); - -public: - void SetUp() override { - target_device = GetParam(); - heteroDeviceName = ov::test::utils::DEVICE_HETERO + std::string(":") + target_device; - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - OVClassNetworkTest::SetUp(); - } -}; -using OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS = OVClassHeteroExecutableNetworkGetMetricTest; -using OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS = OVClassHeteroExecutableNetworkGetMetricTest; -using OVClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME = OVClassHeteroExecutableNetworkGetMetricTest; -using OVClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK = OVClassHeteroExecutableNetworkGetMetricTest; -using OVClassHeteroExecutableNetworkGetMetricTest_EXEC_DEVICES = OVClassHeteroExecutableNetworkGetMetricTest; - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/properties.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/properties.hpp deleted file mode 100644 index 4476d96b6151cf..00000000000000 --- a/src/tests/functional/plugin/shared/include/behavior/ov_executable_network/properties.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "base/ov_behavior_test_utils.hpp" -#include "openvino/runtime/properties.hpp" -#include "openvino/util/common_util.hpp" - -#include "common_test_utils/test_assertions.hpp" -#include "common_test_utils/file_utils.hpp" -#include "common_test_utils/unicode_utils.hpp" - -namespace ov { -namespace test { -namespace behavior { - -class OVCompiledModelPropertiesBase : public OVCompiledNetworkTestBase { -public: - std::shared_ptr core = utils::PluginCache::get().core(); - std::shared_ptr model; - AnyMap properties; -}; - -class OVCompiledModelEmptyPropertiesTests : public testing::WithParamInterface, - public OVCompiledModelPropertiesBase { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override; -}; - -using PropertiesParams = std::tuple; - -class OVCompiledModelPropertiesTests : public testing::WithParamInterface, - public OVCompiledModelPropertiesBase { -public: - static std::string getTestCaseName(testing::TestParamInfo obj); - void SetUp() override; - void TearDown() override; -}; - -using OVCompiledModelPropertiesIncorrectTests = OVCompiledModelPropertiesTests; -using OVCompiledModelPropertiesDefaultTests = OVCompiledModelPropertiesTests; - -using OVClassCompileModelTest = OVClassBaseTestP; - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp deleted file mode 100644 index 8ac84b3abf0dd2..00000000000000 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration.hpp +++ /dev/null @@ -1,1676 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include "base/ov_behavior_test_utils.hpp" -#include - -#include "common_test_utils/test_assertions.hpp" -#include "common_test_utils/file_utils.hpp" -#include "common_test_utils/unicode_utils.hpp" -#include "openvino/op/add.hpp" -#include "openvino/op/concat.hpp" -#include "openvino/op/constant.hpp" -#include "openvino/op/gather.hpp" -#include "openvino/op/matmul.hpp" -#include "openvino/op/parameter.hpp" -#include "openvino/op/relu.hpp" -#include "openvino/op/reshape.hpp" -#include "openvino/op/result.hpp" -#include "openvino/op/shape_of.hpp" -#include "openvino/util/file_util.hpp" -#include "common_test_utils/subgraph_builders/conv_pool_relu_no_reshapes.hpp" -#include "common_test_utils/subgraph_builders/split_conv_concat.hpp" - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -# include -# define GTEST_COUT std::cerr << "[ ] [ INFO ] " -# include -# include -# include "openvino/pass/manager.hpp" -#endif - -namespace ov { -namespace test { -namespace behavior { - -#define OV_ASSERT_PROPERTY_SUPPORTED(property_key) \ -{ \ - auto properties = ie.get_property(target_device, ov::supported_properties); \ - auto it = std::find(properties.begin(), properties.end(), property_key); \ - ASSERT_NE(properties.end(), it); \ -} - -inline bool supportsAvailableDevices(ov::Core& ie, const std::string& target_device) { - auto supported_properties = ie.get_property(target_device, ov::supported_properties); - return supported_properties.end() != - std::find(std::begin(supported_properties), std::end(supported_properties), ov::available_devices); -} - -inline bool supportsDeviceID(ov::Core& ie, const std::string& target_device) { - auto supported_properties = - ie.get_property(target_device, ov::supported_properties); - return supported_properties.end() != - std::find(std::begin(supported_properties), std::end(supported_properties), ov::device::id); -} - -class OVClassBasicTestP : public OVPluginTestBase, - public ::testing::WithParamInterface> { -protected: - std::string deviceName; - std::string pluginName; - -public: - void SetUp() override { - std::tie(pluginName, target_device) = GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - pluginName += OV_BUILD_POSTFIX; - if (pluginName == (std::string("openvino_template_plugin") + OV_BUILD_POSTFIX)) { - pluginName = ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(), pluginName); - } - } -}; - -class OVClassSetDefaultDeviceIDTest : public OVPluginTestBase, - public ::testing::WithParamInterface> { -protected: - std::string deviceName; - std::string deviceID; - -public: - void SetUp() override { - std::tie(target_device, deviceID) = GetParam(); - APIBaseTest::SetUp(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - } -}; - -using DevicePriorityParams = std::tuple< - std::string, // Device name - ov::AnyMap // Configuration key and its default value ->; - -class OVClassSetDevicePriorityConfigTest : public OVPluginTestBase, - public ::testing::WithParamInterface { -protected: - std::string deviceName; - ov::AnyMap configuration; - std::shared_ptr actualNetwork; - -public: - void SetUp() override { - std::tie(target_device, configuration) = GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - actualNetwork = ov::test::utils::make_split_conv_concat(); - } -}; - -using OVClassNetworkTestP = OVClassBaseTestP; -using OVClassQueryNetworkTest = OVClassBaseTestP; -using OVClassImportExportTestP = OVClassBaseTestP; -using OVClassGetMetricTest_SUPPORTED_METRICS = OVClassBaseTestP; -using OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS = OVClassBaseTestP; -using OVClassGetMetricTest_AVAILABLE_DEVICES = OVClassBaseTestP; -using OVClassGetMetricTest_FULL_DEVICE_NAME = OVClassBaseTestP; -using OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID = OVClassBaseTestP; -using OVClassGetMetricTest_DEVICE_UUID = OVClassBaseTestP; -using OVClassGetMetricTest_DEVICE_LUID = OVClassBaseTestP; -using OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES = OVClassBaseTestP; -using OVClassGetMetricTest_DEVICE_GOPS = OVClassBaseTestP; -using OVClassGetMetricTest_DEVICE_TYPE = OVClassBaseTestP; -using OVClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS = OVClassBaseTestP; -using OVClassGetMetricTest_MAX_BATCH_SIZE = OVClassBaseTestP; -using OVClassGetMetricTest_ThrowUnsupported = OVClassBaseTestP; -using OVClassGetConfigTest = OVClassBaseTestP; -using OVClassGetConfigTest_ThrowUnsupported = OVClassBaseTestP; -using OVClassGetAvailableDevices = OVClassBaseTestP; -using OVClassGetMetricTest_RANGE_FOR_STREAMS = OVClassBaseTestP; -using OVClassLoadNetworkAfterCoreRecreateTest = OVClassBaseTestP; -using OVClassLoadNetworkTest = OVClassQueryNetworkTest; -using OVClassLoadNetworkTestWithThrow = OVClassBaseTestP; -using OVClassSetGlobalConfigTest = OVClassBaseTestP; -using OVClassSetModelPriorityConfigTest = OVClassBaseTestP; -using OVClassSetExecutionModeHintConfigTest = OVClassBaseTestP; -using OVClassSetEnableCpuPinningHintConfigTest = OVClassBaseTestP; -using OVClassSetSchedulingCoreTypeHintConfigTest = OVClassBaseTestP; -using OVClassSetEnableHyperThreadingHintConfigTest = OVClassBaseTestP; -using OVClassSetTBBForceTerminatePropertyTest = OVClassBaseTestP; -using OVClassSetLogLevelConfigTest = OVClassBaseTestP; -using OVClassSpecificDeviceTestSetConfig = OVClassBaseTestP; -using OVClassSpecificDeviceTestGetConfig = OVClassBaseTestP; -using OVClassLoadNetworkWithCorrectPropertiesTest = OVClassSetDevicePriorityConfigTest; -using OVClassLoadNetworkWithCondidateDeviceListContainedMetaPluginTest = OVClassSetDevicePriorityConfigTest; -using OVClassLoadNetWorkReturnDefaultHintTest = OVClassSetDevicePriorityConfigTest; -using OVClassLoadNetWorkDoNotReturnDefaultHintTest = OVClassSetDevicePriorityConfigTest; -using OVClassLoadNetworkAndCheckSecondaryPropertiesTest = OVClassSetDevicePriorityConfigTest; - -class OVClassSeveralDevicesTest : public OVPluginTestBase, - public OVClassNetworkTest, - public ::testing::WithParamInterface> { -public: - std::vector target_devices; - - void SetUp() override { - target_device = ov::test::utils::DEVICE_MULTI; - SKIP_IF_CURRENT_TEST_IS_DISABLED() - APIBaseTest::SetUp(); - OVClassNetworkTest::SetUp(); - target_devices = GetParam(); - } -}; - -using OVClassSeveralDevicesTestLoadNetwork = OVClassSeveralDevicesTest; -using OVClassSeveralDevicesTestQueryNetwork = OVClassSeveralDevicesTest; -using OVClassSeveralDevicesTestDefaultCore = OVClassSeveralDevicesTest; - -TEST(OVClassBasicTest, smoke_createDefault) { - OV_ASSERT_NO_THROW(ov::Core ie); -} - -TEST_P(OVClassBasicTestP, registerExistingPluginThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.register_plugin(pluginName, target_device), ov::Exception); -} - -// TODO: CVS-68982 -#ifndef OPENVINO_STATIC_LIBRARY - -TEST_P(OVClassBasicTestP, registerNewPluginNoThrows) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.register_plugin(pluginName, "NEW_DEVICE_NAME")); - OV_ASSERT_NO_THROW(ie.get_property("NEW_DEVICE_NAME", ov::supported_properties)); -} - -TEST(OVClassBasicTest, smoke_registerNonExistingPluginFileThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.register_plugins("nonExistPlugins.xml"), ov::Exception); -} - -TEST(OVClassBasicTest, smoke_createNonExistingConfigThrows) { - ASSERT_THROW(ov::Core ie("nonExistPlugins.xml"), ov::Exception); -} - -inline std::string getPluginFile() { - std::string filePostfix{"mock_engine_valid.xml"}; - std::string filename = ov::test::utils::generateTestFilePrefix() + "_" + filePostfix; - std::ostringstream stream; - stream << ""; - ov::test::utils::createFile(filename, stream.str()); - return filename; -} - -TEST(OVClassBasicTest, smoke_createMockEngineConfigNoThrows) { - const std::string filename = getPluginFile(); - OV_ASSERT_NO_THROW(ov::Core ie(filename)); - ov::test::utils::removeFile(filename.c_str()); -} - -TEST(OVClassBasicTest, smoke_createMockEngineConfigThrows) { - std::string filename = ov::test::utils::generateTestFilePrefix() + "_mock_engine.xml"; - std::string content{""}; - ov::test::utils::createFile(filename, content); - ASSERT_THROW(ov::Core ie(filename), ov::Exception); - ov::test::utils::removeFile(filename.c_str()); -} - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -inline void generateModelFile() { - ov::pass::Manager manager; - manager.register_pass("test_model.xml", "test_model.bin"); - auto function = ov::test::utils::make_conv_pool_relu_no_reshapes({1, 3, 227, 227}); - manager.run_passes(function); -} - -TEST(OVClassBasicTest, compile_model_no_property_unicode) { - std::string model_xml_name = "test_model.xml"; - std::string model_bin_name = "test_model.bin"; - generateModelFile(); - for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) { - std::wstring postfix = L"_" + ov::test::utils::test_unicode_postfix_vector[testIndex]; - std::wstring modelXmlPathW = ov::test::utils::addUnicodePostfixToPath(model_xml_name, postfix); - std::wstring modelBinPathW = ov::test::utils::addUnicodePostfixToPath(model_bin_name, postfix); - GTEST_COUT << testIndex << ": " << ::ov::util::wstring_to_string(modelXmlPathW) << std::endl; - - try { - bool is_copy_successfully; - is_copy_successfully = ov::test::utils::copyFile(model_xml_name, modelXmlPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_xml_name << "' to '" - << ::ov::util::wstring_to_string(modelXmlPathW) << "'"; - } - - is_copy_successfully = ov::test::utils::copyFile(model_bin_name, modelBinPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_bin_name << "' to '" - << ::ov::util::wstring_to_string(modelBinPathW) << "'"; - } - - ov::Core core = createCoreWithTemplate(); - - OV_ASSERT_NO_THROW(core.compile_model(modelXmlPathW)); - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - GTEST_COUT << "OK" << std::endl; - } catch (const ov::Exception& e_next) { - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); - FAIL() << e_next.what(); - } - } - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); -} - -TEST(OVClassBasicTest, compile_model_with_property_unicode) { - std::string model_xml_name = "test_model.xml"; - std::string model_bin_name = "test_model.bin"; - generateModelFile(); - for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) { - std::wstring postfix = L"_" + ov::test::utils::test_unicode_postfix_vector[testIndex]; - std::wstring modelXmlPathW = ov::test::utils::addUnicodePostfixToPath(model_xml_name, postfix); - std::wstring modelBinPathW = ov::test::utils::addUnicodePostfixToPath(model_bin_name, postfix); - GTEST_COUT << testIndex << ": " << ::ov::util::wstring_to_string(modelXmlPathW) << std::endl; - - try { - bool is_copy_successfully; - is_copy_successfully = ov::test::utils::copyFile(model_xml_name, modelXmlPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_xml_name << "' to '" - << ::ov::util::wstring_to_string(modelXmlPathW) << "'"; - } - - is_copy_successfully = ov::test::utils::copyFile(model_bin_name, modelBinPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_bin_name << "' to '" - << ::ov::util::wstring_to_string(modelBinPathW) << "'"; - } - - ov::Core core = createCoreWithTemplate(); - - OV_ASSERT_NO_THROW( - core.compile_model(modelXmlPathW, ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY))); - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - GTEST_COUT << "OK" << std::endl; - } catch (const ov::Exception& e_next) { - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); - FAIL() << e_next.what(); - } - } - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); -} - -TEST_P(OVClassBasicTestP, compile_model_with_device_no_property_unicode) { - std::string model_xml_name = "test_model.xml"; - std::string model_bin_name = "test_model.bin"; - generateModelFile(); - for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) { - std::wstring postfix = L"_" + ov::test::utils::test_unicode_postfix_vector[testIndex]; - std::wstring modelXmlPathW = ov::test::utils::addUnicodePostfixToPath(model_xml_name, postfix); - std::wstring modelBinPathW = ov::test::utils::addUnicodePostfixToPath(model_bin_name, postfix); - GTEST_COUT << testIndex << ": " << ::ov::util::wstring_to_string(modelXmlPathW) << std::endl; - try { - bool is_copy_successfully; - is_copy_successfully = ov::test::utils::copyFile(model_xml_name, modelXmlPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_xml_name << "' to '" - << ::ov::util::wstring_to_string(modelXmlPathW) << "'"; - } - - is_copy_successfully = ov::test::utils::copyFile(model_bin_name, modelBinPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_bin_name << "' to '" - << ::ov::util::wstring_to_string(modelBinPathW) << "'"; - } - - ov::Core core = createCoreWithTemplate(); - - OV_ASSERT_NO_THROW(core.compile_model(modelXmlPathW, target_device)); - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - GTEST_COUT << "OK" << std::endl; - } catch (const ov::Exception& e_next) { - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); - FAIL() << e_next.what(); - } - } - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); -} - -TEST_P(OVClassBasicTestP, compile_model_with_device_with_property_unicode) { - std::string model_xml_name = "test_model.xml"; - std::string model_bin_name = "test_model.bin"; - generateModelFile(); - for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) { - std::wstring postfix = L"_" + ov::test::utils::test_unicode_postfix_vector[testIndex]; - std::wstring modelXmlPathW = ov::test::utils::addUnicodePostfixToPath(model_xml_name, postfix); - std::wstring modelBinPathW = ov::test::utils::addUnicodePostfixToPath(model_bin_name, postfix); - GTEST_COUT << testIndex << ": " << ::ov::util::wstring_to_string(modelXmlPathW) << std::endl; - - try { - bool is_copy_successfully; - is_copy_successfully = ov::test::utils::copyFile(model_xml_name, modelXmlPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_xml_name << "' to '" - << ::ov::util::wstring_to_string(modelXmlPathW) << "'"; - } - - is_copy_successfully = ov::test::utils::copyFile(model_bin_name, modelBinPathW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << model_bin_name << "' to '" - << ::ov::util::wstring_to_string(modelBinPathW) << "'"; - } - - ov::Core core = createCoreWithTemplate(); - - OV_ASSERT_NO_THROW(core.compile_model(modelXmlPathW, - target_device, - ov::hint::performance_mode(ov::hint::PerformanceMode::LATENCY))); - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - GTEST_COUT << "OK" << std::endl; - } catch (const ov::Exception& e_next) { - ov::test::utils::removeFile(modelXmlPathW); - ov::test::utils::removeFile(modelBinPathW); - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); - FAIL() << e_next.what(); - } - } - ov::test::utils::removeFile(model_xml_name); - ov::test::utils::removeFile(model_bin_name); -} -#endif - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPOR -TEST_P(OVClassBasicTestP, smoke_registerPluginsXMLUnicodePath) { - const std::string pluginXML = getPluginFile(); - - for (std::size_t testIndex = 0; testIndex < ov::test::utils::test_unicode_postfix_vector.size(); testIndex++) { - GTEST_COUT << testIndex; - std::wstring postfix = L"_" + ov::test::utils::test_unicode_postfix_vector[testIndex]; - std::wstring pluginsXmlW = ov::test::utils::addUnicodePostfixToPath(pluginXML, postfix); - - try { - bool is_copy_successfully; - is_copy_successfully = ov::test::utils::copyFile(pluginXML, pluginsXmlW); - if (!is_copy_successfully) { - FAIL() << "Unable to copy from '" << pluginXML << "' to '" - << ::ov::util::wstring_to_string(pluginsXmlW) << "'"; - } - - GTEST_COUT << "Test " << testIndex << std::endl; - - ov::Core ie = createCoreWithTemplate(); - GTEST_COUT << "Core created " << testIndex << std::endl; - OV_ASSERT_NO_THROW(ie.register_plugins(::ov::util::wstring_to_string(pluginsXmlW))); - ov::test::utils::removeFile(pluginsXmlW); - OV_ASSERT_NO_THROW(ie.get_versions("mock")); // from pluginXML - OV_ASSERT_NO_THROW(ie.get_versions(target_device)); - GTEST_COUT << "Plugin created " << testIndex << std::endl; - - OV_ASSERT_NO_THROW(ie.register_plugin(pluginName, "TEST_DEVICE")); - OV_ASSERT_NO_THROW(ie.get_versions("TEST_DEVICE")); - GTEST_COUT << "Plugin registered and created " << testIndex << std::endl; - - GTEST_COUT << "OK" << std::endl; - } catch (const ov::Exception& e_next) { - ov::test::utils::removeFile(pluginsXmlW); - std::remove(pluginXML.c_str()); - FAIL() << e_next.what(); - } - } - ov::test::utils::removeFile(pluginXML); -} - -#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -#endif // !OPENVINO_STATIC_LIBRARY - -// -// GetVersions() -// - -TEST_P(OVClassBasicTestP, getVersionsByExactDeviceNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.get_versions(target_device + ".0")); -} - -TEST_P(OVClassBasicTestP, getVersionsByDeviceClassNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.get_versions(target_device)); -} - -TEST_P(OVClassBasicTestP, getVersionsNonEmpty) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_EQ(2, ie.get_versions(ov::test::utils::DEVICE_HETERO + std::string(":") + target_device).size()); -} - -// -// UnregisterPlugin -// - -TEST_P(OVClassBasicTestP, unregisterExistingPluginNoThrow) { - ov::Core ie = createCoreWithTemplate(); - // device instance is not created yet - ASSERT_THROW(ie.unload_plugin(target_device), ov::Exception); - - // make the first call to IE which created device instance - ie.get_versions(target_device); - // now, we can unregister device - OV_ASSERT_NO_THROW(ie.unload_plugin(target_device)); -} - -TEST_P(OVClassBasicTestP, accessToUnregisteredPluginThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.unload_plugin(target_device), ov::Exception); - OV_ASSERT_NO_THROW(ie.get_versions(target_device)); - OV_ASSERT_NO_THROW(ie.unload_plugin(target_device)); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::AnyMap{})); - OV_ASSERT_NO_THROW(ie.get_versions(target_device)); - OV_ASSERT_NO_THROW(ie.unload_plugin(target_device)); -} - -TEST(OVClassBasicTest, smoke_unregisterNonExistingPluginThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.unload_plugin("unkown_device"), ov::Exception); -} - -// -// SetConfig -// - -TEST_P(OVClassBasicTestP, SetConfigAllThrows) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.set_property({{"unsupported_key", "4"}})); - ASSERT_ANY_THROW(ie.get_versions(target_device)); -} - -TEST_P(OVClassBasicTestP, SetConfigForUnRegisteredDeviceThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.set_property("unregistered_device", {{"unsupported_key", "4"}}), ov::Exception); -} - -TEST_P(OVClassBasicTestP, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::enable_profiling(true))); -} - -TEST_P(OVClassBasicTestP, SetConfigAllNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.set_property(ov::enable_profiling(true))); - OV_ASSERT_NO_THROW(ie.get_versions(target_device)); -} - -TEST_P(OVClassBasicTestP, SetGetConfigForTbbTerminateThrows) { - ov::Core ie = createCoreWithTemplate(); - bool value = false; - ASSERT_NO_THROW(ie.set_property(target_device, {ov::force_tbb_terminate(true)})); - ASSERT_NO_THROW(value = ie.get_property(ov::force_tbb_terminate.name()).as()); - ASSERT_TRUE(value); - - ASSERT_NO_THROW(ie.set_property(target_device, {ov::force_tbb_terminate(false)})); - ASSERT_NO_THROW(value = ie.get_property(ov::force_tbb_terminate.name()).as()); - ASSERT_FALSE(value); -} - -TEST(OVClassBasicTest, smoke_SetConfigHeteroThrows) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_HETERO, ov::enable_profiling(true))); -} - -TEST(OVClassBasicTest, smoke_SetConfigDevicePropertiesThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.set_property("", ov::device::properties(ov::test::utils::DEVICE_CPU, ov::enable_profiling(true))), - ov::Exception); - ASSERT_THROW(ie.set_property(ov::test::utils::DEVICE_CPU, - ov::device::properties(ov::test::utils::DEVICE_CPU, ov::enable_profiling(true))), - ov::Exception); - ASSERT_THROW(ie.set_property(ov::test::utils::DEVICE_AUTO, - ov::device::properties(ov::test::utils::DEVICE_CPU, ov::enable_profiling(true))), - ov::Exception); - ASSERT_THROW(ie.set_property(ov::test::utils::DEVICE_AUTO, - ov::device::properties(ov::test::utils::DEVICE_CPU, ov::num_streams(4))), - ov::Exception); -} - -TEST_P(OVClassBasicTestP, SetConfigHeteroTargetFallbackThrows) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_HETERO, ov::device::priorities(target_device))); -} - -TEST_P(OVClassBasicTestP, smoke_SetConfigHeteroNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::string value; - - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_HETERO, ov::device::priorities(target_device))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::test::utils::DEVICE_HETERO, ov::device::priorities)); - ASSERT_EQ(target_device, value); - - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_HETERO, ov::device::priorities(target_device))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::test::utils::DEVICE_HETERO, ov::device::priorities)); - ASSERT_EQ(target_device, value); -} - -TEST(OVClassBasicTest, smoke_SetConfigAutoNoThrows) { - ov::Core ie = createCoreWithTemplate(); - - // priority config test - ov::hint::Priority value; - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority(ov::hint::Priority::LOW))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::LOW); - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority(ov::hint::Priority::MEDIUM))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::MEDIUM); - OV_ASSERT_NO_THROW(ie.set_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority(ov::hint::Priority::HIGH))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::test::utils::DEVICE_AUTO, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::HIGH); -} - -TEST_P(OVClassSpecificDeviceTestSetConfig, SetConfigSpecificDeviceNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - std::string deviceID, cleartarget_device; - auto pos = target_device.find('.'); - if (pos != std::string::npos) { - cleartarget_device = target_device.substr(0, pos); - deviceID = target_device.substr(pos + 1, target_device.size()); - } - if (!supportsDeviceID(ie, cleartarget_device) || !supportsAvailableDevices(ie, cleartarget_device)) { - GTEST_FAIL(); - } - auto deviceIDs = ie.get_property(cleartarget_device, ov::available_devices); - if (std::find(deviceIDs.begin(), deviceIDs.end(), deviceID) == deviceIDs.end()) { - GTEST_FAIL(); - } - - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::enable_profiling(true))); - bool value = false; - OV_ASSERT_NO_THROW(value = ie.get_property(target_device, ov::enable_profiling)); - ASSERT_TRUE(value); -} - -TEST_P(OVClassSetModelPriorityConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - // priority config test - ov::hint::Priority value; - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::hint::model_priority(ov::hint::Priority::LOW))); - OV_ASSERT_NO_THROW(value = ie.get_property(target_device, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::LOW); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::hint::model_priority(ov::hint::Priority::MEDIUM))); - OV_ASSERT_NO_THROW(value = ie.get_property(target_device, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::MEDIUM); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::hint::model_priority(ov::hint::Priority::HIGH))); - OV_ASSERT_NO_THROW(value = ie.get_property(target_device, ov::hint::model_priority)); - EXPECT_EQ(value, ov::hint::Priority::HIGH); -} - -TEST_P(OVClassSetExecutionModeHintConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - OV_ASSERT_PROPERTY_SUPPORTED(ov::hint::execution_mode); - - ov::hint::ExecutionMode defaultMode{}; - ASSERT_NO_THROW(defaultMode = ie.get_property(target_device, ov::hint::execution_mode)); - (void)defaultMode; - - ie.set_property(target_device, ov::hint::execution_mode(ov::hint::ExecutionMode::ACCURACY)); - ASSERT_EQ(ov::hint::ExecutionMode::ACCURACY, ie.get_property(target_device, ov::hint::execution_mode)); - ie.set_property(target_device, ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE)); - ASSERT_EQ(ov::hint::ExecutionMode::PERFORMANCE, ie.get_property(target_device, ov::hint::execution_mode)); -} - -TEST_P(OVClassSetEnableCpuPinningHintConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - OV_ASSERT_PROPERTY_SUPPORTED(ov::hint::enable_cpu_pinning); - - bool defaultMode{}; - ASSERT_NO_THROW(defaultMode = ie.get_property(target_device, ov::hint::enable_cpu_pinning)); - (void)defaultMode; - - ASSERT_EQ(true, ie.get_property(target_device, ov::hint::enable_cpu_pinning)); - - ie.set_property(target_device, ov::hint::enable_cpu_pinning(false)); - ASSERT_EQ(false, ie.get_property(target_device, ov::hint::enable_cpu_pinning)); - ie.set_property(target_device, ov::hint::enable_cpu_pinning(true)); - ASSERT_EQ(true, ie.get_property(target_device, ov::hint::enable_cpu_pinning)); -} - -TEST_P(OVClassSetSchedulingCoreTypeHintConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - OV_ASSERT_PROPERTY_SUPPORTED(ov::hint::scheduling_core_type); - - ov::hint::SchedulingCoreType defaultMode{}; - ASSERT_NO_THROW(defaultMode = ie.get_property(target_device, ov::hint::scheduling_core_type)); - (void)defaultMode; - - ASSERT_EQ(ov::hint::SchedulingCoreType::ANY_CORE, ie.get_property(target_device, ov::hint::scheduling_core_type)); - - ie.set_property(target_device, ov::hint::scheduling_core_type(ov::hint::SchedulingCoreType::PCORE_ONLY)); - ASSERT_EQ(ov::hint::SchedulingCoreType::PCORE_ONLY, ie.get_property(target_device, ov::hint::scheduling_core_type)); - ie.set_property(target_device, ov::hint::scheduling_core_type(ov::hint::SchedulingCoreType::ECORE_ONLY)); - ASSERT_EQ(ov::hint::SchedulingCoreType::ECORE_ONLY, ie.get_property(target_device, ov::hint::scheduling_core_type)); - ie.set_property(target_device, ov::hint::scheduling_core_type(ov::hint::SchedulingCoreType::ANY_CORE)); - ASSERT_EQ(ov::hint::SchedulingCoreType::ANY_CORE, ie.get_property(target_device, ov::hint::scheduling_core_type)); -} - -TEST_P(OVClassSetEnableHyperThreadingHintConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - OV_ASSERT_PROPERTY_SUPPORTED(ov::hint::enable_hyper_threading); - - bool defaultMode{}; - ASSERT_NO_THROW(defaultMode = ie.get_property(target_device, ov::hint::enable_hyper_threading)); - (void)defaultMode; - - ASSERT_EQ(true, ie.get_property(target_device, ov::hint::enable_hyper_threading)); - - ie.set_property(target_device, ov::hint::enable_hyper_threading(false)); - ASSERT_EQ(false, ie.get_property(target_device, ov::hint::enable_hyper_threading)); - ie.set_property(target_device, ov::hint::enable_hyper_threading(true)); - ASSERT_EQ(true, ie.get_property(target_device, ov::hint::enable_hyper_threading)); -} - -TEST_P(OVClassSetDevicePriorityConfigTest, SetConfigAndCheckGetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::string devicePriority; - OV_ASSERT_NO_THROW(ie.set_property(target_device, configuration)); - OV_ASSERT_NO_THROW(devicePriority = ie.get_property(target_device, ov::device::priorities)); - ASSERT_EQ(devicePriority, configuration[ov::device::priorities.name()].as()); -} - -TEST(OVClassBasicTest, SetCacheDirPropertyCoreNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - // Cache_dir property test - ov::Any value; - OV_ASSERT_NO_THROW(ie.set_property(ov::cache_dir("./tmp_cache_dir"))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::cache_dir.name())); - EXPECT_EQ(value.as(), std::string("./tmp_cache_dir")); -} - -TEST(OVClassBasicTest, SetTBBForceTerminatePropertyCoreNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - bool value = true; - OV_ASSERT_NO_THROW(ie.set_property(ov::force_tbb_terminate(false))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::force_tbb_terminate.name()).as()); - EXPECT_FALSE(value); - OV_ASSERT_NO_THROW(ie.set_property(ov::force_tbb_terminate(true))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::force_tbb_terminate.name()).as()); - EXPECT_TRUE(value); -} - -TEST(OVClassBasicTest, SetEnableMmapPropertyCoreNoThrow) { - ov::Core ie; - - bool value = true; - OV_ASSERT_NO_THROW(ie.set_property(ov::enable_mmap(false))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::enable_mmap.name()).as()); - EXPECT_FALSE(value); - OV_ASSERT_NO_THROW(ie.set_property(ov::enable_mmap(true))); - OV_ASSERT_NO_THROW(value = ie.get_property(ov::enable_mmap.name()).as()); - EXPECT_TRUE(value); -} - -TEST(OVClassBasicTest, GetUnsupportedPropertyCoreThrow) { - ov::Core ie = createCoreWithTemplate(); - - // Unsupported property test - ASSERT_THROW(ie.get_property("unsupported_property"), ov::Exception); -} - -TEST_P(OVClassSetLogLevelConfigTest, SetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - // log level - ov::log::Level logValue; - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::NO))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::NO); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::ERR))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::ERR); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::WARNING))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::WARNING); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::INFO))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::INFO); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::DEBUG))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::DEBUG); - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::log::level(ov::log::Level::TRACE))); - OV_ASSERT_NO_THROW(logValue = ie.get_property(target_device, ov::log::level)); - EXPECT_EQ(logValue, ov::log::Level::TRACE); -} - -// -// QueryNetwork -// - -TEST_P(OVClassNetworkTestP, QueryNetworkActualThrows) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.query_model(actualNetwork, ov::test::utils::DEVICE_HETERO + std::string(":") + target_device)); -} - -TEST_P(OVClassNetworkTestP, QueryNetworkActualNoThrow) { - ov::Core ie = createCoreWithTemplate(); - ie.query_model(actualNetwork, target_device); -} - -TEST_P(OVClassNetworkTestP, QueryNetworkWithKSO) { - ov::Core ie = createCoreWithTemplate(); - - auto rl_map = ie.query_model(ksoNetwork, target_device); - auto func = ksoNetwork; - for (const auto& op : func->get_ops()) { - if (!rl_map.count(op->get_friendly_name())) { - FAIL() << "Op " << op->get_friendly_name() << " is not supported by " << target_device; - } - } -} - -TEST_P(OVClassSeveralDevicesTestQueryNetwork, QueryNetworkActualSeveralDevicesNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - std::string clear_target_device; - auto pos = target_devices.begin()->find('.'); - if (pos != std::string::npos) { - clear_target_device = target_devices.begin()->substr(0, pos); - } - if (!supportsDeviceID(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } - if (!supportsAvailableDevices(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support AvailableDevices property" << std::endl; - } - auto deviceIDs = ie.get_property(clear_target_device, ov::available_devices); - ASSERT_LT(deviceIDs.size(), target_devices.size()); - - std::string multi_target_device = ov::test::utils::DEVICE_MULTI + std::string(":"); - for (auto& dev_name : target_devices) { - multi_target_device += dev_name; - if (&dev_name != &(target_devices.back())) { - multi_target_device += ","; - } - } - OV_ASSERT_NO_THROW(ie.query_model(actualNetwork, multi_target_device)); -} - -TEST_P(OVClassNetworkTestP, SetAffinityWithConstantBranches) { - ov::Core ie = createCoreWithTemplate(); - - std::shared_ptr func; - { - ov::PartialShape shape({1, 84}); - ov::element::Type type(ov::element::Type_t::f32); - auto param = std::make_shared(type, shape); - auto matMulWeights = ov::op::v0::Constant::create(ov::element::Type_t::f32, {10, 84}, {1}); - auto shapeOf = std::make_shared(matMulWeights); - auto gConst1 = ov::op::v0::Constant::create(ov::element::Type_t::i32, {1}, {1}); - auto gConst2 = ov::op::v0::Constant::create(ov::element::Type_t::i64, {}, {0}); - auto gather = std::make_shared(shapeOf, gConst1, gConst2); - auto concatConst = ov::op::v0::Constant::create(ov::element::Type_t::i64, {1}, {1}); - auto concat = std::make_shared(ov::NodeVector{concatConst, gather}, 0); - auto relu = std::make_shared(param); - auto reshape = std::make_shared(relu, concat, false); - auto matMul = std::make_shared(reshape, matMulWeights, false, true); - auto matMulBias = ov::op::v0::Constant::create(ov::element::Type_t::f32, {1, 10}, {1}); - auto addBias = std::make_shared(matMul, matMulBias); - auto result = std::make_shared(addBias); - - ov::ParameterVector params = {param}; - ov::ResultVector results = {result}; - - func = std::make_shared(results, params); - } - - auto rl_map = ie.query_model(func, target_device); - for (const auto& op : func->get_ops()) { - if (!rl_map.count(op->get_friendly_name())) { - FAIL() << "Op " << op->get_friendly_name() << " is not supported by " << target_device; - } - } - for (const auto& op : func->get_ops()) { - std::string affinity = rl_map[op->get_friendly_name()]; - op->get_rt_info()["affinity"] = affinity; - } - auto exeNetwork = ie.compile_model(func, target_device); -} - -TEST_P(OVClassNetworkTestP, SetAffinityWithKSO) { - ov::Core ie = createCoreWithTemplate(); - - auto rl_map = ie.query_model(ksoNetwork, target_device); - auto func = ksoNetwork; - for (const auto& op : func->get_ops()) { - if (!rl_map.count(op->get_friendly_name())) { - FAIL() << "Op " << op->get_friendly_name() << " is not supported by " << target_device; - } - } - for (const auto& op : func->get_ops()) { - std::string affinity = rl_map[op->get_friendly_name()]; - op->get_rt_info()["affinity"] = affinity; - } - auto exeNetwork = ie.compile_model(ksoNetwork, target_device); -} - -TEST_P(OVClassNetworkTestP, QueryNetworkHeteroActualNoThrow) { - ov::Core ie = createCoreWithTemplate(); - ov::SupportedOpsMap res; - OV_ASSERT_NO_THROW( - res = ie.query_model(actualNetwork, ov::test::utils::DEVICE_HETERO, ov::device::priorities(target_device))); - ASSERT_LT(0, res.size()); -} - -TEST_P(OVClassNetworkTestP, QueryNetworkMultiNoThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_NO_THROW(ie.query_model(actualNetwork, ov::test::utils::DEVICE_MULTI)); -} - -TEST(OVClassBasicTest, smoke_GetMetricSupportedMetricsHeteroNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::string target_device = ov::test::utils::DEVICE_HETERO; - - std::vector t; - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::supported_properties)); - - std::cout << "Supported HETERO properties: " << std::endl; - for (auto&& str : t) { - std::cout << str << " is_mutable: " << str.is_mutable() << std::endl; - } - - OV_ASSERT_PROPERTY_SUPPORTED(ov::supported_properties); -} - -TEST_P(OVClassBasicTestP, smoke_GetMetricSupportedConfigKeysHeteroThrows) { - ov::Core ie = createCoreWithTemplate(); - // TODO: check - std::string real_target_device = ov::test::utils::DEVICE_HETERO + std::string(":") + target_device; - ASSERT_THROW(ie.get_property(real_target_device, ov::supported_properties), ov::Exception); -} - -TEST_P(OVClassGetMetricTest_SUPPORTED_METRICS, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::supported_properties)); - - std::cout << "Supported properties: " << std::endl; - for (auto&& str : t) { - std::cout << str << " is_mutable: " << str.is_mutable() << std::endl; - } - - OV_ASSERT_PROPERTY_SUPPORTED(ov::supported_properties); -} - -TEST_P(OVClassGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::supported_properties)); - - std::cout << "Supported config values: " << std::endl; - for (auto&& str : t) { - std::cout << str << " is_mutable: " << str.is_mutable() << std::endl; - } - - OV_ASSERT_PROPERTY_SUPPORTED(ov::supported_properties); -} - -TEST_P(OVClassGetMetricTest_AVAILABLE_DEVICES, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::available_devices)); - - std::cout << "Available devices: " << std::endl; - for (auto&& str : t) { - std::cout << str << std::endl; - } - - OV_ASSERT_PROPERTY_SUPPORTED(ov::available_devices); -} - -TEST_P(OVClassGetMetricTest_FULL_DEVICE_NAME, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::string t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::full_name)); - std::cout << "Full device name: " << std::endl << t << std::endl; - - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::full_name); -} - -TEST_P(OVClassGetMetricTest_FULL_DEVICE_NAME_with_DEVICE_ID, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::string t; - - if (supportsDeviceID(ie, target_device)) { - auto device_ids = ie.get_property(target_device, ov::available_devices); - ASSERT_GT(device_ids.size(), 0); - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::full_name, ov::device::id(device_ids.front()))); - std::cout << "Device " << device_ids.front() << " " << ", Full device name: " << std::endl << t << std::endl; - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::full_name); - } else { - GTEST_FAIL() << "Device id is not supported"; - } -} - -TEST_P(OVClassGetMetricTest_DEVICE_UUID, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - ov::device::UUID t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::uuid)); - std::cout << "Device uuid: " << std::endl << t << std::endl; - - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::uuid); -} - -TEST_P(OVClassGetMetricTest_DEVICE_LUID, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - ov::device::LUID t; - - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::luid)); - std::cout << "Device luid: " << std::endl << t << std::endl; - - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::luid); -} - -TEST_P(OVClassGetMetricTest_OPTIMIZATION_CAPABILITIES, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector t; - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::capabilities)); - std::cout << "Optimization capabilities: " << std::endl; - for (auto&& str : t) { - std::cout << str << std::endl; - } - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::capabilities); -} - -TEST_P(OVClassGetMetricTest_MAX_BATCH_SIZE, GetMetricAndPrintNoThrow) { - ov::Core ie; - uint32_t max_batch_size = 0; - - ASSERT_NO_THROW(max_batch_size = ie.get_property(target_device, ov::max_batch_size)); - - std::cout << "Max batch size: " << max_batch_size << std::endl; - - OV_ASSERT_PROPERTY_SUPPORTED(ov::max_batch_size); -} - -TEST_P(OVClassGetMetricTest_DEVICE_GOPS, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::cout << "Device GOPS: " << std::endl; - for (auto&& kv : ie.get_property(target_device, ov::device::gops)) { - std::cout << kv.first << ": " << kv.second << std::endl; - } - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::gops); -} - -TEST_P(OVClassGetMetricTest_DEVICE_TYPE, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_PROPERTY_SUPPORTED(ov::device::type); - ov::device::Type t = {}; - OV_ASSERT_NO_THROW(t = ie.get_property(target_device, ov::device::type)); - std::cout << "Device Type: " << t << std::endl; -} - -TEST_P(OVClassGetMetricTest_RANGE_FOR_ASYNC_INFER_REQUESTS, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - unsigned int start{0}, end{0}, step{0}; - - ASSERT_NO_THROW(std::tie(start, end, step) = ie.get_property(target_device, ov::range_for_async_infer_requests)); - - std::cout << "Range for async infer requests: " << std::endl - << start << std::endl - << end << std::endl - << step << std::endl - << std::endl; - - ASSERT_LE(start, end); - ASSERT_GE(step, 1u); - OV_ASSERT_PROPERTY_SUPPORTED(ov::range_for_async_infer_requests); -} - -TEST_P(OVClassGetMetricTest_RANGE_FOR_STREAMS, GetMetricAndPrintNoThrow) { - ov::Core ie = createCoreWithTemplate(); - unsigned int start = 0, end = 0; - - ASSERT_NO_THROW(std::tie(start, end) = ie.get_property(target_device, ov::range_for_streams)); - - std::cout << "Range for streams: " << std::endl - << start << std::endl - << end << std::endl - << std::endl; - - ASSERT_LE(start, end); - OV_ASSERT_PROPERTY_SUPPORTED(ov::range_for_streams); -} - -TEST_P(OVClassGetMetricTest_ThrowUnsupported, GetMetricThrow) { - ov::Core ie = createCoreWithTemplate(); - - ASSERT_THROW(ie.get_property(target_device, "unsupported_metric"), ov::Exception); -} - -TEST_P(OVClassGetConfigTest, GetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector configValues; - - OV_ASSERT_NO_THROW(configValues = ie.get_property(target_device, ov::supported_properties)); - - for (auto&& confKey : configValues) { - ov::Any defaultValue; - OV_ASSERT_NO_THROW(defaultValue = ie.get_property(target_device, confKey)); - ASSERT_FALSE(defaultValue.empty()); - } -} - -TEST_P(OVClassGetConfigTest, GetConfigHeteroNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector configValues; - OV_ASSERT_NO_THROW(configValues = ie.get_property(target_device, ov::supported_properties)); - - for (auto&& confKey : configValues) { - OV_ASSERT_NO_THROW(ie.get_property(target_device, confKey)); - } -} - -TEST_P(OVClassGetConfigTest_ThrowUnsupported, GetConfigHeteroThrow) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.get_property(ov::test::utils::DEVICE_HETERO, "unsupported_config"), ov::Exception); -} - -TEST_P(OVClassGetConfigTest_ThrowUnsupported, GetConfigHeteroWithDeviceThrow) { - ov::Core ie = createCoreWithTemplate(); - - ASSERT_THROW(ie.get_property(ov::test::utils::DEVICE_HETERO + std::string(":") + target_device, - ov::device::priorities), - ov::Exception); -} - -TEST_P(OVClassGetConfigTest_ThrowUnsupported, GetConfigThrow) { - ov::Core ie = createCoreWithTemplate(); - - ASSERT_THROW(ie.get_property(target_device, "unsupported_config"), ov::Exception); -} - -TEST_P(OVClassSpecificDeviceTestGetConfig, GetConfigSpecificDeviceNoThrow) { - ov::Core ie = createCoreWithTemplate(); - ov::Any p; - - std::string deviceID, clear_target_device; - auto pos = target_device.find('.'); - if (pos != std::string::npos) { - clear_target_device = target_device.substr(0, pos); - deviceID = target_device.substr(pos + 1, target_device.size()); - } - if (!supportsDeviceID(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } - if (!supportsAvailableDevices(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support AvailableDevices property" << std::endl; - } - auto deviceIDs = ie.get_property(clear_target_device, ov::available_devices); - if (std::find(deviceIDs.begin(), deviceIDs.end(), deviceID) == deviceIDs.end()) { - GTEST_FAIL() << "No DeviceID" << std::endl; - } - - std::vector configValues; - OV_ASSERT_NO_THROW(configValues = ie.get_property(target_device, ov::supported_properties)); - - for (auto &&confKey : configValues) { - ov::Any defaultValue; - OV_ASSERT_NO_THROW(defaultValue = ie.get_property(target_device, confKey)); - ASSERT_FALSE(defaultValue.empty()); - } -} - -TEST_P(OVClassGetAvailableDevices, GetAvailableDevicesNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector devices; - - OV_ASSERT_NO_THROW(devices = ie.get_available_devices()); - - bool deviceFound = false; - std::cout << "Available devices: " << std::endl; - for (auto&& device : devices) { - if (device.find(target_device) != std::string::npos) { - deviceFound = true; - } - - std::cout << device << " "; - } - std::cout << std::endl; - - ASSERT_TRUE(deviceFound); -} - -// -// QueryNetwork with HETERO on particular device -// -TEST_P(OVClassQueryNetworkTest, QueryNetworkHETEROWithDeviceIDNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - auto deviceIDs = ie.get_property(target_device, ov::available_devices); - if (deviceIDs.empty()) - GTEST_FAIL(); - ie.query_model(actualNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::priorities(target_device + "." + deviceIDs[0], target_device)); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassQueryNetworkTest, QueryNetworkWithDeviceID) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - auto deviceIDs = ie.get_property(target_device, ov::available_devices); - if (deviceIDs.empty()) - GTEST_FAIL(); - ie.query_model(simpleNetwork, target_device + "." + deviceIDs[0]); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassQueryNetworkTest, QueryNetworkWithBigDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.query_model(actualNetwork, target_device + ".110"), ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassQueryNetworkTest, QueryNetworkWithInvalidDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.query_model(actualNetwork, target_device + ".l0"), ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassQueryNetworkTest, QueryNetworkHETEROWithBigDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.query_model(actualNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::priorities(target_device + ".100", target_device)), - ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -using OVClassNetworkTestP = OVClassBaseTestP; - -// -// LoadNetwork -// - -TEST_P(OVClassNetworkTestP, LoadNetworkActualNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, target_device)); -} - -TEST_P(OVClassNetworkTestP, LoadNetworkMultiWithoutSettingDevicePrioritiesThrows) { - ov::Core ie = createCoreWithTemplate(); - try { - ie.compile_model(actualNetwork, ov::test::utils::DEVICE_MULTI); - } catch (ov::Exception& error) { - EXPECT_PRED_FORMAT2(testing::IsSubstring, - std::string("KEY_MULTI_DEVICE_PRIORITIES key is not set for"), - error.what()); - } catch (...) { - FAIL() << "compile_model is failed for unexpected reason."; - } -} - -TEST_P(OVClassNetworkTestP, LoadNetworkActualHeteroDeviceNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, ov::test::utils::DEVICE_HETERO + std::string(":") + target_device)); -} - -TEST_P(OVClassNetworkTestP, LoadNetworkActualHeteroDevice2NoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, ov::test::utils::DEVICE_HETERO, ov::device::priorities(target_device))); -} - -TEST_P(OVClassNetworkTestP, LoadNetworkActualHeteroDeviceUsingDevicePropertiesNoThrow) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::priorities(target_device), - ov::device::properties(target_device, - ov::enable_profiling(true)))); -} - -TEST_P(OVClassNetworkTestP, LoadNetworkCreateDefaultExecGraphResult) { - auto ie = createCoreWithTemplate(); - auto net = ie.compile_model(actualNetwork, target_device); - auto runtime_function = net.get_runtime_model(); - ASSERT_NE(nullptr, runtime_function); - auto actual_parameters = runtime_function->get_parameters(); - auto actual_results = runtime_function->get_results(); - auto expected_parameters = actualNetwork->get_parameters(); - auto expected_results = actualNetwork->get_results(); - ASSERT_EQ(expected_parameters.size(), actual_parameters.size()); - for (std::size_t i = 0; i < expected_parameters.size(); ++i) { - auto expected_element_type = expected_parameters[i]->get_output_element_type(0); - auto actual_element_type = actual_parameters[i]->get_output_element_type(0); - ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i; - auto expected_shape = expected_parameters[i]->get_output_shape(0); - auto actual_shape = actual_parameters[i]->get_output_shape(0); - ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i; - } - ASSERT_EQ(expected_results.size(), actual_results.size()); - for (std::size_t i = 0; i < expected_results.size(); ++i) { - auto expected_element_type = expected_results[i]->get_input_element_type(0); - auto actual_element_type = actual_results[i]->get_input_element_type(0); - ASSERT_EQ(expected_element_type, actual_element_type) << "For index: " << i; - auto expected_shape = expected_results[i]->get_input_shape(0); - auto actual_shape = actual_results[i]->get_input_shape(0); - ASSERT_EQ(expected_shape, actual_shape) << "For index: " << i; - } -} - -TEST_P(OVClassSeveralDevicesTestLoadNetwork, LoadNetworkActualSeveralDevicesNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - std::string clear_target_device; - auto pos = target_devices.begin()->find('.'); - if (pos != std::string::npos) { - clear_target_device = target_devices.begin()->substr(0, pos); - } - if (!supportsAvailableDevices(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support AvailableDevices property" << std::endl; - } - auto deviceIDs = ie.get_property(clear_target_device, ov::available_devices); - if (deviceIDs.size() < target_devices.size()) - GTEST_FAIL() << "Incorrect DeviceID" << std::endl; - - std::string multitarget_device = ov::test::utils::DEVICE_MULTI + std::string(":"); - for (auto& dev_name : target_devices) { - multitarget_device += dev_name; - if (&dev_name != &(target_devices.back())) { - multitarget_device += ","; - } - } - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, multitarget_device)); -} - -// -// LoadNetwork with null device & throw -// -TEST_P(OVClassLoadNetworkTestWithThrow, LoadNetworkActualWithThrow) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.compile_model(actualNetwork, target_device), ov::Exception); -} - -// -// LoadNetwork with HETERO on particular device -// -TEST_P(OVClassLoadNetworkTest, LoadNetworkHETEROWithDeviceIDNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - 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)); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkWithDeviceIDNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - auto deviceIDs = ie.get_property(target_device, ov::available_devices); - if (deviceIDs.empty()) - GTEST_FAIL(); - OV_ASSERT_NO_THROW(ie.compile_model(simpleNetwork, target_device + "." + deviceIDs[0])); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkWithBigDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.compile_model(actualNetwork, target_device + ".10"), ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkWithCondidateDeviceListContainedMetaPluginTest, LoadNetworkRepeatedlyWithMetaPluginTestThrow) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.compile_model(actualNetwork, target_device, configuration), ov::Exception); -} - -TEST_P(OVClassLoadNetworkWithCorrectPropertiesTest, LoadNetworkWithCorrectPropertiesTest) { - ov::Core ie = createCoreWithTemplate(); - OV_ASSERT_NO_THROW(ie.compile_model(actualNetwork, target_device, configuration)); -} - -TEST_P(OVClassLoadNetworkAndCheckSecondaryPropertiesTest, LoadNetworkAndCheckSecondaryPropertiesTest) { - ov::Core ie = createCoreWithTemplate(); - ov::CompiledModel model; - OV_ASSERT_NO_THROW(model = ie.compile_model(actualNetwork, target_device, configuration)); - ov::AnyMap property = configuration; - ov::AnyMap::iterator it = configuration.end(); - // device properties in form ov::device::properties(DEVICE, ...) has the first priority - for (it = configuration.begin(); it != configuration.end(); it++) { - if ((it->first.find(ov::device::properties.name()) != std::string::npos) && - (it->first != ov::device::properties.name())) { - break; - } - } - if (it != configuration.end()) { - // DEVICE_PROPERTIES_ found - property = it->second.as(); - } else { - // search for DEVICE_PROPERTIES - it = configuration.find(ov::device::properties.name()); - ASSERT_TRUE(it != configuration.end()); - property = it->second.as().begin()->second.as(); - if (it == configuration.end()) { - it = configuration.find(ov::num_streams.name()); - } - } - ASSERT_TRUE(property.count(ov::num_streams.name())); - auto actual = property.at(ov::num_streams.name()).as(); - ov::Any value; - //AutoExcutableNetwork GetMetric() does not support key ov::num_streams - OV_ASSERT_NO_THROW(value = model.get_property(ov::num_streams.name())); - int32_t expect = value.as(); - ASSERT_EQ(actual, expect); -} - -TEST_P(OVClassLoadNetWorkReturnDefaultHintTest, LoadNetworkReturnDefaultHintTest) { - ov::Core ie = createCoreWithTemplate(); - ov::CompiledModel model; - ov::hint::PerformanceMode value; - OV_ASSERT_NO_THROW(model = ie.compile_model(actualNetwork, target_device, configuration)); - OV_ASSERT_NO_THROW(value = model.get_property(ov::hint::performance_mode)); - if (target_device.find("AUTO") != std::string::npos) { - ASSERT_EQ(value, ov::hint::PerformanceMode::LATENCY); - } else { - ASSERT_EQ(value, ov::hint::PerformanceMode::THROUGHPUT); - } -} - -TEST_P(OVClassLoadNetWorkDoNotReturnDefaultHintTest, LoadNetworkDoNotReturnDefaultHintTest) { - ov::Core ie = createCoreWithTemplate(); - ov::CompiledModel model; - ov::hint::PerformanceMode value; - OV_ASSERT_NO_THROW(model = ie.compile_model(actualNetwork, target_device, configuration)); - OV_ASSERT_NO_THROW(value = model.get_property(ov::hint::performance_mode)); - if (target_device.find("AUTO") != std::string::npos) { - ASSERT_NE(value, ov::hint::PerformanceMode::LATENCY); - } else { - ASSERT_EQ(value, ov::hint::PerformanceMode::THROUGHPUT); - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkWithInvalidDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.compile_model(actualNetwork, target_device + ".l0"), ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkHETEROWithBigDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.compile_model(actualNetwork, - "HETERO", - ov::device::priorities(target_device + ".100", ov::test::utils::DEVICE_CPU)), - ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkHETEROAndDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device)) { - ASSERT_THROW(ie.compile_model(actualNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::priorities(target_device, ov::test::utils::DEVICE_CPU), - ov::device::id("110")), - ov::Exception); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -// -// LoadNetwork with HETERO on MULTI combinations particular device -// - -TEST_P(OVClassLoadNetworkTest, LoadNetworkHETEROwithMULTINoThrow) { - ov::Core ie = createCoreWithTemplate(); - if (supportsDeviceID(ie, target_device) && supportsAvailableDevices(ie, target_device)) { - std::string devices; - auto availableDevices = ie.get_property(target_device, ov::available_devices); - for (auto&& device : availableDevices) { - devices += target_device + '.' + device; - if (&device != &(availableDevices.back())) { - devices += ','; - } - } - ie.compile_model(actualNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::properties(ov::test::utils::DEVICE_MULTI, - ov::device::priorities(devices)), - ov::device::properties(ov::test::utils::DEVICE_HETERO, - ov::device::priorities(ov::test::utils::DEVICE_MULTI, target_device))); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, LoadNetworkMULTIwithHETERONoThrow) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device) && supportsAvailableDevices(ie, target_device)) { - std::string hetero_devices; - auto device_ids = ie.get_property(target_device, ov::available_devices); - for (auto&& device_id : device_ids) { - hetero_devices += target_device + std::string(".") + device_id; - if (&device_id != &device_ids.back()) - hetero_devices += ','; - } - OV_ASSERT_NO_THROW(ie.compile_model( - actualNetwork, - ov::test::utils::DEVICE_MULTI, - ov::device::properties(ov::test::utils::DEVICE_MULTI, ov::device::priorities(ov::test::utils::DEVICE_HETERO)), - ov::device::properties(ov::test::utils::DEVICE_HETERO, ov::device::priorities(hetero_devices)))); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -// -// QueryNetwork with HETERO on MULTI combinations particular device -// - -TEST_P(OVClassLoadNetworkTest, QueryNetworkHETEROWithMULTINoThrow_V10) { - ov::Core ie = createCoreWithTemplate(); - - if (supportsDeviceID(ie, target_device) && supportsAvailableDevices(ie, target_device)) { - std::string devices; - auto availableDevices = ie.get_property(target_device, ov::available_devices); - for (auto&& device : availableDevices) { - devices += target_device + '.' + device; - if (&device != &(availableDevices.back())) { - devices += ','; - } - } - auto function = multinputNetwork; - ASSERT_NE(nullptr, function); - std::unordered_set expectedLayers; - for (auto&& node : function->get_ops()) { - expectedLayers.emplace(node->get_friendly_name()); - } - ov::SupportedOpsMap result; - std::string hetero_device_priorities(ov::test::utils::DEVICE_MULTI + std::string(",") + target_device); - OV_ASSERT_NO_THROW(result = ie.query_model( - multinputNetwork, - ov::test::utils::DEVICE_HETERO, - ov::device::properties(ov::test::utils::DEVICE_MULTI, - ov::device::priorities(devices)), - ov::device::properties(ov::test::utils::DEVICE_HETERO, - ov::device::priorities(ov::test::utils::DEVICE_MULTI, - target_device)))); - - std::unordered_set actualLayers; - for (auto&& layer : result) { - actualLayers.emplace(layer.first); - } - ASSERT_EQ(expectedLayers, actualLayers); - } else { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } -} - -TEST_P(OVClassLoadNetworkTest, QueryNetworkMULTIWithHETERONoThrow_V10) { - ov::Core ie = createCoreWithTemplate(); - - if (!supportsDeviceID(ie, target_device)) { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } - if (!supportsAvailableDevices(ie, target_device)) { - GTEST_FAIL() << "Device does not support AvailableDevices property" << std::endl; - } - std::string devices; - auto device_ids = ie.get_property(target_device, ov::available_devices); - for (auto&& device_id : device_ids) { - devices += target_device + "." + device_id; - if (&device_id != &(device_ids.back())) { - devices += ','; - } - } - auto function = multinputNetwork; - ASSERT_NE(nullptr, function); - std::unordered_set expectedLayers; - for (auto&& node : function->get_ops()) { - expectedLayers.emplace(node->get_friendly_name()); - } - ov::SupportedOpsMap result; - OV_ASSERT_NO_THROW(result = ie.query_model(multinputNetwork, - ov::test::utils::DEVICE_MULTI, - ov::device::properties(ov::test::utils::DEVICE_MULTI, - ov::device::priorities(ov::test::utils::DEVICE_HETERO)), - ov::device::properties(ov::test::utils::DEVICE_HETERO, - ov::device::priorities(devices)))); - - std::unordered_set actualLayers; - for (auto&& layer : result) { - actualLayers.emplace(layer.first); - } - ASSERT_EQ(expectedLayers, actualLayers); -} - -TEST_P(OVClassSetDefaultDeviceIDTest, SetDefaultDeviceIDNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto deviceIDs = ie.get_property(target_device, ov::available_devices); - if (std::find(deviceIDs.begin(), deviceIDs.end(), deviceID) == deviceIDs.end()) { - GTEST_FAIL(); - } - std::string value; - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::device::id(deviceID), ov::enable_profiling(true))); - ASSERT_TRUE(ie.get_property(target_device, ov::enable_profiling)); - OV_ASSERT_NO_THROW(value = ie.get_property(target_device, ov::enable_profiling.name()).as()); - ASSERT_EQ(value, "YES"); -} - -TEST_P(OVClassSetGlobalConfigTest, SetGlobalConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto deviceIDs = ie.get_property(target_device, ov::available_devices); - ov::Any ref, src; - for (auto& dev_id : deviceIDs) { - OV_ASSERT_NO_THROW(ie.set_property(target_device + "." + dev_id, ov::enable_profiling(false))); - } - OV_ASSERT_NO_THROW(ie.set_property(target_device, ov::enable_profiling(true))); - OV_ASSERT_NO_THROW(ref = ie.get_property(target_device, ov::enable_profiling.name())); - - for (auto& dev_id : deviceIDs) { - OV_ASSERT_NO_THROW(src = ie.get_property(target_device + "." + dev_id, ov::enable_profiling.name())); - ASSERT_EQ(src, ref); - } -} - -TEST_P(OVClassSeveralDevicesTestDefaultCore, DefaultCoreSeveralDevicesNoThrow) { - ov::Core ie; - - std::string clear_target_device; - auto pos = target_devices.begin()->find('.'); - if (pos != std::string::npos) { - clear_target_device = target_devices.begin()->substr(0, pos); - } - if (!supportsDeviceID(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support DeviceID property" << std::endl; - } - if (!supportsAvailableDevices(ie, clear_target_device)) { - GTEST_FAIL() << "Device does not support AvailableDevices property" << std::endl; - } - auto deviceIDs = ie.get_property(clear_target_device, ov::available_devices); - if (deviceIDs.size() < target_devices.size()) - GTEST_FAIL() << "Incorrect Device ID" << std::endl; - - for (size_t i = 0; i < target_devices.size(); ++i) { - OV_ASSERT_NO_THROW(ie.set_property(target_devices[i], ov::enable_profiling(true))); - } - bool res; - for (size_t i = 0; i < target_devices.size(); ++i) { - OV_ASSERT_NO_THROW(res = ie.get_property(target_devices[i], ov::enable_profiling)); - ASSERT_TRUE(res); - } -} - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration_sw.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration_sw.hpp index 13c66680ad6e2c..d45b14ed80ea85 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration_sw.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_plugin/core_integration_sw.hpp @@ -27,6 +27,7 @@ class OVClassSeveralDevicesTests : public OVPluginTestBase, using OVClassSeveralDevicesTestCompileModel = OVClassSeveralDevicesTests; using OVClassSeveralDevicesTestQueryModel = OVClassSeveralDevicesTests; +using OVClassSeveralDevicesTestDefaultCore = OVClassSeveralDevicesTests; using OVClassCompileModelWithCondidateDeviceListContainedMetaPluginTest = OVClassSetDevicePriorityConfigPropsTest; TEST_P(OVClassCompileModelWithCondidateDeviceListContainedMetaPluginTest, @@ -125,6 +126,28 @@ TEST_P(OVClassSeveralDevicesTestQueryModel, QueryModelActualSeveralDevicesNoThro OV_ASSERT_NO_THROW(ie.query_model(actualNetwork, multi_target_device)); } +TEST_P(OVClassSeveralDevicesTestDefaultCore, DefaultCoreSeveralDevicesNoThrow) { + ov::Core ie; + + std::string clear_target_device; + auto pos = target_devices.begin()->find('.'); + if (pos != std::string::npos) { + clear_target_device = target_devices.begin()->substr(0, pos); + } + auto deviceIDs = ie.get_property(clear_target_device, ov::available_devices); + if (deviceIDs.size() < target_devices.size()) + GTEST_FAIL() << "Incorrect Device ID" << std::endl; + + for (size_t i = 0; i < target_devices.size(); ++i) { + OV_ASSERT_NO_THROW(ie.set_property(target_devices[i], ov::enable_profiling(true))); + } + bool res; + for (size_t i = 0; i < target_devices.size(); ++i) { + OV_ASSERT_NO_THROW(res = ie.get_property(target_devices[i], ov::enable_profiling)); + ASSERT_TRUE(res); + } +} + TEST(OVClassBasicPropsTest, smoke_SetConfigHeteroThrows) { ov::Core core; OV_ASSERT_NO_THROW(core.set_property(ov::test::utils::DEVICE_HETERO, ov::enable_profiling(true))); diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/exec_graph_info.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/exec_graph_info.cpp deleted file mode 100644 index 4c4a6e94d5140e..00000000000000 --- a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/exec_graph_info.cpp +++ /dev/null @@ -1,789 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifcorer: Apache-2.0 -// - -#include "behavior/ov_executable_network/exec_graph_info.hpp" - -#include "common_test_utils/ov_test_utils.hpp" -#include "common_test_utils/common_utils.hpp" -#include "common_test_utils/file_utils.hpp" - -#include "common_test_utils/subgraph_builders/multiple_input_outpput_double_concat.hpp" -#include "openvino/pass/serialize.hpp" - -namespace ov { -namespace test { -namespace behavior { - -std::string OVExecGraphImportExportTest::getTestCaseName(testing::TestParamInfo obj) { - ov::element::Type_t elementType; - std::string targetDevice; - ov::AnyMap configuration; - std::tie(elementType, targetDevice, configuration) = obj.param; - std::replace(targetDevice.begin(), targetDevice.end(), ':', '.'); - std::ostringstream result; - result << "targetDevice=" << targetDevice << "_"; - result << "elementType=" << elementType << "_"; - if (!configuration.empty()) { - result << "config=("; - for (const auto& config : configuration) { - result << config.first << "="; - config.second.print(result); - result << "_"; - } - result << ")"; - } - return result.str(); -} - -void OVExecGraphImportExportTest::SetUp() { - std::tie(elementType, target_device, configuration) = this->GetParam(); - // Skip test according to plugin specific disabledTestPatterns() (if any) - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); -} - -void OVExecGraphImportExportTest::TearDown() { - if (!configuration.empty()) { - utils::PluginCache::get().reset(); - } - APIBaseTest::TearDown(); -} - -TEST_P(OVExecGraphImportExportTest, importExportedFunction) { - if (target_device == ov::test::utils::DEVICE_MULTI || target_device == ov::test::utils::DEVICE_AUTO) { - GTEST_SKIP() << "MULTI / AUTO does not support import / export" << std::endl; - } - - ov::CompiledModel execNet; - // Create simple function - function = ov::test::utils::make_multiple_input_output_double_concat({1, 2, 24, 24}, elementType); - execNet = core->compile_model(function, target_device, configuration); - - std::stringstream strm; - execNet.export_model(strm); - - ov::CompiledModel importedExecNet = core->import_model(strm, target_device, configuration); - EXPECT_EQ(function->inputs().size(), 2); - EXPECT_EQ(function->inputs().size(), importedExecNet.inputs().size()); - EXPECT_THROW(importedExecNet.input(), ov::Exception); - EXPECT_EQ(function->input(0).get_tensor().get_names(), importedExecNet.input(0).get_tensor().get_names()); - EXPECT_EQ(function->input(0).get_tensor().get_partial_shape(), - importedExecNet.input(0).get_tensor().get_partial_shape()); - EXPECT_EQ(function->input(0).get_tensor().get_element_type(), - importedExecNet.input(0).get_tensor().get_element_type()); - EXPECT_EQ(function->input(0).get_element_type(), - importedExecNet.input(0).get_tensor().get_element_type()); - EXPECT_EQ(function->input(1).get_tensor().get_names(), importedExecNet.input(1).get_tensor().get_names()); - EXPECT_EQ(function->input(1).get_tensor().get_partial_shape(), - importedExecNet.input(1).get_tensor().get_partial_shape()); - EXPECT_EQ(function->input(1).get_tensor().get_element_type(), - importedExecNet.input(1).get_tensor().get_element_type()); - EXPECT_EQ(function->input(1).get_element_type(), - importedExecNet.input(1).get_tensor().get_element_type()); - EXPECT_EQ(importedExecNet.input(0).get_node(), importedExecNet.input("data1").get_node()); - EXPECT_NE(importedExecNet.input(1).get_node(), importedExecNet.input("data1").get_node()); - EXPECT_EQ(importedExecNet.input(1).get_node(), importedExecNet.input("data2").get_node()); - EXPECT_NE(importedExecNet.input(0).get_node(), importedExecNet.input("data2").get_node()); - EXPECT_EQ(function->outputs().size(), 2); - EXPECT_EQ(function->outputs().size(), importedExecNet.outputs().size()); - EXPECT_THROW(importedExecNet.output(), ov::Exception); - EXPECT_EQ(function->output(0).get_tensor().get_names(), importedExecNet.output(0).get_tensor().get_names()); - EXPECT_EQ(function->output(0).get_tensor().get_partial_shape(), - importedExecNet.output(0).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(0).get_tensor().get_element_type(), - importedExecNet.output(0).get_tensor().get_element_type()); - EXPECT_EQ(function->output(0).get_element_type(), - importedExecNet.output(0).get_tensor().get_element_type()); - EXPECT_EQ(function->output(1).get_tensor().get_names(), importedExecNet.output(1).get_tensor().get_names()); - EXPECT_EQ(function->output(1).get_tensor().get_partial_shape(), - importedExecNet.output(1).get_tensor().get_partial_shape()); - EXPECT_EQ(function->output(1).get_tensor().get_element_type(), - importedExecNet.output(1).get_tensor().get_element_type()); - EXPECT_EQ(function->output(1).get_element_type(), - importedExecNet.output(1).get_tensor().get_element_type()); - EXPECT_EQ(importedExecNet.output(0).get_node(), importedExecNet.output("concat1").get_node()); - EXPECT_NE(importedExecNet.output(1).get_node(), importedExecNet.output("concat1").get_node()); - EXPECT_EQ(importedExecNet.output(1).get_node(), importedExecNet.output("concat2").get_node()); - EXPECT_NE(importedExecNet.output(0).get_node(), importedExecNet.output("concat2").get_node()); - EXPECT_THROW(importedExecNet.input("param1"), ov::Exception); - EXPECT_THROW(importedExecNet.input("param2"), ov::Exception); - EXPECT_THROW(importedExecNet.output("result1"), ov::Exception); - EXPECT_THROW(importedExecNet.output("result2"), ov::Exception); -} - -TEST_P(OVExecGraphImportExportTest, importExportedFunctionParameterResultOnly) { - if (target_device == ov::test::utils::DEVICE_MULTI || target_device == ov::test::utils::DEVICE_AUTO) { - GTEST_SKIP() << "MULTI / AUTO does not support import / export" << std::endl; - } - - // Create a simple function - { - auto param = std::make_shared(elementType, ov::Shape({1, 3, 24, 24})); - param->set_friendly_name("param"); - param->output(0).get_tensor().set_names({"data"}); - auto result = std::make_shared(param); - result->set_friendly_name("result"); - function = std::make_shared(ov::ResultVector{result}, - ov::ParameterVector{param}); - function->set_friendly_name("ParamResult"); - } - - auto execNet = core->compile_model(function, target_device, configuration); - std::stringstream strm; - execNet.export_model(strm); - - ov::CompiledModel importedCompiledModel = core->import_model(strm, target_device, configuration); - EXPECT_EQ(function->inputs().size(), 1); - EXPECT_EQ(function->inputs().size(), importedCompiledModel.inputs().size()); - EXPECT_NO_THROW(importedCompiledModel.input()); - EXPECT_NO_THROW(importedCompiledModel.input("data").get_node()); - EXPECT_THROW(importedCompiledModel.input("param"), ov::Exception); - - EXPECT_EQ(function->outputs().size(), 1); - EXPECT_EQ(function->outputs().size(), importedCompiledModel.outputs().size()); - EXPECT_NO_THROW(importedCompiledModel.output()); - EXPECT_EQ(function->output(0).get_tensor().get_names(), - importedCompiledModel.output(0).get_tensor().get_names()); - EXPECT_NO_THROW(importedCompiledModel.output("data").get_node()); - EXPECT_THROW(importedCompiledModel.output("param"), ov::Exception); - - EXPECT_EQ(ov::element::Type(elementType), importedCompiledModel.input("data").get_element_type()); - EXPECT_EQ(ov::element::Type(elementType), importedCompiledModel.output("data").get_element_type()); -} - -TEST_P(OVExecGraphImportExportTest, importExportedFunctionConstantResultOnly) { - if (target_device == ov::test::utils::DEVICE_MULTI || target_device == ov::test::utils::DEVICE_AUTO) { - GTEST_SKIP() << "MULTI / AUTO does not support import / export" << std::endl; - } - - // Create a simple function - { - auto constant = std::make_shared(elementType, ov::Shape({1, 3, 24, 24})); - constant->set_friendly_name("constant"); - constant->output(0).get_tensor().set_names({"data"}); - auto result = std::make_shared(constant); - result->set_friendly_name("result"); - function = std::make_shared(ov::ResultVector{result}, - ov::ParameterVector{}); - function->set_friendly_name("ConstResult"); - } - - auto execNet = core->compile_model(function, target_device, configuration); - std::stringstream strm; - execNet.export_model(strm); - - ov::CompiledModel importedCompiledModel = core->import_model(strm, target_device, configuration); - EXPECT_EQ(function->inputs().size(), 0); - EXPECT_EQ(function->inputs().size(), importedCompiledModel.inputs().size()); - EXPECT_THROW(importedCompiledModel.input(), ov::Exception); - EXPECT_THROW(importedCompiledModel.input("data"), ov::Exception); - EXPECT_THROW(importedCompiledModel.input("constant"), ov::Exception); - - EXPECT_EQ(function->outputs().size(), 1); - EXPECT_EQ(function->outputs().size(), importedCompiledModel.outputs().size()); - EXPECT_NO_THROW(importedCompiledModel.output()); - EXPECT_EQ(function->output(0).get_tensor().get_names(), - importedCompiledModel.output(0).get_tensor().get_names()); - EXPECT_NO_THROW(importedCompiledModel.output("data").get_node()); - EXPECT_THROW(importedCompiledModel.output("constant"), ov::Exception); - - EXPECT_EQ(ov::element::Type(elementType), importedCompiledModel.output("data").get_element_type()); -} - -TEST_P(OVExecGraphImportExportTest, readFromV10IR) { - std::string model = R"V0G0N( - - - - - - - 1 - 3 - 22 - 22 - - - - - - - - 1 - 3 - 22 - 22 - - - - - - - 1 - 3 - 22 - 22 - - - 1 - 3 - 22 - 22 - - - - - 1 - 6 - 22 - 22 - - - - - - - 1 - 6 - 22 - 22 - - - - - - - - - - - )V0G0N"; - function = core->read_model(model, ov::Tensor()); - EXPECT_EQ(function->inputs().size(), 2); - EXPECT_EQ(function->outputs().size(), 1); - EXPECT_NO_THROW(function->input("in1")); // remove if read_model does not change function names - EXPECT_NO_THROW(function->input("in2")); // remove if read_model does not change function names - EXPECT_NO_THROW(function->output("concat")); // remove if read_model does not change function names - - ov::CompiledModel execNet = core->compile_model(function, target_device, configuration); - EXPECT_EQ(execNet.inputs().size(), 2); - EXPECT_EQ(execNet.outputs().size(), 1); - EXPECT_NO_THROW(execNet.input("in1")); - EXPECT_NO_THROW(execNet.input("in2")); - EXPECT_NO_THROW(execNet.output("concat")); - - if (target_device == ov::test::utils::DEVICE_MULTI || target_device == ov::test::utils::DEVICE_AUTO) { - GTEST_SKIP() << "MULTI / AUTO does not support import / export" << std::endl; - } - - std::stringstream strm; - execNet.export_model(strm); - - ov::CompiledModel importedExecNet = core->import_model(strm, target_device, configuration); - EXPECT_EQ(importedExecNet.inputs().size(), 2); - EXPECT_EQ(importedExecNet.outputs().size(), 1); - EXPECT_NO_THROW(importedExecNet.input("in1")); - EXPECT_NO_THROW(importedExecNet.input("in2")); - EXPECT_NO_THROW(importedExecNet.output("concat")); - - EXPECT_EQ(importedExecNet.input("in1").get_element_type(), ov::element::f32); - EXPECT_EQ(importedExecNet.input("in2").get_element_type(), ov::element::f32); - EXPECT_EQ(importedExecNet.output().get_element_type(), ov::element::f32); -} - -static std::map any_copy(const ov::AnyMap& params) { - auto to_config_string = [] (const Any& any) -> std::string { - if (any.is()) { - return any.as() ? "YES" : "NO"; - } else { - std::stringstream strm; - any.print(strm); - return strm.str(); - } - }; - std::map result; - for (auto&& value : params) { - result.emplace(value.first, to_config_string(value.second)); - } - return result; -} - -std::string OVExecGraphUniqueNodeNames::getTestCaseName(testing::TestParamInfo obj) { - ov::element::Type type; - ov::Shape shape; - std::string device; - std::tie(type, shape, device) = obj.param; - - std::ostringstream result; - result << "IS=" << ov::test::utils::vec2str(shape) << "_"; - result << "inType=" << type.get_type_name() << "_"; - result << "targetDevice=" << device; - return result.str(); -} - -void OVExecGraphUniqueNodeNames::SetUp() { - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - ov::element::Type type; - ov::Shape shape; - std::tie(type, shape, target_device) = this->GetParam(); - - APIBaseTest::SetUp(); - - ov::ParameterVector params{std::make_shared(type, shape)}; - auto split_axis_op = std::make_shared(ov::element::i64, ov::Shape{}, std::vector{1}); - auto split = std::make_shared(params[0], split_axis_op, 2); - - auto concat = std::make_shared(split->outputs(), 1); - - ov::ResultVector results{std::make_shared(concat)}; - fnPtr = std::make_shared(results, params, "SplitConvConcat"); -} - -TEST_P(OVExecGraphUniqueNodeNames, CheckUniqueNodeNames) { - auto core = utils::PluginCache::get().core(); - auto compiled_model = core->compile_model(fnPtr, target_device); - - auto runtime_model = compiled_model.get_runtime_model(); - - std::unordered_set names; - for (auto&& op : runtime_model->get_ops()) { - ASSERT_TRUE(names.find(op->get_friendly_name()) == names.end()) << "Node with name " << op->get_friendly_name() << "already exists"; - names.insert(op->get_friendly_name()); - } -}; - - - - -const char serialize_test_model[] = R"V0G0N( - - - - - - - - 1 - - - - - - - - 1 - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - - 1 - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - 1 - - - - - - - - - - - - - - - - - - -)V0G0N"; - -const char expected_serialized_model[] = R"V0G0N( - - - - - - - - 1 - - - - - - - - 1 - - - - - - - - 1 - - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - - - - - - 1 - - - 1 - - - - - 1 - - - - - - - - 1 - - - - - - - - - - - - - - - - -)V0G0N"; - -const char expected_serialized_model_cpu[] = R"V0G0N( - - - - - - - - 1 - - - - - - - - 1 - - - - - - - - 1 - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - - - - - - 1 - - - - - - - - - - - - - -)V0G0N"; - - -std::string OVExecGraphSerializationTest::getTestCaseName(testing::TestParamInfo obj) { - std::ostringstream result; - std::string target_device = obj.param; - std::replace(target_device.begin(), target_device.end(), ':', '.'); - result << "TargetDevice=" << target_device; - return result.str(); -} - -void OVExecGraphSerializationTest::SetUp() { - target_device = this->GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED() - APIBaseTest::SetUp(); - - const std::string XML_EXT = ".xml"; - const std::string BIN_EXT = ".bin"; - - std::string filePrefix = ov::test::utils::generateTestFilePrefix(); - - m_out_xml_path = filePrefix + XML_EXT; - m_out_bin_path = filePrefix + BIN_EXT; -} - -void OVExecGraphSerializationTest::TearDown() { - APIBaseTest::TearDown(); - ov::test::utils::removeIRFiles(m_out_xml_path, m_out_bin_path); -} - -bool OVExecGraphSerializationTest::exec_graph_walker::for_each(pugi::xml_node &node) { - std::string node_name{node.name()}; - if (node_name == "layer" || node_name == "data") { - nodes.push_back(node); - } - return true; // continue traversal -} - -std::pair OVExecGraphSerializationTest::compare_nodes(const pugi::xml_node &node1, - const pugi::xml_node &node2) { - // node names must be the same - const std::string node1_name{node1.name()}; - const std::string node2_name{node2.name()}; - if (node1_name != node2_name) { - return {false, "Node name is different: " + node1_name + " != " + node2_name}; - } - - // node attribute count must be the same - const auto attr1 = node1.attributes(); - const auto attr2 = node2.attributes(); - const auto attr1_size = std::distance(attr1.begin(), attr1.end()); - const auto attr2_size = std::distance(attr2.begin(), attr2.end()); - if (attr1_size != attr2_size) { - return {false, "Attribute count is different in <" + node1_name + "> :" + - std::to_string(attr1_size) + " != " + - std::to_string(attr2_size)}; - } - - // every node attribute name must be the same - auto a1 = attr1.begin(); - auto a2 = attr2.begin(); - for (int j = 0; j < attr1_size; ++j, ++a1, ++a2) { - const std::string a1_name{a1->name()}; - const std::string a2_name{a2->name()}; - const std::string a1_value{a1->value()}; - const std::string a2_value{a2->value()}; - if (a1_name != a2_name || (a1_name == "type" && a1_value != a2_value)) { - // TODO: Remove temporary w/a later - if (a1_value == "Output" && a2_value == "Result") { - continue; - } - return {false, "Attributes are different in <" + node1_name + "> : " + - a1_name + "=" + a1_value + " != " + a2_name + - "=" + a2_value}; - } - } - return {true, ""}; -} - -std::pair OVExecGraphSerializationTest::compare_docs(const pugi::xml_document &doc1, - const pugi::xml_document &doc2) { - // traverse document and prepare vector of & nodes to compare - exec_graph_walker walker1, walker2; - doc1.child("net").child("layers").traverse(walker1); - doc2.child("net").child("layers").traverse(walker2); - - // nodes count must be the same - const auto &nodes1 = walker1.nodes; - const auto &nodes2 = walker2.nodes; - if (nodes1.size() != nodes2.size()) { - return {false, "Node count differ: " + std::to_string(nodes1.size()) + - " != " + std::to_string(nodes2.size())}; - } - - // every node must be equivalent - for (int i = 0; i < nodes1.size(); i++) { - const auto res = compare_nodes(nodes1[i], nodes2[i]); - if (res.first == false) { - return res; - } - } - return {true, ""}; -} - -TEST_P(OVExecGraphSerializationTest, ExecutionGraph) { - auto core = utils::PluginCache::get().core(); - auto model = core->read_model(serialize_test_model); - auto compiled_model = core->compile_model(model, target_device); - auto runtime_model = compiled_model.get_runtime_model(); - - ov::serialize(runtime_model, m_out_xml_path, m_out_bin_path); - - pugi::xml_document expected; - pugi::xml_document result; - if (target_device == "CPU" || target_device == "AUTO:CPU" || target_device == "MULTI:CPU") { - ASSERT_TRUE(expected.load_string(expected_serialized_model_cpu)); - } else { - ASSERT_TRUE(expected.load_string(expected_serialized_model)); - } - ASSERT_TRUE(result.load_file(m_out_xml_path.c_str())); - - bool status; - std::string message; - std::tie(status, message) = this->compare_docs(expected, result); - - ASSERT_TRUE(status) << message; -} - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/get_metric.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/get_metric.cpp deleted file mode 100644 index c05b5540243984..00000000000000 --- a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/get_metric.cpp +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "behavior/ov_executable_network/get_metric.hpp" - -namespace ov { -namespace test { -namespace behavior { -std::string OVClassExecutableNetworkGetMetricTest_Priority::getTestCaseName(testing::TestParamInfo obj) { - std::string target_device; - ov::AnyMap userConfig; - std::tie(target_device, userConfig) = obj.param; - std::replace(target_device.begin(), target_device.end(), ':', '.'); - auto compileModelProperties = userConfig; - std::ostringstream result; - result << "device_name=" << target_device << "_"; - for (auto& iter : compileModelProperties) { - result << iter.first << "_" << iter.second.as() << "_"; - } - return result.str(); -} - -void OVClassHeteroExecutableNetworkGetMetricTest::SetCpuAffinity(ov::Core& core, std::vector& expectedTargets) { -#ifdef ENABLE_INTEL_CPU - auto layermap = core.query_model(actualNetwork, heteroDeviceName); - for (auto &iter : layermap) { - if (iter.first.find("Concat") != std::string::npos) - layermap[iter.first] = ov::test::utils::DEVICE_CPU; - } - for (auto& node : actualNetwork->get_ops()) { - auto affinity = layermap[node->get_friendly_name()]; - node->get_rt_info()["affinity"] = affinity; - } - if (target_device.find(ov::test::utils::DEVICE_CPU) == std::string::npos) - expectedTargets = {target_device, ov::test::utils::DEVICE_CPU}; -#endif -} - - -// -// ImportExportNetwork -// - -TEST_P(OVClassExecutableNetworkImportExportTestP, smoke_ImportNetworkNoThrowWithDeviceName) { - ov::Core ie = createCoreWithTemplate(); - std::stringstream strm; - ov::CompiledModel executableNetwork; - OV_ASSERT_NO_THROW(executableNetwork = ie.compile_model(actualNetwork, target_device)); - OV_ASSERT_NO_THROW(executableNetwork.export_model(strm)); - OV_ASSERT_NO_THROW(executableNetwork = ie.import_model(strm, target_device)); - OV_ASSERT_NO_THROW(executableNetwork.create_infer_request()); -} - -// -// ExecutableNetwork GetMetric / GetConfig -// -TEST_P(OVClassExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - std::vector supported_properties; - OV_ASSERT_NO_THROW(supported_properties = compiled_model.get_property(ov::supported_properties)); - - std::cout << "Supported RW keys: " << std::endl; - for (auto&& conf : supported_properties) if (conf.is_mutable()) { - std::cout << conf << std::endl; - ASSERT_LT(0, conf.size()); - } - ASSERT_LE(0, supported_properties.size()); - ASSERT_EXEC_METRIC_SUPPORTED(ov::supported_properties); -} - -TEST_P(OVClassExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - std::vector supported_properties; - OV_ASSERT_NO_THROW(supported_properties = compiled_model.get_property(ov::supported_properties)); - - std::cout << "Supported RO keys: " << std::endl; - for (auto&& conf : supported_properties) if (!conf.is_mutable()) { - std::cout << conf << std::endl; - ASSERT_LT(0, conf.size()); - } - ASSERT_LE(0, supported_properties.size()); - ASSERT_EXEC_METRIC_SUPPORTED(ov::supported_properties); -} - -TEST_P(OVClassExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - std::string model_name; - OV_ASSERT_NO_THROW(model_name = compiled_model.get_property(ov::model_name)); - - std::cout << "Compiled model name: " << std::endl << model_name << std::endl; - ASSERT_EQ(simpleNetwork->get_friendly_name(), model_name); - ASSERT_EXEC_METRIC_SUPPORTED(ov::model_name); -} - -TEST_P(OVClassExecutableNetworkGetMetricTest_OPTIMAL_NUMBER_OF_INFER_REQUESTS, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - unsigned int value = 0; - OV_ASSERT_NO_THROW(value = compiled_model.get_property(ov::optimal_number_of_infer_requests)); - - std::cout << "Optimal number of Inference Requests: " << value << std::endl; - ASSERT_GE(value, 1u); - ASSERT_EXEC_METRIC_SUPPORTED(ov::optimal_number_of_infer_requests); -} -TEST_P(OVClassExecutableNetworkGetMetricTest_MODEL_PRIORITY, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - auto compiled_model = ie.compile_model(simpleNetwork, target_device, configuration); - - ov::hint::Priority value; - OV_ASSERT_NO_THROW(value = compiled_model.get_property(ov::hint::model_priority)); - ASSERT_EQ(value, configuration[ov::hint::model_priority.name()].as()); -} - -TEST_P(OVClassExecutableNetworkGetMetricTest_DEVICE_PRIORITY, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - auto compiled_model = ie.compile_model(simpleNetwork, target_device, configuration); - - std::string value; - OV_ASSERT_NO_THROW(value = compiled_model.get_property(ov::device::priorities)); - ASSERT_EQ(value, configuration[ov::device::priorities.name()].as()); -} - -TEST_P(OVClassExecutableNetworkGetMetricTest_ThrowsUnsupported, GetMetricThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - ASSERT_THROW(compiled_model.get_property("unsupported_property"), ov::Exception); -} - -TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - std::vector property_names; - OV_ASSERT_NO_THROW(property_names = compiled_model.get_property(ov::supported_properties)); - - for (auto&& property : property_names) { - ov::Any defaultValue; - OV_ASSERT_NO_THROW(defaultValue = compiled_model.get_property(property)); - ASSERT_FALSE(defaultValue.empty()); - } -} - -TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigThrows) { - ov::Core ie = createCoreWithTemplate(); - ov::Any p; - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - ASSERT_THROW(compiled_model.get_property("unsupported_property"), ov::Exception); -} - -TEST_P(OVClassExecutableNetworkSetConfigTest, SetConfigThrows) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - ASSERT_THROW(compiled_model.set_property({{"unsupported_config", "some_value"}}), ov::Exception); -} - -TEST_P(OVClassExecutableNetworkSetConfigTest, canNotSetConfigToCompiledModelWithIncorrectConfig) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - std::map incorrectConfig = {{"abc", "def"}}; - std::map config; - for (const auto& confItem : incorrectConfig) { - config.emplace(confItem.first, confItem.second); - } - EXPECT_ANY_THROW(compiled_model.set_property(config)); -} - -TEST_P(OVClassExecutableNetworkSupportedConfigTest, SupportedConfigWorks) { - ov::Core ie = createCoreWithTemplate(); - ov::Any p; - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - OV_ASSERT_NO_THROW(compiled_model.set_property({{configKey, configValue}})); - OV_ASSERT_NO_THROW(p = compiled_model.get_property(configKey)); - ASSERT_EQ(p, configValue); -} - -TEST_P(OVClassExecutableNetworkGetMetricTestForSpecificConfig, canSetConfigToCompiledModel) { - ov::Core ie = createCoreWithTemplate(); - std::shared_ptr function = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); - auto execNet = ie.compile_model(function, target_device); - std::map config; - config.emplace(configKey, configValue); - EXPECT_NO_THROW(execNet.set_property(config)); -} - -TEST_P(OVClassExecutableNetworkGetMetricTestForSpecificConfig, canSetConfigToCompiledModelGetConfigAndCheck) { - ov::Core ie = createCoreWithTemplate(); - std::shared_ptr function = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); - auto execNet = ie.compile_model(simpleNetwork, target_device); - std::map config; - config.emplace(configKey, configValue); - execNet.set_property(config); - ov::Any param; - EXPECT_NO_THROW(param = execNet.get_property(configKey)); - EXPECT_FALSE(param.empty()); - EXPECT_EQ(param, configValue); -} - -TEST_P(OVClassExecutableNetworkUnsupportedConfigTest, UnsupportedConfigThrows) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - ASSERT_THROW(compiled_model.set_property({{configKey, configValue}}), ov::Exception); -} - -TEST_P(OVClassExecutableNetworkGetConfigTest, GetConfigNoEmptyNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - std::vector dev_property_names; - OV_ASSERT_NO_THROW(dev_property_names = ie.get_property(target_device, ov::supported_properties)); - - auto compiled_model = ie.compile_model(simpleNetwork, target_device); - - std::vector model_property_names; - OV_ASSERT_NO_THROW(model_property_names = compiled_model.get_property(ov::supported_properties)); -} - -TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_CONFIG_KEYS, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto heteroExeNetwork = ie.compile_model(actualNetwork, heteroDeviceName); - auto deviceExeNetwork = ie.compile_model(actualNetwork, target_device); - - std::vector heteroConfigValues, deviceConfigValues; - OV_ASSERT_NO_THROW(heteroConfigValues = heteroExeNetwork.get_property(ov::supported_properties)); - OV_ASSERT_NO_THROW(deviceConfigValues = deviceExeNetwork.get_property(ov::supported_properties)); - - std::cout << "Supported config keys: " << std::endl; - for (auto&& conf : heteroConfigValues) { - std::cout << conf << std::endl; - ASSERT_LT(0, conf.size()); - } - ASSERT_LE(0, heteroConfigValues.size()); - - // check that all device config values are present in hetero case - for (auto&& deviceConf : deviceConfigValues) { - auto it = std::find(heteroConfigValues.begin(), heteroConfigValues.end(), deviceConf); - ASSERT_TRUE(it != heteroConfigValues.end()); - - ov::Any heteroConfigValue = heteroExeNetwork.get_property(deviceConf); - ov::Any deviceConfigValue = deviceExeNetwork.get_property(deviceConf); - - if (CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS) != deviceConf && - ov::supported_properties.name() != deviceConf) { - std::stringstream strm; - deviceConfigValue.print(strm); - strm << " "; - heteroConfigValue.print(strm); - ASSERT_EQ(deviceConfigValue, heteroConfigValue) << deviceConf << " " << strm.str(); - } - } -} - -TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_SUPPORTED_METRICS, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto heteroExeNetwork = ie.compile_model(actualNetwork, heteroDeviceName); - auto deviceExeNetwork = ie.compile_model(actualNetwork, target_device); - - std::vector heteroConfigValues, deviceConfigValues; - OV_ASSERT_NO_THROW(heteroConfigValues = heteroExeNetwork.get_property(ov::supported_properties)); - OV_ASSERT_NO_THROW(deviceConfigValues = deviceExeNetwork.get_property(ov::supported_properties)); - - std::cout << "Supported config keys: " << std::endl; - for (auto&& conf : heteroConfigValues) { - std::cout << conf << std::endl; - ASSERT_LT(0, conf.size()); - } - ASSERT_LE(0, heteroConfigValues.size()); - - // check that all device config values are present in hetero case - for (auto&& deviceConf : deviceConfigValues) { - auto it = std::find(heteroConfigValues.begin(), heteroConfigValues.end(), deviceConf); - ASSERT_TRUE(it != heteroConfigValues.end()); - - ov::Any heteroConfigValue = heteroExeNetwork.get_property(deviceConf); - ov::Any deviceConfigValue = deviceExeNetwork.get_property(deviceConf); - - // HETERO returns EXCLUSIVE_ASYNC_REQUESTS as a boolean value - if (CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS) != deviceConf) { - std::stringstream strm; - deviceConfigValue.print(strm); - strm << " "; - heteroConfigValue.print(strm); - ASSERT_EQ(deviceConfigValue, heteroConfigValue) << deviceConf << " " << strm.str(); - } - } -} - -TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_NETWORK_NAME, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - auto compiled_model = ie.compile_model(actualNetwork, heteroDeviceName); - - std::string model_name; - OV_ASSERT_NO_THROW(model_name = compiled_model.get_property(ov::model_name)); - - std::cout << "Compiled model name: " << std::endl << model_name << std::endl; -} - -TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_TARGET_FALLBACK, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - - setHeteroNetworkAffinity(target_device); - - auto compiled_model = ie.compile_model(actualNetwork, heteroDeviceName); - - std::string targets; - OV_ASSERT_NO_THROW(targets = compiled_model.get_property(ov::device::priorities)); - auto expectedTargets = target_device; - - std::cout << "Compiled model fallback targets: " << targets << std::endl; - ASSERT_EQ(expectedTargets, targets); -} - -TEST_P(OVClassHeteroExecutableNetworkGetMetricTest_EXEC_DEVICES, GetMetricNoThrow) { - ov::Core ie = createCoreWithTemplate(); - std::vector expectedTargets = {target_device}; - - SetCpuAffinity(ie, expectedTargets); - - auto compiled_model = ie.compile_model(actualNetwork, heteroDeviceName); - - std::vector exeTargets; - OV_ASSERT_NO_THROW(exeTargets = compiled_model.get_property(ov::execution_devices)); - - ASSERT_EQ(expectedTargets, exeTargets); -} -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/properties.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/properties.cpp deleted file mode 100644 index 51addb55b739a5..00000000000000 --- a/src/tests/functional/plugin/shared/src/behavior/ov_executable_network/properties.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "behavior/ov_executable_network/properties.hpp" - -#include - -#include "openvino/runtime/properties.hpp" - -namespace ov { -namespace test { -namespace behavior { - -std::string OVCompiledModelEmptyPropertiesTests::getTestCaseName(testing::TestParamInfo obj) { - return "target_device=" + obj.param; -} - -void OVCompiledModelEmptyPropertiesTests::SetUp() { - target_device = this->GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED() - APIBaseTest::SetUp(); - model = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); -} - -std::string OVCompiledModelPropertiesTests::getTestCaseName(testing::TestParamInfo obj) { - std::string targetDevice; - AnyMap properties; - std::tie(targetDevice, properties) = obj.param; - std::replace(targetDevice.begin(), targetDevice.end(), ':', '.'); - std::ostringstream result; - result << "targetDevice=" << targetDevice << "_"; - if (!properties.empty()) { - result << "properties=" << util::join(util::split(util::to_string(properties), ' '), "_"); - } - return result.str(); -} - -void OVCompiledModelPropertiesTests::SetUp() { - std::tie(target_device, properties) = this->GetParam(); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); - APIBaseTest::SetUp(); - model = ov::test::behavior::getDefaultNGraphFunctionForTheDevice(); -} - -void OVCompiledModelPropertiesTests::TearDown() { - if (!properties.empty()) { - utils::PluginCache::get().reset(); - } - APIBaseTest::TearDown(); -} - -TEST_P(OVCompiledModelEmptyPropertiesTests, CanCompileModelWithEmptyProperties) { - OV_ASSERT_NO_THROW(core->compile_model(model, target_device, AnyMap{})); -} - -TEST_P(OVCompiledModelPropertiesTests, CanCompileModelWithCorrectProperties) { - OV_ASSERT_NO_THROW(core->compile_model(model, target_device, properties)); -} - -TEST_P(OVCompiledModelPropertiesTests, CanUseCache) { - core->set_property(ov::cache_dir("./test_cache")); - OV_ASSERT_NO_THROW(core->compile_model(model, target_device, properties)); - OV_ASSERT_NO_THROW(core->compile_model(model, target_device, properties)); - ov::test::utils::removeDir("./test_cache"); -} - -TEST_P(OVCompiledModelPropertiesTests, IgnoreEnableMMap) { - if (target_device.find("HETERO:") == 0 || target_device.find("MULTI:") == 0 || target_device.find("AUTO:") == 0 || - target_device.find("BATCH:") == 0) - GTEST_SKIP() << "Disabled test due to configuration" << std::endl; - // Load available plugins - core->get_available_devices(); - OV_ASSERT_NO_THROW(core->set_property(ov::enable_mmap(false))); - OV_ASSERT_NO_THROW(core->set_property(target_device, ov::enable_mmap(false))); -} // namespace behavior - -TEST_P(OVCompiledModelPropertiesTests, canCompileModelWithPropertiesAndCheckGetProperty) { - auto compiled_model = core->compile_model(model, target_device, properties); - auto supported_properties = compiled_model.get_property(ov::supported_properties); - for (const auto& property_item : properties) { - if (util::contains(supported_properties, property_item.first)) { - Any property; - OV_ASSERT_NO_THROW(property = compiled_model.get_property(property_item.first)); - ASSERT_FALSE(property.empty()); - std::cout << property_item.first << ":" << property.as() << std::endl; - } - } -} - -TEST_P(OVCompiledModelPropertiesIncorrectTests, CanNotCompileModelWithIncorrectProperties) { - ASSERT_THROW(core->compile_model(model, target_device, properties), ov::Exception); -} - -TEST_P(OVClassCompileModelTest, LoadNetworkWithBigDeviceIDThrows) { - ov::Core ie = createCoreWithTemplate(); - ASSERT_THROW(ie.compile_model(actualNetwork, target_device + ".10"), ov::Exception); -} - -TEST_P(OVCompiledModelPropertiesDefaultTests, CanCompileWithDefaultValueFromPlugin) { - std::vector supported_properties; - OV_ASSERT_NO_THROW(supported_properties = core->get_property(target_device, ov::supported_properties)); - AnyMap default_rw_properties; - for (auto& supported_property : supported_properties) { - if (supported_property.is_mutable()) { - Any property; - OV_ASSERT_NO_THROW(property = core->get_property(target_device, supported_property)); - default_rw_properties.emplace(supported_property, property); - std::cout << supported_property << ":" << property.as() << std::endl; - } - } - OV_ASSERT_NO_THROW(core->compile_model(model, target_device, default_rw_properties)); -} - -TEST_P(OVCompiledModelPropertiesDefaultTests, CheckDefaultValues) { - auto compiled_model = core->compile_model(model, target_device); - std::vector supported_properties; - OV_ASSERT_NO_THROW(supported_properties = compiled_model.get_property(ov::supported_properties)); - std::cout << "SUPPORTED PROPERTIES: " << std::endl; - for (auto&& supported_property : supported_properties) { - Any property; - OV_ASSERT_NO_THROW(property = compiled_model.get_property(supported_property)); - std::cout << supported_property << ":" << property.as() << std::endl; - } - for (auto&& default_property : properties) { - auto supported = util::contains(supported_properties, default_property.first); - ASSERT_TRUE(supported) << "default_property=" << default_property.first; - Any property; - OV_ASSERT_NO_THROW(property = compiled_model.get_property(default_property.first)); - ASSERT_EQ(default_property.second, property) - << "For property: " << default_property.first - << " expected value is: " << default_property.second.as(); - } -} - -} // namespace behavior -} // namespace test -} // namespace ov diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp index 4246bf3496a75f..c94ee904c2582b 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_plugin/properties_tests.cpp @@ -218,7 +218,7 @@ std::vector OVPropertiesTestsWithCompileModelProps::getROMandatoryPr return res; } -std::vector OVPropertiesTestsWithCompileModelProps::getROOptionalProperties() { +std::vector OVPropertiesTestsWithCompileModelProps::getROOptionalProperties() { std::vector res; res.push_back({{ov::PropertyName(ov::loaded_from_cache.name(), ov::loaded_from_cache.mutability), nullptr}}); res.push_back({{ov::PropertyName(ov::device::uuid.name(), ov::device::uuid.mutability), nullptr}}); diff --git a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp index 7743d4b9098455..281310fb4e83c7 100644 --- a/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/ov_tensor_utils.cpp @@ -305,11 +305,24 @@ ov::runtime::Tensor create_and_fill_tensor_consistently(const ov::element::Type constexpr double eps = std::numeric_limits::epsilon(); inline double less(double a, double b) { - return (b - a) > (std::fmax(std::fabs(a), std::fabs(b)) * eps); + return std::fabs(a - b) > eps && a < b; } inline double less_or_equal(double a, double b) { - return (b - a) >= (std::fmax(std::fabs(a), std::fabs(b)) * eps); + bool res = true; + if (std::isnan(a) || std::isnan(b)) { + res = false; + } else if (std::isinf(b) && b > 0) { + // b is grater than any number or eq the +Inf + res = true; + } else if (std::isinf(a) && a > 0) { + res = false; + } else { + res = (std::fabs(b - a) <= (std::fmax(std::fabs(a), std::fabs(b)) * eps) || a < b); + } + double eq_midle_res = std::fabs(b - a); + bool eq_res = (std::fabs(b - a) <= (std::fmax(std::fabs(a), std::fabs(b)) * eps)); + return res; } struct Error { @@ -369,13 +382,33 @@ void compare(const ov::Tensor& expected, if (abs_threshold == std::numeric_limits::max() && rel_threshold == std::numeric_limits::max()) { if (sizeof(ExpectedT) == 1 || sizeof(ActualT) == 1) { abs_threshold = 1.; + rel_threshold = 1.; + if (expected.get_element_type() == ov::element::Type_t::boolean) { + abs_threshold = 0.; + rel_threshold = 0.; + } } else { std::vector abs_values(shape_size_cnt); for (size_t i = 0; i < shape_size_cnt; i++) { abs_values[i] = std::fabs(static_cast(expected_data[i])); } auto abs_median = calculate_median(abs_values); + auto elem_type = expected.get_element_type(); + abs_threshold = abs_median * 0.05 < 1e-5 ? 1e-5 : 0.05 * abs_median; + + if (elem_type == ov::element::Type_t::boolean) { + abs_threshold = 0.; + } else if (elem_type.is_integral_number()) { + abs_threshold = 1.0; + } else if (elem_type == ov::element::Type_t::f32 || elem_type == ov::element::Type_t::f64) { + abs_threshold = abs_median * 0.05 < 1e-5 ? 1e-5 : 0.05 * abs_median; + } else if (elem_type == ov::element::Type_t::bf16 || elem_type == ov::element::Type_t::f16) { + abs_threshold = abs_median * 0.05 < 1e-3 ? 1e-3 : 0.05 * abs_median; + } + + rel_threshold = abs_threshold; + if (std::is_integral::value) { abs_threshold = std::ceil(abs_threshold); } @@ -388,10 +421,21 @@ void compare(const ov::Tensor& expected, std::cout << "[ COMPARATION ] abs_threshold: " << abs_threshold << std::endl; } + auto max_type_expected = std::numeric_limits::max(); + auto max_type_actual = std::numeric_limits::max(); + auto min_type_expected = std::numeric_limits::min(); + auto min_type_actual = std::numeric_limits::min(); Error abs_error(abs_threshold), rel_error(rel_threshold); for (size_t i = 0; i < shape_size_cnt; ++i) { double expected_value = expected_data[i]; double actual_value = actual_data[i]; + if ((std::isinf(expected_value) || expected_value >= max_type_expected) && + (std::isinf(actual_value) || actual_value >= max_type_actual)) { + continue; + } else if ((std::isinf(expected_value) || expected_value <= min_type_expected) && + (std::isinf(actual_value) || actual_value <= min_type_actual)) { + continue; + } if (std::isnan(expected_value) && std::isnan(actual_value)) continue; if (std::isnan(expected_value)) { @@ -406,15 +450,15 @@ void compare(const ov::Tensor& expected, } double abs = std::fabs(expected_value - actual_value); - double rel = expected_value ? (abs / std::fabs(expected_value)) : abs; - + double rel = + expected_value && actual_value && !std::isinf(expected_value) ? (abs / std::fabs(expected_value)) : 0; abs_error.update(abs, i); rel_error.update(rel, i); } abs_error.mean /= shape_size_cnt; rel_error.mean /= shape_size_cnt; - if (!(less_or_equal(abs_error.max, abs_threshold) && less_or_equal(rel_error.max, rel_threshold))) { + if (!(less_or_equal(abs_error.max, abs_threshold) || less_or_equal(rel_error.mean, rel_threshold))) { std::ostringstream out_stream; out_stream << "abs_max < abs_threshold && rel_max < rel_threshold" << "\n\t abs_max: " << abs_error.max << "\n\t\t coordinate " << abs_error.max_coordinate