Extend Proxy tests to cover cache_dir with auto batch (#18632)

* Added new tests to reproduce issue with auto batch

* Remove cache dir

* Fixed tests with auto batch

* Fixed check

* Added comment

* Remove try catch

* Remove comment

* Revert "Remove comment"

This reverts commit 99e26de4ca.

* Revert "Remove try catch"

This reverts commit 08b478c070.
This commit is contained in:
Ilya Churaev 2023-07-20 11:11:41 +04:00 committed by GitHub
parent a51d9494fa
commit 3f675ce396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 310 additions and 71 deletions

View File

@ -710,13 +710,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
auto plugin = get_plugin(parsed._deviceName); auto plugin = get_plugin(parsed._deviceName);
ov::SoPtr<ov::ICompiledModel> res; ov::SoPtr<ov::ICompiledModel> res;
auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager;
if (cacheManager && device_supports_model_caching(plugin)) { // Skip caching for proxy plugin. HW plugin will load network from the cache
if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {
CacheContent cacheContent{cacheManager}; CacheContent cacheContent{cacheManager};
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
std::unique_ptr<CacheGuardEntry> lock; std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
// Proxy plugin fallback to lowlevel device
if (!is_proxy_device(plugin))
lock = cacheGuard.get_hash_lock(cacheContent.blobId);
res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() { res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() {
return compile_model_and_cache(model, return compile_model_and_cache(model,
plugin, plugin,
@ -746,13 +744,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
auto plugin = get_plugin(parsed._deviceName); auto plugin = get_plugin(parsed._deviceName);
ov::SoPtr<ov::ICompiledModel> res; ov::SoPtr<ov::ICompiledModel> res;
auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager;
if (cacheManager && device_supports_model_caching(plugin)) { // Skip caching for proxy plugin. HW plugin will load network from the cache
if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {
CacheContent cacheContent{cacheManager}; CacheContent cacheContent{cacheManager};
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config)); cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
std::unique_ptr<CacheGuardEntry> lock; std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
// Proxy plugin fallback to lowlevel device
if (!is_proxy_device(plugin))
lock = cacheGuard.get_hash_lock(cacheContent.blobId);
res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() { res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() {
return compile_model_and_cache(model, plugin, parsed._config, context, cacheContent); return compile_model_and_cache(model, plugin, parsed._config, context, cacheContent);
}); });
@ -793,13 +789,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
ov::SoPtr<ov::ICompiledModel> compiled_model; ov::SoPtr<ov::ICompiledModel> compiled_model;
auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager;
if (cacheManager && device_supports_model_caching(plugin)) { // Skip caching for proxy plugin. HW plugin will load network from the cache
if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {
CacheContent cacheContent{cacheManager, model_path}; CacheContent cacheContent{cacheManager, model_path};
cacheContent.blobId = ov::ModelCache::compute_hash(model_path, create_compile_config(plugin, parsed._config)); cacheContent.blobId = ov::ModelCache::compute_hash(model_path, create_compile_config(plugin, parsed._config));
std::unique_ptr<CacheGuardEntry> lock; std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
// Proxy plugin fallback to lowlevel device
if (!is_proxy_device(plugin))
lock = cacheGuard.get_hash_lock(cacheContent.blobId);
compiled_model = compiled_model =
load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() { load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() {
auto cnnNetwork = ReadNetwork(model_path, std::string()); auto cnnNetwork = ReadNetwork(model_path, std::string());
@ -830,14 +824,12 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
ov::SoPtr<ov::ICompiledModel> compiled_model; ov::SoPtr<ov::ICompiledModel> compiled_model;
auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager; auto cacheManager = coreConfig.get_cache_config_for_device(plugin, parsed._config)._cacheManager;
if (cacheManager && device_supports_model_caching(plugin)) { // Skip caching for proxy plugin. HW plugin will load network from the cache
if (cacheManager && device_supports_model_caching(plugin) && !is_proxy_device(plugin)) {
CacheContent cacheContent{cacheManager}; CacheContent cacheContent{cacheManager};
cacheContent.blobId = cacheContent.blobId =
ov::ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed._config)); ov::ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed._config));
std::unique_ptr<CacheGuardEntry> lock; std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
// Proxy plugin fallback to lowlevel device
if (!is_proxy_device(plugin))
lock = cacheGuard.get_hash_lock(cacheContent.blobId);
compiled_model = compiled_model =
load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() { load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() {
auto cnnNetwork = read_model(model_str, weights); auto cnnNetwork = read_model(model_str, weights);

View File

@ -6,6 +6,7 @@
#include "dev/converter_utils.hpp" #include "dev/converter_utils.hpp"
#include "ie_plugin_config.hpp" #include "ie_plugin_config.hpp"
#include "openvino/core/except.hpp"
InferenceEngine::ICompiledModelWrapper::ICompiledModelWrapper( InferenceEngine::ICompiledModelWrapper::ICompiledModelWrapper(
const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& model) const std::shared_ptr<InferenceEngine::IExecutableNetworkInternal>& model)
@ -29,7 +30,11 @@ std::shared_ptr<ov::IAsyncInferRequest> InferenceEngine::ICompiledModelWrapper::
} }
void InferenceEngine::ICompiledModelWrapper::export_model(std::ostream& model) const { void InferenceEngine::ICompiledModelWrapper::export_model(std::ostream& model) const {
m_model->Export(model); try {
m_model->Export(model);
} catch (const InferenceEngine::NotImplemented& ex) {
OPENVINO_ASSERT_HELPER(ov::NotImplemented, "", false, ex.what());
}
} }
std::shared_ptr<const ov::Model> InferenceEngine::ICompiledModelWrapper::get_runtime_model() const { std::shared_ptr<const ov::Model> InferenceEngine::ICompiledModelWrapper::get_runtime_model() const {

View File

@ -688,26 +688,32 @@ void ov::hetero::CompiledModel::export_model(std::ostream& model_stream) const {
for (const auto& comp_model_desc : m_compiled_submodels) { for (const auto& comp_model_desc : m_compiled_submodels) {
if (get_plugin()->get_core()->device_supports_model_caching(comp_model_desc.device)) { if (get_plugin()->get_core()->device_supports_model_caching(comp_model_desc.device)) {
comp_model_desc.compiled_model->export_model(model_stream); try {
} else { // Batch plugin reports property of low level plugin
auto model = comp_model_desc.model; // If we use Batch plugin inside hetero, we won't be able to call export
if (!model) // Auto batch plugin will throw NOT_IMPLEMENTED
OPENVINO_THROW("OpenVINO Model is empty"); comp_model_desc.compiled_model->export_model(model_stream);
continue;
std::stringstream xmlFile, binFile; } catch (ov::NotImplemented&) {
ov::pass::Serialize serializer(xmlFile, binFile); }
serializer.run_on_model(model);
auto constants = binFile.str();
auto model_str = xmlFile.str();
auto dataSize = static_cast<std::uint64_t>(model_str.size());
model_stream.write(reinterpret_cast<char*>(&dataSize), sizeof(dataSize));
model_stream.write(model_str.c_str(), dataSize);
dataSize = static_cast<std::uint64_t>(constants.size());
model_stream.write(reinterpret_cast<char*>(&dataSize), sizeof(dataSize));
model_stream.write(reinterpret_cast<char*>(&constants[0]), dataSize);
} }
auto model = comp_model_desc.model;
if (!model)
OPENVINO_THROW("OpenVINO Model is empty");
std::stringstream xmlFile, binFile;
ov::pass::Serialize serializer(xmlFile, binFile);
serializer.run_on_model(model);
auto constants = binFile.str();
auto model_str = xmlFile.str();
auto dataSize = static_cast<std::uint64_t>(model_str.size());
model_stream.write(reinterpret_cast<char*>(&dataSize), sizeof(dataSize));
model_stream.write(model_str.c_str(), dataSize);
dataSize = static_cast<std::uint64_t>(constants.size());
model_stream.write(reinterpret_cast<char*>(&dataSize), sizeof(dataSize));
model_stream.write(reinterpret_cast<char*>(&constants[0]), dataSize);
} }
} }

View File

@ -4,12 +4,34 @@
set(TARGET_NAME ov_proxy_plugin_tests) set(TARGET_NAME ov_proxy_plugin_tests)
set(DEPENDENCIES
mock_engine
openvino::runtime
func_test_utils
)
set(COMPILE_DEFINITIONS "CI_BUILD_NUMBER=\"mock_version\"")
if(ENABLE_AUTO_BATCH)
list(APPEND DEPENDENCIES openvino_auto_batch_plugin)
list(APPEND COMPILE_DEFINITIONS ENABLE_AUTO_BATCH)
endif()
if(ENABLE_HETERO)
list(APPEND DEPENDENCIES openvino_hetero_plugin)
list(APPEND COMPILE_DEFINITIONS HETERO_ENABLED)
endif()
if(ENABLE_OV_IR_FRONTEND)
list(APPEND DEPENDENCIES openvino_ir_frontend)
list(APPEND COMPILE_DEFINITIONS IR_FRONTEND_ENABLED)
endif()
ov_add_test_target( ov_add_test_target(
NAME ${TARGET_NAME} NAME ${TARGET_NAME}
ROOT ${CMAKE_CURRENT_SOURCE_DIR} ROOT ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDENCIES DEPENDENCIES
openvino::runtime ${DEPENDENCIES}
mock_engine
LINK_LIBRARIES LINK_LIBRARIES
openvino::runtime::dev openvino::runtime::dev
gtest gtest
@ -20,16 +42,5 @@ ov_add_test_target(
PROXY_PLUGIN PROXY_PLUGIN
) )
target_compile_definitions(${TARGET_NAME} PRIVATE CI_BUILD_NUMBER=\"mock_version\") target_compile_definitions(${TARGET_NAME} PRIVATE ${COMPILE_DEFINITIONS})
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../dev_api) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../dev_api)
if(ENABLE_HETERO)
add_dependencies(${TARGET_NAME} openvino_hetero_plugin)
target_compile_definitions(${TARGET_NAME} PRIVATE HETERO_ENABLED)
endif()
if(ENABLE_OV_IR_FRONTEND)
add_dependencies(${TARGET_NAME} openvino_ir_frontend)
target_compile_definitions(${TARGET_NAME} PRIVATE IR_FRONTEND_ENABLED)
endif()

View File

@ -1,6 +1,7 @@
// Copyright (C) 2018-2023 Intel Corporation // Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "openvino/runtime/properties.hpp"
#include "proxy_tests.hpp" #include "proxy_tests.hpp"
using namespace ov::proxy::tests; using namespace ov::proxy::tests;
@ -46,7 +47,7 @@ TEST_F(ProxyTests, set_property_for_primary_device_full_name) {
TEST_F(ProxyTests, get_property_on_default_device) { TEST_F(ProxyTests, get_property_on_default_device) {
const std::string dev_name = "MOCK"; const std::string dev_name = "MOCK";
auto supported_properties = core.get_property(dev_name, ov::supported_properties); auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(8, supported_properties.size()); EXPECT_EQ(12, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0); size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) { for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++; property.is_mutable() ? mutable_pr++ : immutable_pr++;
@ -59,21 +60,21 @@ TEST_F(ProxyTests, get_property_on_default_device) {
EXPECT_EQ("000102030405060708090a0b0c0d0e0f", get_string_value(core.get_property(dev_name, property))); EXPECT_EQ("000102030405060708090a0b0c0d0e0f", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) { } else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>(); auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
EXPECT_EQ(value.size(), 2); ASSERT_EQ(value.size(), 2);
EXPECT_EQ(value[0], "ABC"); EXPECT_EQ(value[0], "ABC");
EXPECT_EQ(value[1], "BDE"); EXPECT_EQ(value[1], "BDE");
} else { } else {
EXPECT_NO_THROW(core.get_property(dev_name, property)); EXPECT_NO_THROW(core.get_property(dev_name, property));
} }
} }
EXPECT_EQ(5, immutable_pr); EXPECT_EQ(6, immutable_pr);
EXPECT_EQ(3, mutable_pr); EXPECT_EQ(6, mutable_pr);
} }
TEST_F(ProxyTests, get_property_on_mixed_device) { TEST_F(ProxyTests, get_property_on_mixed_device) {
const std::string dev_name = "MOCK.1"; const std::string dev_name = "MOCK.1";
auto supported_properties = core.get_property(dev_name, ov::supported_properties); auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(8, supported_properties.size()); EXPECT_EQ(12, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0); size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) { for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++; property.is_mutable() ? mutable_pr++ : immutable_pr++;
@ -86,21 +87,21 @@ TEST_F(ProxyTests, get_property_on_mixed_device) {
EXPECT_EQ("00020406080a0c0e10121416181a1c1e", get_string_value(core.get_property(dev_name, property))); EXPECT_EQ("00020406080a0c0e10121416181a1c1e", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) { } else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>(); auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
EXPECT_EQ(value.size(), 2); ASSERT_EQ(value.size(), 2);
EXPECT_EQ(value[0], "ABC"); EXPECT_EQ(value[0], "ABC");
EXPECT_EQ(value[1], "BDE"); EXPECT_EQ(value[1], "BDE");
} else { } else {
core.get_property(dev_name, property); core.get_property(dev_name, property);
} }
} }
EXPECT_EQ(5, immutable_pr); EXPECT_EQ(6, immutable_pr);
EXPECT_EQ(3, mutable_pr); EXPECT_EQ(6, mutable_pr);
} }
TEST_F(ProxyTests, get_property_on_specified_device) { TEST_F(ProxyTests, get_property_on_specified_device) {
const std::string dev_name = "MOCK.3"; const std::string dev_name = "MOCK.3";
auto supported_properties = core.get_property(dev_name, ov::supported_properties); auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(7, supported_properties.size()); EXPECT_EQ(8, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0); size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) { for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++; property.is_mutable() ? mutable_pr++ : immutable_pr++;
@ -113,21 +114,21 @@ TEST_F(ProxyTests, get_property_on_specified_device) {
EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property))); EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) { } else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>(); auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
EXPECT_EQ(value.size(), 1); ASSERT_EQ(value.size(), 1);
EXPECT_EQ(value[0], "BDE"); EXPECT_EQ(value[0], "BDE");
} else { } else {
EXPECT_NO_THROW(core.get_property(dev_name, property)); EXPECT_NO_THROW(core.get_property(dev_name, property));
} }
} }
EXPECT_EQ(5, immutable_pr); EXPECT_EQ(5, immutable_pr);
EXPECT_EQ(2, mutable_pr); EXPECT_EQ(3, mutable_pr);
} }
TEST_F(ProxyTests, get_property_for_changed_default_device) { TEST_F(ProxyTests, get_property_for_changed_default_device) {
const std::string dev_name = "MOCK"; const std::string dev_name = "MOCK";
core.set_property(dev_name, ov::device::id(3)); core.set_property(dev_name, ov::device::id(3));
auto supported_properties = core.get_property(dev_name, ov::supported_properties); auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(7, supported_properties.size()); EXPECT_EQ(8, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0); size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) { for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++; property.is_mutable() ? mutable_pr++ : immutable_pr++;
@ -140,12 +141,205 @@ TEST_F(ProxyTests, get_property_for_changed_default_device) {
EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property))); EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) { } else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>(); auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
EXPECT_EQ(value.size(), 1); ASSERT_EQ(value.size(), 1);
EXPECT_EQ(value[0], "BDE"); EXPECT_EQ(value[0], "BDE");
} else { } else {
EXPECT_NO_THROW(core.get_property(dev_name, property)); EXPECT_NO_THROW(core.get_property(dev_name, property));
} }
} }
EXPECT_EQ(5, immutable_pr); EXPECT_EQ(5, immutable_pr);
EXPECT_EQ(2, mutable_pr); EXPECT_EQ(3, mutable_pr);
} }
TEST_F(ProxyTests, get_property_on_loaded_default_uninit_device) {
core.get_available_devices();
const std::string dev_name = "MOCK";
EXPECT_EQ(0, core.get_property(dev_name, ov::num_streams));
core.set_property(dev_name, ov::num_streams(2));
EXPECT_EQ(2, core.get_property(dev_name, ov::num_streams));
}
TEST_F(ProxyTests, set_property_for_loaded_fallback_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
EXPECT_EQ(0, core.get_property(dev_name, ov::num_streams));
core.set_property(dev_name, ov::num_streams(2));
EXPECT_EQ(2, core.get_property(dev_name, ov::num_streams));
core.set_property(dev_name, ov::device::properties("BDE", ov::enable_profiling(true)));
EXPECT_EQ(false, core.get_property(dev_name, ov::enable_profiling));
}
TEST_F(ProxyTests, set_cache_dir_for_loaded_fallback_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
core.set_property(dev_name, ov::cache_dir("test_cache"));
auto model = create_model_with_subtract();
auto compiled_model = core.compile_model(model, "MOCK.1", ov::cache_dir("test_cache"));
auto infer_request = compiled_model.create_infer_request();
auto input_tensor = create_and_fill_tensor(model->input().get_element_type(), model->input().get_shape());
infer_request.set_input_tensor(input_tensor);
infer_request.infer();
}
TEST_F(ProxyTests, set_property_for_loaded_primary_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
core.set_property(dev_name, ov::device::properties("ABC", ov::enable_profiling(true)));
EXPECT_EQ(true, core.get_property(dev_name, ov::enable_profiling));
}
TEST_F(ProxyTests, set_property_for_loaded_primary_device_full_name) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
core.set_property(dev_name, ov::device::properties("ABC.abc_b", ov::enable_profiling(true)));
EXPECT_EQ(true, core.get_property(dev_name, ov::enable_profiling));
}
TEST_F(ProxyTests, get_property_on_loaded_default_device) {
core.get_available_devices();
const std::string dev_name = "MOCK";
auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(12, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++;
if (property == ov::num_streams) {
EXPECT_EQ("0", get_string_value(core.get_property(dev_name, property)));
core.set_property(dev_name, ov::num_streams(2));
EXPECT_TRUE(core.get_property(dev_name, property).is<int32_t>());
EXPECT_EQ("2", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::uuid) {
EXPECT_EQ("000102030405060708090a0b0c0d0e0f", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
ASSERT_EQ(value.size(), 2);
EXPECT_EQ(value[0], "ABC");
EXPECT_EQ(value[1], "BDE");
} else {
EXPECT_NO_THROW(core.get_property(dev_name, property));
}
}
EXPECT_EQ(6, immutable_pr);
EXPECT_EQ(6, mutable_pr);
}
TEST_F(ProxyTests, get_property_loaded_on_mixed_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(12, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++;
if (property == ov::num_streams) {
EXPECT_EQ("0", get_string_value(core.get_property(dev_name, property)));
core.set_property(dev_name, ov::num_streams(2));
EXPECT_TRUE(core.get_property(dev_name, property).is<int32_t>());
EXPECT_EQ("2", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::uuid) {
EXPECT_EQ("00020406080a0c0e10121416181a1c1e", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
ASSERT_EQ(value.size(), 2);
EXPECT_EQ(value[0], "ABC");
EXPECT_EQ(value[1], "BDE");
} else {
core.get_property(dev_name, property);
}
}
EXPECT_EQ(6, immutable_pr);
EXPECT_EQ(6, mutable_pr);
}
TEST_F(ProxyTests, get_property_loaded_on_specified_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.3";
auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(8, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++;
if (property == ov::enable_profiling) {
EXPECT_EQ("NO", get_string_value(core.get_property(dev_name, property)));
core.set_property(dev_name, ov::enable_profiling(true));
EXPECT_TRUE(core.get_property(dev_name, property).is<bool>());
EXPECT_EQ("YES", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::uuid) {
EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
ASSERT_EQ(value.size(), 1);
EXPECT_EQ(value[0], "BDE");
} else {
EXPECT_NO_THROW(core.get_property(dev_name, property));
}
}
EXPECT_EQ(5, immutable_pr);
EXPECT_EQ(3, mutable_pr);
}
TEST_F(ProxyTests, get_property_for_loaded_changed_default_device) {
core.get_available_devices();
const std::string dev_name = "MOCK";
core.set_property(dev_name, ov::device::id(3));
auto supported_properties = core.get_property(dev_name, ov::supported_properties);
EXPECT_EQ(8, supported_properties.size());
size_t mutable_pr(0), immutable_pr(0);
for (auto&& property : supported_properties) {
property.is_mutable() ? mutable_pr++ : immutable_pr++;
if (property == ov::enable_profiling) {
EXPECT_EQ("NO", get_string_value(core.get_property(dev_name, property)));
core.set_property(dev_name, ov::enable_profiling(true));
EXPECT_TRUE(core.get_property(dev_name, property).is<bool>());
EXPECT_EQ("YES", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::uuid) {
EXPECT_EQ("0004080c1014181c2024282c3034383c", get_string_value(core.get_property(dev_name, property)));
} else if (property == ov::device::priorities) {
auto value = core.get_property(dev_name, property).as<std::vector<std::string>>();
ASSERT_EQ(value.size(), 1);
EXPECT_EQ(value[0], "BDE");
} else {
EXPECT_NO_THROW(core.get_property(dev_name, property));
}
}
EXPECT_EQ(5, immutable_pr);
EXPECT_EQ(3, mutable_pr);
}
#ifdef ENABLE_AUTO_BATCH
# ifdef HETERO_ENABLED
TEST_F(ProxyTests, set_cache_dir_for_auto_batch_hetero_fallback_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
core.set_property(dev_name, ov::cache_dir("test_cache"));
auto model = create_model_with_add();
auto compiled_model = core.compile_model(model,
"MOCK.1",
ov::cache_dir("test_cache"),
ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT));
auto infer_request = compiled_model.create_infer_request();
auto input_tensor = create_and_fill_tensor(model->input().get_element_type(), model->input().get_shape());
infer_request.set_input_tensor(input_tensor);
infer_request.infer();
}
# endif
TEST_F(ProxyTests, set_cache_dir_for_auto_batch_main_fallback_device) {
core.get_available_devices();
const std::string dev_name = "MOCK.1";
core.set_property(dev_name, ov::cache_dir("test_cache"));
auto model = create_model_with_add();
auto compiled_model = core.compile_model(model,
"MOCK.0",
ov::cache_dir("test_cache"),
ov::hint::performance_mode(ov::hint::PerformanceMode::THROUGHPUT));
auto infer_request = compiled_model.create_infer_request();
auto input_tensor = create_and_fill_tensor(model->input().get_element_type(), model->input().get_shape());
infer_request.set_input_tensor(input_tensor);
infer_request.infer();
}
#endif

View File

@ -66,6 +66,10 @@ void ov::proxy::tests::ProxyTests::SetUp() {
} }
} }
void ov::proxy::tests::ProxyTests::TearDown() {
CommonTestUtils::removeDir("test_cache");
}
ov::Tensor ov::proxy::tests::ProxyTests::create_and_fill_tensor(const ov::element::Type& type, const ov::Shape& shape) { ov::Tensor ov::proxy::tests::ProxyTests::create_and_fill_tensor(const ov::element::Type& type, const ov::Shape& shape) {
switch (type) { switch (type) {
case ov::element::Type_t::i64: case ov::element::Type_t::i64:
@ -108,6 +112,18 @@ std::shared_ptr<ov::Model> ov::proxy::tests::ProxyTests::create_model_with_subtr
return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param}); return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param});
} }
std::shared_ptr<ov::Model> ov::proxy::tests::ProxyTests::create_model_with_add() {
auto param = std::make_shared<ov::opset11::Parameter>(ov::element::i64, ov::Shape{1, 3, 2, 2});
param->set_friendly_name("input");
auto const_value = ov::opset11::Constant::create(ov::element::i64, ov::Shape{1, 1, 1, 1}, {1});
const_value->set_friendly_name("const_val");
auto add = std::make_shared<ov::opset11::Add>(param, const_value);
add->set_friendly_name("add");
auto result = std::make_shared<ov::opset11::Result>(add);
result->set_friendly_name("res");
return std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param});
}
std::shared_ptr<ov::Model> ov::proxy::tests::ProxyTests::create_model_with_subtract_reshape_relu() { std::shared_ptr<ov::Model> ov::proxy::tests::ProxyTests::create_model_with_subtract_reshape_relu() {
auto param = std::make_shared<ov::opset11::Parameter>(ov::element::i64, ov::Shape{1, 3, 2, 2}); auto param = std::make_shared<ov::opset11::Parameter>(ov::element::i64, ov::Shape{1, 3, 2, 2});
param->set_friendly_name("input"); param->set_friendly_name("input");
@ -173,7 +189,7 @@ public:
} }
std::shared_ptr<const ov::Model> get_runtime_model() const override { std::shared_ptr<const ov::Model> get_runtime_model() const override {
OPENVINO_NOT_IMPLEMENTED; return m_model;
} }
void set_property(const ov::AnyMap& properties) override { void set_property(const ov::AnyMap& properties) override {
@ -515,6 +531,8 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_reshape(ov::Core& cor
m_profiling = it.second.as<bool>(); m_profiling = it.second.as<bool>();
else if (it.first == ov::device::id.name()) else if (it.first == ov::device::id.name())
continue; continue;
else if (it.first == ov::cache_dir.name())
continue;
else else
OPENVINO_THROW(get_device_name(), " set config: " + it.first); OPENVINO_THROW(get_device_name(), " set config: " + it.first);
} }
@ -530,10 +548,14 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_reshape(ov::Core& cor
RO_property(ov::loaded_from_cache.name()), RO_property(ov::loaded_from_cache.name()),
RO_property(ov::device::uuid.name()), RO_property(ov::device::uuid.name()),
RO_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT)), RO_property(METRIC_KEY(IMPORT_EXPORT_SUPPORT)),
RO_property(ov::optimal_batch_size.name()),
RW_property(ov::hint::performance_mode.name()),
RW_property(ov::hint::num_requests.name()),
}; };
// the whole config is RW before network is loaded. // the whole config is RW before network is loaded.
const static std::vector<ov::PropertyName> rwProperties{ const static std::vector<ov::PropertyName> rwProperties{
RW_property(ov::num_streams.name()), RW_property(ov::num_streams.name()),
RW_property(ov::cache_dir.name()),
RW_property(ov::enable_profiling.name()), RW_property(ov::enable_profiling.name()),
}; };
@ -551,6 +573,12 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_reshape(ov::Core& cor
} else if (name == ov::internal::supported_properties) { } else if (name == ov::internal::supported_properties) {
return decltype(ov::internal::supported_properties)::value_type( return decltype(ov::internal::supported_properties)::value_type(
{ov::PropertyName{ov::internal::caching_properties.name(), ov::PropertyMutability::RO}}); {ov::PropertyName{ov::internal::caching_properties.name(), ov::PropertyMutability::RO}});
} else if (name == ov::optimal_batch_size) {
return decltype(ov::optimal_batch_size)::value_type{1};
} else if (name == ov::hint::num_requests) {
return decltype(ov::hint::num_requests)::value_type{1};
} else if (name == ov::hint::performance_mode) {
return decltype(ov::hint::performance_mode)::value_type{ov::hint::PerformanceMode::LATENCY};
} else if (name == ov::device::uuid) { } else if (name == ov::device::uuid) {
ov::device::UUID uuid; ov::device::UUID uuid;
for (size_t i = 0; i < uuid.MAX_UUID_SIZE; i++) { for (size_t i = 0; i < uuid.MAX_UUID_SIZE; i++) {
@ -657,6 +685,7 @@ void ov::proxy::tests::ProxyTests::register_plugin_support_subtract(ov::Core& co
// the whole config is RW before network is loaded. // the whole config is RW before network is loaded.
const static std::vector<ov::PropertyName> rwProperties{ const static std::vector<ov::PropertyName> rwProperties{
RW_property(ov::enable_profiling.name()), RW_property(ov::enable_profiling.name()),
RW_property(ov::cache_dir.name()),
}; };
std::string device_id; std::string device_id;
if (arguments.find(ov::device::id.name()) != arguments.end()) { if (arguments.find(ov::device::id.name()) != arguments.end()) {

View File

@ -64,11 +64,13 @@ public:
ov::Core core; ov::Core core;
void SetUp() override; void SetUp() override;
void TearDown() override;
std::shared_ptr<ov::Model> create_model_with_subtract(); std::shared_ptr<ov::Model> create_model_with_subtract();
std::shared_ptr<ov::Model> create_model_with_subtract_reshape(); std::shared_ptr<ov::Model> create_model_with_subtract_reshape();
std::shared_ptr<ov::Model> create_model_with_subtract_reshape_relu(); std::shared_ptr<ov::Model> create_model_with_subtract_reshape_relu();
std::shared_ptr<ov::Model> create_model_with_reshape(); std::shared_ptr<ov::Model> create_model_with_reshape();
std::shared_ptr<ov::Model> create_model_with_add();
ov::Tensor create_and_fill_tensor(const ov::element::Type& type, const ov::Shape& shape); ov::Tensor create_and_fill_tensor(const ov::element::Type& type, const ov::Shape& shape);
protected: protected: