Skip to content

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

[core, GPU, NPU]Remove deprecated code in core for `ov::cache_dir` (#32658)

Pawel Raasz3915f30c4c97
diff --git a/src/bindings/js/node/tests/unit/basic.test.js b/src/bindings/js/node/tests/unit/basic.test.js
index d417065b5fa..9b1bda05410 100644
--- a/src/bindings/js/node/tests/unit/basic.test.js
+++ b/src/bindings/js/node/tests/unit/basic.test.js
@@ -346,10 +346,9 @@ describe("ov basic tests.", () => {
it("Test importModelSync(stream, device, config: unsupported property) \
throws", () => {
- const tmpDir = "/tmp";
assert.throws(
- () => core.importModelSync(userStream, "CPU", { CACHE_DIR: tmpDir }),
- /Unsupported property CACHE_DIR by CPU plugin./,
+ () => core.importModelSync(userStream, "CPU", { NPU_DEVICE_TOTAL_MEM_SIZE: 1024 }),
+ /Unsupported property NPU_DEVICE_TOTAL_MEM_SIZE by CPU plugin./,
);
});
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index 6637d839618..a386b2c1713 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -384,7 +384,7 @@ ov::Parsed parse_device_config(const std::string& device_name,
}
};
- parsed.m_core_config.set(updated_config);
+ parsed.m_core_config.set(updated_config, updated_device_name);
// keep batch property only when called from query_supported_property
if (!keep_auto_batch_property) {
for (const auto& name : auto_batch_properties_names) {
@@ -393,6 +393,12 @@ ov::Parsed parse_device_config(const std::string& device_name,
}
return parsed;
}
+
+void emplace_cache_dir_if_supported(ov::AnyMap& config, const ov::Plugin& plugin, const std::string& cache_dir) {
+ if (ov::util::contains(plugin.get_property(ov::supported_properties), ov::cache_dir)) {
+ config.emplace(ov::cache_dir(cache_dir));
+ }
+}
} // namespace
ov::Parsed ov::parse_device_name_into_config(const std::string& device_name,
@@ -406,11 +412,9 @@ ov::Parsed ov::parse_device_name_into_config(const std::string& device_name,
const AnyMap& config,
const bool keep_auto_batch_property) {
auto parsed = parse_device_config(device_name, core_config, config, keep_auto_batch_property);
-
// remove core properties for HW devices
if (!ov::is_virtual_device(parsed.m_device_name)) {
- // note: ov::cache_dir kept as plugin may require it
- CoreConfig::remove_core_skip_cache_dir(parsed.m_config);
+ CoreConfig::remove_core(parsed.m_config);
}
return parsed;
}
@@ -764,22 +768,6 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& plugin_name) const {
}
}
#endif
- // TODO: remove this block of code once GPU removes support of ov::cache_dir
- // also, remove device_supports_cache_dir at all
- {
- OPENVINO_SUPPRESS_DEPRECATED_START
- if (device_supports_cache_dir(plugin)) {
- auto cache_config = m_core_config.get_cache_config_for_device(plugin);
- if (cache_config.m_cache_manager) {
- desc.m_default_config[ov::cache_dir.name()] = cache_config.m_cache_dir;
- }
- } else if (desc.m_default_config.count(ov::cache_dir.name()) > 0) {
- // Remove "CACHE_DIR" from config if it is not supported by plugin
- desc.m_default_config.erase(ov::cache_dir.name());
- }
- OPENVINO_SUPPRESS_DEPRECATED_END
- }
-
allowNotImplemented([&]() {
// Add device specific value to support device_name.device_id cases
{
@@ -852,14 +840,13 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
config_with_batch,
is_proxy_device(patched_device_name));
auto plugin = get_plugin(parsed.m_device_name);
- // will consume ov::cache_dir if plugin not support it
- const auto cache_manager =
- parsed.m_core_config.get_cache_config_for_device(plugin, parsed.m_config).m_cache_manager;
- auto res = import_compiled_model(plugin, {}, parsed.m_config, model);
+ const auto& [cache_dir, cache_manager] = parsed.m_core_config.get_cache_config_for_device(plugin);
+ auto res = import_compiled_model(plugin, {}, config, model);
// Skip caching for proxy plugin. HW plugin will load network from the cache
if (res) {
// hint::compiled_blob is set and imported skip compilation
} else if (cache_manager && device_supports_model_caching(plugin, parsed.m_config) && !is_proxy_device(plugin)) {
+ emplace_cache_dir_if_supported(parsed.m_config, plugin, cache_dir);
CacheContent cache_content{cache_manager,
parsed.m_core_config.get_enable_mmap(),
get_cache_model_path(config).string()};
@@ -900,14 +887,13 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
auto parsed =
parse_device_name_into_config(device_name, m_core_config, config_with_batch, is_proxy_device(device_name));
auto plugin = get_plugin(parsed.m_device_name);
- // will consume ov::cache_dir if plugin not support it
- const auto cache_manager =
- parsed.m_core_config.get_cache_config_for_device(plugin, parsed.m_config).m_cache_manager;
+ const auto& [cache_dir, cache_manager] = parsed.m_core_config.get_cache_config_for_device(plugin);
auto res = import_compiled_model(plugin, context, parsed.m_config, model);
// Skip caching for proxy plugin. HW plugin will load network from the cache
if (res) {
// hint::compiled_blob is set and imported skip compilation
} else if (cache_manager && device_supports_model_caching(plugin, parsed.m_config) && !is_proxy_device(plugin)) {
+ emplace_cache_dir_if_supported(parsed.m_config, plugin, cache_dir);
CacheContent cache_content{cache_manager,
parsed.m_core_config.get_enable_mmap(),
get_cache_model_path(config).string()};
@@ -930,16 +916,15 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
auto parsed = parse_device_config(device_name, m_core_config, config, false);
// in case of compile_model(file_name), we need to clear-up core-level properties
auto plugin = get_plugin(parsed.m_device_name);
- // will consume ov::cache_dir if plugin not support it
- const auto cache_manager =
- parsed.m_core_config.get_cache_config_for_device(plugin, parsed.m_config).m_cache_manager;
+ const auto& [cache_dir, cache_manager] = parsed.m_core_config.get_cache_config_for_device(plugin);
auto compiled_model = import_compiled_model(plugin, {}, parsed.m_config, model_path);
if (compiled_model) {
// hint::compiled_blob is set and imported skip compilation
} else if (cache_manager && device_supports_model_caching(plugin, parsed.m_config) && !is_proxy_device(plugin)) {
// Skip caching for proxy plugin. HW plugin will load network from the cache
- CoreConfig::remove_core_skip_cache_dir(parsed.m_config);
+ CoreConfig::remove_core(parsed.m_config);
+ emplace_cache_dir_if_supported(parsed.m_config, plugin, cache_dir);
CacheContent cache_content{cache_manager, parsed.m_core_config.get_enable_mmap(), model_path};
cache_content.m_blob_id =
ov::ModelCache::compute_hash(model_path, create_compile_config(plugin, parsed.m_config));
@@ -962,14 +947,13 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
OV_ITT_SCOPED_TASK(ov::itt::domains::OV, "Core::compile_model::from_memory");
auto parsed = parse_device_name_into_config(device_name, m_core_config, config);
auto plugin = get_plugin(parsed.m_device_name);
- // will consume ov::cache_dir if plugin not support it
- const auto cache_manager =
- parsed.m_core_config.get_cache_config_for_device(plugin, parsed.m_config).m_cache_manager;
+ const auto& [cache_dir, cache_manager] = parsed.m_core_config.get_cache_config_for_device(plugin);
auto compiled_model = import_compiled_model(plugin, {}, parsed.m_config);
// Skip caching for proxy plugin. HW plugin will load network from the cache
if (compiled_model) {
// hint::compiled_blob is set and imported skip compilation
} else if (cache_manager && device_supports_model_caching(plugin, parsed.m_config) && !is_proxy_device(plugin)) {
+ emplace_cache_dir_if_supported(parsed.m_config, plugin, cache_dir);
CacheContent cache_content{cache_manager, parsed.m_core_config.get_enable_mmap()};
cache_content.m_blob_id =
ov::ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed.m_config));
@@ -1377,35 +1361,7 @@ void ov::CoreImpl::set_property_for_device(const ov::AnyMap& config, const std::
{
std::lock_guard<std::mutex> lock(get_mutex());
created_plugins.reserve(m_plugins.size());
-
- // TODO: keep only:
- // core_config.set_and_update(config);
- // once GPU remove support of ov::cache_dir
- // CoreConfg::set_and_update will drop CACHE_DIR from config map
- // and updates core config with new ov::cache_dir
- if (device_name.empty()) {
- m_core_config.set_and_update(cfg_copy);
- } else {
- OPENVINO_SUPPRESS_DEPRECATED_START
- auto cache_it = cfg_copy.find(ov::cache_dir.name());
- if (cache_it != cfg_copy.end()) {
- m_core_config.set_cache_dir_for_device((cache_it->second).as<std::string>(), clear_device_name);
- cfg_copy.erase(cache_it);
- }
- OPENVINO_SUPPRESS_DEPRECATED_END
- // apply and remove core properties
- auto it = cfg_copy.find(ov::force_tbb_terminate.name());
- if (it != cfg_copy.end()) {
- auto flag = it->second.as<bool>();
- ov::threading::executor_manager()->set_property({{it->first, flag}});
- cfg_copy.erase(it);
- }
-
- it = cfg_copy.find(ov::enable_mmap.name());
- if (it != cfg_copy.end()) {
- cfg_copy.erase(it);
- }
- }
+ m_core_config.set_and_update(cfg_copy, clear_device_name);
if (!cfg_copy.empty()) {
auto base_desc = m_plugin_registry.find(clear_device_name);
@@ -1445,18 +1401,6 @@ void ov::CoreImpl::set_property_for_device(const ov::AnyMap& config, const std::
allowNotImplemented([&]() {
std::lock_guard<std::mutex> lock(get_mutex(plugin.first));
auto config_copy = cfg_copy;
- // TODO: remove once GPU remove explicit support of ov::cache_dir
- {
- OPENVINO_SUPPRESS_DEPRECATED_START
- if (device_supports_cache_dir(plugin.second)) {
- config_copy[ov::cache_dir.name()] =
- m_core_config.get_cache_config_for_device(plugin.second).m_cache_dir;
- } else if (config_copy.count(ov::cache_dir.name()) > 0) {
- // Remove "CACHE_DIR" from config if it is not supported by plugin
- config_copy.erase(ov::cache_dir.name());
- }
- OPENVINO_SUPPRESS_DEPRECATED_END
- }
// Add device specific value to support device_name.device_id cases
{
if (!parser.get_device_id().empty()) {
@@ -1519,14 +1463,6 @@ bool ov::CoreImpl::device_supports_model_caching(const ov::Plugin& plugin, const
: plugin.supports_model_caching();
}
-bool ov::CoreImpl::device_supports_cache_dir(const ov::Plugin& plugin) const {
- try {
- return util::contains(plugin.get_property(ov::supported_properties), ov::cache_dir);
- } catch (const ov::NotImplemented&) {
- return false;
- }
-}
-
ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model_and_cache(ov::Plugin& plugin,
const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& parsedConfig,
@@ -1724,33 +1660,32 @@ ov::CoreConfig::CoreConfig(const CoreConfig& other) {
m_flag_enable_mmap = other.m_flag_enable_mmap;
}
-void ov::CoreConfig::set(const ov::AnyMap& config) {
- auto it = config.find(ov::cache_dir.name());
- if (it != config.end()) {
- std::lock_guard<std::mutex> lock(m_cache_config_mutex);
- // fill global cache config
- m_cache_config = CoreConfig::CacheConfig::create(it->second.as<std::string>());
- // sets cache config per-device if it's not set explicitly before
- for (auto& deviceCfg : m_devices_cache_config) {
- deviceCfg.second = CoreConfig::CacheConfig::create(it->second.as<std::string>());
+void ov::CoreConfig::set(const ov::AnyMap& config, const std::string& device_name) {
+ if (const auto cfg_entry = config.find(ov::cache_dir.name()); cfg_entry != config.end()) {
+ const auto& cache_dir = cfg_entry->second.as<std::string>();
+ if (std::lock_guard<std::mutex> lock(m_cache_config_mutex); device_name.empty()) {
+ // fill global cache config
+ m_cache_config = CoreConfig::CacheConfig::create(cache_dir);
+ // sets cache config per-device if it's not set explicitly before
+ for (auto& device_cfg : m_devices_cache_config) {
+ device_cfg.second = CoreConfig::CacheConfig::create(cache_dir);
+ }
+ } else {
+ m_devices_cache_config[device_name] = CoreConfig::CacheConfig::create(cache_dir);
}
}
- it = config.find(ov::force_tbb_terminate.name());
- if (it != config.end()) {
- auto flag = it->second.as<bool>();
- ov::threading::executor_manager()->set_property({{it->first, flag}});
+ if (const auto cfg_entry = config.find(ov::force_tbb_terminate.name()); cfg_entry != config.end()) {
+ ov::threading::executor_manager()->set_property({*cfg_entry});
}
- it = config.find(ov::enable_mmap.name());
- if (it != config.end()) {
- auto flag = it->second.as<bool>();
- m_flag_enable_mmap = flag;
+ if (const auto cfg_entry = config.find(ov::enable_mmap.name()); cfg_entry != config.end()) {
+ m_flag_enable_mmap = cfg_entry->second.as<bool>();
}
}
-void ov::CoreConfig::set_and_update(ov::AnyMap& config) {
- set(config);
+void ov::CoreConfig::set_and_update(ov::AnyMap& config, const std::string& device_name) {
+ set(config, device_name);
remove_core(config);
}
@@ -1760,17 +1695,6 @@ void ov::CoreConfig::remove_core(ov::AnyMap& config) {
}
}
-void ov::CoreConfig::remove_core_skip_cache_dir(ov::AnyMap& config) {
- for (const auto& name : {ov::enable_mmap.name(), ov::force_tbb_terminate.name(), ov::cache_model_path.name()}) {
- config.erase(name);
- }
-}
-
-void ov::CoreConfig::set_cache_dir_for_device(const std::string& dir, const std::string& name) {
- std::lock_guard<std::mutex> lock(m_cache_config_mutex);
- m_devices_cache_config[name] = CoreConfig::CacheConfig::create(dir);
-}
-
std::string ov::CoreConfig::get_cache_dir() const {
std::lock_guard<std::mutex> lock(m_cache_config_mutex);
return m_cache_config.m_cache_dir;
@@ -1780,26 +1704,6 @@ bool ov::CoreConfig::get_enable_mmap() const {
return m_flag_enable_mmap;
}
-// Creating thread-safe copy of config including shared_ptr to ICacheManager
-// Passing empty or not-existing name will return global cache config
-ov::CoreConfig::CacheConfig ov::CoreConfig::get_cache_config_for_device(const ov::Plugin& plugin,
- ov::AnyMap& parsedConfig) const {
- // cache_dir is enabled locally in compile_model only
- if (parsedConfig.count(ov::cache_dir.name())) {
- const auto& cache_dir_val = parsedConfig.at(ov::cache_dir.name()).as<std::string>();
- const auto& tempConfig = CoreConfig::CacheConfig::create(cache_dir_val);
- // if plugin does not explicitly support cache_dir, and if plugin is not virtual, we need to remove
- // it from config
- if (!util::contains(plugin.get_property(ov::supported_properties), ov::cache_dir) &&
- !ov::is_virtual_device(plugin.get_name())) {
- parsedConfig.erase(ov::cache_dir.name());
- }
- return tempConfig;
- } else { // cache_dir is set to Core globally or for the specific device
- return get_cache_config_for_device(plugin);
- }
-}
-
ov::CoreConfig::CacheConfig ov::CoreConfig::get_cache_config_for_device(const ov::Plugin& plugin) const {
std::lock_guard<std::mutex> lock(m_cache_config_mutex);
return m_devices_cache_config.count(plugin.get_name()) ? m_devices_cache_config.at(plugin.get_name())
@@ -1834,7 +1738,7 @@ std::shared_ptr<ov::Model> ov::CoreImpl::read_model(const std::string& modelPath
const AnyMap& properties) const {
OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ReadTime, "CoreImpl::read_model from file");
auto local_core_config = m_core_config;
- local_core_config.set(properties);
+ local_core_config.set(properties, {});
return ov::util::read_model(modelPath, binPath, get_extensions_copy(), local_core_config.get_enable_mmap());
}
diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp
index 1dea47b0a18..3a3cd9b1841 100644
--- a/src/inference/src/dev/core_impl.hpp
+++ b/src/inference/src/dev/core_impl.hpp
@@ -34,29 +34,24 @@ public:
static CacheConfig create(const std::string& dir);
};
- void set(const ov::AnyMap& config);
+ void set(const ov::AnyMap& config, const std::string& device_name);
/**
* @brief Removes core-level properties from config and triggers new state for core config
- * @param config - config to be updated
+ * @param config config to be updated
+ * @param device_name device name for which config is applied (empty is for core-level)
*/
- void set_and_update(ov::AnyMap& config);
-
- OPENVINO_DEPRECATED("Don't use this method, it will be removed soon")
- void set_cache_dir_for_device(const std::string& dir, const std::string& name);
+ void set_and_update(ov::AnyMap& config, const std::string& device_name);
std::string get_cache_dir() const;
bool get_enable_mmap() const;
- CacheConfig get_cache_config_for_device(const ov::Plugin& plugin, ov::AnyMap& parsed_config) const;
-
// Creating thread-safe copy of global config including shared_ptr to ICacheManager
CacheConfig get_cache_config_for_device(const ov::Plugin& plugin) const;
// remove core properties
static void remove_core(ov::AnyMap& config);
- static void remove_core_skip_cache_dir(ov::AnyMap& config);
private:
mutable std::mutex m_cache_config_mutex{};
@@ -201,7 +196,6 @@ private:
std::shared_ptr<ov::threading::ExecutorManager> m_executor_manager;
mutable std::unordered_set<std::string> m_opset_names;
mutable std::vector<Extension::Ptr> m_extensions;
-
std::map<std::string, PluginDescriptor> m_plugin_registry;
ov::SoPtr<ov::ICompiledModel> compile_model_and_cache(ov::Plugin& plugin,
@@ -222,9 +216,6 @@ private:
bool device_supports_property(const ov::Plugin& plugin, const ov::PropertyName& key) const;
bool device_supports_internal_property(const ov::Plugin& plugin, const ov::PropertyName& key) const;
- OPENVINO_DEPRECATED("Don't use this method, it will be removed soon")
- bool device_supports_cache_dir(const ov::Plugin& plugin) const;
-
ov::AnyMap create_compile_config(const ov::Plugin& plugin, const ov::AnyMap& orig_config) const;
ov::AnyMap create_compile_config(const std::string& device_name, const ov::AnyMap& orig_config) const override {
return create_compile_config(get_plugin(device_name), orig_config);
diff --git a/src/inference/src/dev/iplugin.cpp b/src/inference/src/dev/iplugin.cpp
index d7dc6ae617e..422c7645592 100644
--- a/src/inference/src/dev/iplugin.cpp
+++ b/src/inference/src/dev/iplugin.cpp
@@ -78,7 +78,9 @@ std::shared_ptr<ov::ICompiledModel> ov::IPlugin::compile_model(const std::string
OPENVINO_ASSERT(core);
const auto model = core->read_model(model_path, {}, properties);
auto local_properties = properties;
- CoreConfig::remove_core_skip_cache_dir(local_properties);
+ if (!ov::is_virtual_device(get_device_name())) {
+ CoreConfig::remove_core(local_properties);
+ }
return compile_model(model, local_properties);
}
diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cpp
index d3b9e7fcad4..be08f8a224f 100644
--- a/src/inference/tests/functional/caching_test.cpp
+++ b/src/inference/tests/functional/caching_test.cpp
@@ -726,6 +726,7 @@ TEST_P(CachingTest, TestNoCacheEnabled) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
+ EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
testLoad([&](ov::Core& core) {
m_testFunction(core);
});
@@ -828,7 +829,7 @@ TEST_P(CachingTest, TestNoCacheMetric_hasCacheDirConfig) {
.Times(AtLeast(1))
.WillRepeatedly(Return(std::vector<ov::PropertyName>{}));
EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(1)).WillRepeatedly(Invoke([](const ov::AnyMap& config) {
- ASSERT_GT(config.count(ov::cache_dir.name()), 0);
+ ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
@@ -847,7 +848,7 @@ TEST_P(CachingTest, TestNoCacheMetric_hasCacheDirConfig) {
/// core.compile_model
TEST_P(CachingTest, TestNoCacheMetric_hasCacheDirConfig_inline) {
m_checkConfigCb = [](const ov::AnyMap& config) {
- EXPECT_NE(config.count(ov::cache_dir.name()), 0);
+ EXPECT_EQ(config.count(ov::cache_dir.name()), 0);
};
EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
.Times(AtLeast(1))
@@ -880,7 +881,7 @@ TEST_P(CachingTest, TestNoCacheMetric_hasCacheDirConfig_by_device_name) {
.Times(AtLeast(1))
.WillRepeatedly(Return(std::vector<ov::PropertyName>{}));
EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(1)).WillRepeatedly(Invoke([](const ov::AnyMap& config) {
- ASSERT_GT(config.count(ov::cache_dir.name()), 0);
+ ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
@@ -922,14 +923,12 @@ TEST_P(CachingTest, TestNoCacheMetric_configThrow) {
m_checkConfigCb = [](const ov::AnyMap& config) {
EXPECT_NE(config.count(ov::cache_dir.name()), 0);
};
- EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
- .Times(AtLeast(1))
- .WillRepeatedly(Return(std::vector<ov::PropertyName>{ov::supported_properties.name(), ov::cache_dir.name()}));
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(0);
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _))
.Times(AtLeast(1))
.WillRepeatedly(Return(std::vector<ov::PropertyName>{}));
EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(1)).WillRepeatedly(Invoke([](const ov::AnyMap& config) {
- ASSERT_GT(config.count(ov::cache_dir.name()), 0);
+ ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
OPENVINO_THROW("Error occurred");
}));
@@ -956,6 +955,7 @@ TEST_P(CachingTest, TestNoCacheEnabled_cacheDirConfig) {
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
testLoad([&](ov::Core& core) {
m_testFunction(core);
});
@@ -1004,7 +1004,15 @@ TEST_P(CachingTest, TestLoadChangeCacheDir) {
/// \brief Change CACHE_DIR during working with same 'Core' object. Verifies that new dir is used for caching
TEST_P(CachingTest, TestLoadChangeCacheDirOneCore) {
- EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const auto&, const auto&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
EXPECT_CALL(*mockPlugin, get_property(ov::device::capability::EXPORT_IMPORT, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
@@ -1014,9 +1022,20 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore) {
ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
- .Times(!m_remoteContext ? 2 : 0);
+ const auto newCacheDir = m_cacheDir + "2";
+ Expectation compile_1_ctx = EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(m_cacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(newCacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0)
+ .After(compile_1_ctx);
+ Expectation compile_1 = EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(),
+ Contains(ov::cache_dir(m_cacheDir))))
+ .Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(newCacheDir))))
+ .Times(!m_remoteContext ? 1 : 0)
+ .After(compile_1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
@@ -1025,7 +1044,6 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore) {
});
core.set_property(ov::cache_dir(m_cacheDir));
m_testFunction(core);
- std::string newCacheDir = m_cacheDir + "2";
m_post_mock_net_callbacks.pop_back();
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -1040,7 +1058,15 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore) {
/// \brief Change CACHE_DIR during working with same 'Core' object
/// Initially set for 'device', then is overwritten with global 'cache_dir' for all devices
TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_overwrite_device_dir) {
- EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const auto&, const auto&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
EXPECT_CALL(*mockPlugin, get_property(ov::device::capability::EXPORT_IMPORT, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
@@ -1050,9 +1076,20 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_overwrite_device_dir) {
ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
- .Times(!m_remoteContext ? 2 : 0);
+ std::string newCacheDir = m_cacheDir + "2";
+ Expectation compile_1_ctx = EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(m_cacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(newCacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0)
+ .After(compile_1_ctx);
+ Expectation compile_1 = EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(),
+ Contains(ov::cache_dir(m_cacheDir))))
+ .Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(newCacheDir))))
+ .Times(!m_remoteContext ? 1 : 0)
+ .After(compile_1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
@@ -1061,7 +1098,6 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_overwrite_device_dir) {
});
core.set_property("mock", ov::cache_dir(m_cacheDir));
m_testFunction(core);
- std::string newCacheDir = m_cacheDir + "2";
m_post_mock_net_callbacks.pop_back();
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -1073,16 +1109,21 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_overwrite_device_dir) {
}
}
-/// \brief Change CACHE_DIR during working with same 'Core' object for device which supports 'CACHE_DIR' config, not
-/// import_export Expectation is that set_property for plugin will be called 2 times - with appropriate cache_dir values
+/// \brief Change CACHE_DIR during working with same 'Core' object for device which supports 'CACHE_DIR' config, no
+/// import_export Expectation new cache dir used on compile_model
TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_SupportsCacheDir_NoImportExport) {
m_checkConfigCb = [](const ov::AnyMap& config) {
EXPECT_EQ(config.count(ov::cache_dir.name()), 0);
};
EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
.Times(AnyNumber())
- .WillRepeatedly(Return(std::vector<ov::PropertyName>{ov::supported_properties.name(), ov::cache_dir.name()}));
- EXPECT_CALL(*mockPlugin, get_property(ov::device::capabilities.name(), _)).Times(AnyNumber());
+ .WillRepeatedly(Invoke([&](const auto&, const auto&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
EXPECT_CALL(*mockPlugin, get_property(ov::device::capabilities.name(), _))
.Times(AnyNumber())
.WillRepeatedly(Return(decltype(ov::device::capabilities)::value_type{}));
@@ -1090,13 +1131,17 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_SupportsCacheDir_NoImportExpor
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
std::string set_cache_dir = {};
- EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(2)).WillRepeatedly(Invoke([&](const ov::AnyMap& config) {
- ASSERT_NE(config.count(ov::cache_dir.name()), 0);
- set_cache_dir = config.at(ov::cache_dir.name()).as<std::string>();
+ EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(1)).WillRepeatedly(Invoke([&](const ov::AnyMap& config) {
+ ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
+
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
+ const auto new_cache_dir = m_cacheDir + "2";
+ EXPECT_CALL(*mockPlugin, compile_model(_, Not(Contains(Key(ov::cache_dir.name()))), _))
+ .Times(m_remoteContext ? 2 : 0);
+ EXPECT_CALL(
+ *mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Not(Contains(Key(ov::cache_dir.name())))))
.Times(!m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 2 : 0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -1107,20 +1152,28 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_SupportsCacheDir_NoImportExpor
testLoad([&](ov::Core& core) {
core.set_property(ov::cache_dir(m_cacheDir));
m_testFunction(core);
- EXPECT_EQ(set_cache_dir, m_cacheDir);
+ EXPECT_NE(set_cache_dir, m_cacheDir);
- std::string new_cache_dir = m_cacheDir + "2";
MkDirGuard dir(new_cache_dir);
core.set_property(ov::cache_dir(new_cache_dir));
m_testFunction(core);
- EXPECT_EQ(set_cache_dir, new_cache_dir);
+ EXPECT_NE(set_cache_dir, new_cache_dir);
+ EXPECT_EQ(set_cache_dir, "");
});
}
}
/// \brief Change CACHE_DIR per device during working with same 'Core' object - expected that new cache dir is used
TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_by_device_name) {
- EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const auto&, const auto&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
EXPECT_CALL(*mockPlugin, get_property(ov::device::capability::EXPORT_IMPORT, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
@@ -1130,9 +1183,21 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_by_device_name) {
ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
- .Times(!m_remoteContext ? 2 : 0);
+ Expectation import_1_ctx = EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(m_cacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(m_cacheDir + "2")), _))
+ .Times(m_remoteContext ? 1 : 0)
+ .After(import_1_ctx);
+ Expectation import_1 = EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(),
+ Contains(ov::cache_dir(m_cacheDir))))
+ .Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(
+ *mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(m_cacheDir + "2"))))
+ .Times(!m_remoteContext ? 1 : 0)
+ .After(import_1);
+
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
@@ -1169,11 +1234,14 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_by_device_name_supports_cache_
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, set_property(_)).Times(AtLeast(2)).WillRepeatedly(Invoke([](const ov::AnyMap& config) {
- ASSERT_GT(config.count(ov::cache_dir.name()), 0);
+ ASSERT_EQ(config.count(ov::cache_dir.name()), 0);
}));
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
+ EXPECT_CALL(*mockPlugin, compile_model(_, Not(Contains(Key(std::string(ov::cache_dir.name())))), _))
+ .Times(m_remoteContext ? 2 : 0);
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(),
+ Not(Contains(Key(std::string(ov::cache_dir.name()))))))
.Times(!m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 2 : 0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -1214,6 +1282,7 @@ TEST_P(CachingTest, TestClearCacheDir) {
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0);
}
+ EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
testLoad([&](ov::Core& core) {
core.set_property(ov::cache_dir(m_cacheDir));
core.set_property(ov::cache_dir(""));
@@ -1224,15 +1293,25 @@ TEST_P(CachingTest, TestClearCacheDir) {
}
TEST_P(CachingTest, TestChangeOtherConfig) {
- EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const auto&, const auto&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
EXPECT_CALL(*mockPlugin, get_property(ov::device::capability::EXPORT_IMPORT, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::capabilities.name(), _)).Times(AnyNumber());
{
- EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
+ EXPECT_CALL(*mockPlugin, compile_model(_, Contains(ov::cache_dir(m_cacheDir)), _))
+ .Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(m_cacheDir))))
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
@@ -1930,6 +2009,7 @@ TEST_P(CachingTest, LoadHetero_NoCacheMetric) {
EXPECT_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _))
.Times(AnyNumber())
.WillRepeatedly(Return(std::vector<ov::PropertyName>{}));
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 1);
// Hetero supports Import/Export, but mock plugin does not
deviceToLoad = ov::test::utils::DEVICE_HETERO + std::string(":mock.1,mock.2");
if (m_remoteContext) {
@@ -1961,6 +2041,7 @@ TEST_P(CachingTest, LoadHetero_OneDevice) {
return; // skip the remote Context test for Hetero plugin
}
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 1);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -1977,6 +2058,7 @@ TEST_P(CachingTest, LoadHetero_OneDevice) {
}
m_post_mock_net_callbacks.pop_back();
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -2000,6 +2082,7 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) {
return; // skip the remote Context test for Hetero plugin
}
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(1);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -2017,6 +2100,7 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) {
}
m_post_mock_net_callbacks.pop_back();
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 0);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -2070,6 +2154,7 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
return; // skip the remote Context test for Hetero plugin
}
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 3);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(AtLeast(2)); // for .1 and for .51
@@ -2088,6 +2173,7 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
deviceToLoad = ov::test::utils::DEVICE_HETERO + std::string(":mock.2,mock.52");
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -2103,6 +2189,7 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
deviceToLoad = ov::test::utils::DEVICE_HETERO + std::string(":mock.53,mock.3");
m_post_mock_net_callbacks.pop_back();
{
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 3);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(AtLeast(1));
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
@@ -2132,6 +2219,7 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) {
return "mock_another_architecture";
}
}));
+ EXPECT_CALL(*mockPlugin, get_default_context(_)).Times(m_remoteContext ? 0 : 2);
deviceToLoad = ov::test::utils::DEVICE_HETERO;
if (m_remoteContext) {
return; // skip the remote Context test for Hetero plugin
@@ -2203,7 +2291,9 @@ TEST_P(CachingTest, LoadAUTO_OneDevice) {
for (int index = 0; index < TEST_COUNT; index++) {
deviceToLoad = ov::test::utils::DEVICE_AUTO;
deviceToLoad += ":mock.0";
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
+ EXPECT_CALL(
+ *mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Not(Contains(Key(ov::cache_dir.name())))))
.Times(TEST_COUNT - index - 1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
@@ -2222,6 +2312,15 @@ TEST_P(CachingTest, LoadAUTOWithConfig) {
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const std::string&, const ov::AnyMap&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
// skip the remote Context test for Auto plugin
if (m_remoteContext) {
return;
@@ -2235,7 +2334,8 @@ TEST_P(CachingTest, LoadAUTOWithConfig) {
for (; index < TEST_COUNT; index++) {
deviceToLoad = ov::test::utils::DEVICE_AUTO;
deviceToLoad += ":mock.0";
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(cacheDir))))
.Times(TEST_COUNT - index - 1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
@@ -2744,6 +2844,15 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
+ EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _))
+ .Times(AnyNumber())
+ .WillRepeatedly(Invoke([&](const std::string&, const ov::AnyMap&) {
+ return std::vector<ov::PropertyName>{ov::supported_properties.name(),
+ ov::device::capabilities.name(),
+ ov::device::architecture.name(),
+ ov::internal::caching_properties.name(),
+ ov::cache_dir.name()};
+ }));
if (m_remoteContext) {
return; // skip the remote Context test for Multi plugin
}
@@ -2752,14 +2861,19 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
MkDirGuard guard(m_cacheDir);
+ auto new_cache_dir = m_cacheDir + "2";
+ MkDirGuard g2uard(new_cache_dir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
+ EXPECT_CALL(*mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Contains(ov::cache_dir(m_cacheDir))))
+ .Times(1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(1);
EXPECT_CALL(*mockPlugin, import_model(A<const ov::Tensor&>(), _, _)).Times(0);
EXPECT_CALL(*mockPlugin, import_model(A<const ov::Tensor&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
+ core.set_property(ov::cache_dir(new_cache_dir));
const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}, {ov::enable_mmap(false)}};
m_testFunctionWithCfg(core, config);
m_testFunctionWithCfg(core, config);
diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
index ac7d7263b84..d5ef4a1e2c3 100644
--- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
+++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
@@ -249,7 +249,7 @@ std::shared_ptr<Graph> CompiledModel::get_graph(size_t n) const {
ov::Any CompiledModel::get_property(const std::string& name) const {
if (name == ov::supported_properties) {
- return decltype(ov::supported_properties)::value_type {
+ return decltype(ov::supported_properties)::value_type{
// Metrics
ov::PropertyName{ov::supported_properties.name(), PropertyMutability::RO},
ov::PropertyName{ov::model_name.name(), PropertyMutability::RO},
diff --git a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp
index 37b8eb5260f..d5aa024dd31 100644
--- a/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp
+++ b/src/plugins/intel_gpu/tests/functional/subgraph_tests/dynamic/kv_cache.cpp
@@ -71,6 +71,7 @@ TEST_P(KVCacheTest, Inference_cached) {
ov::test::utils::removeFilesWithExt(cacheDirName, "blob");
ov::test::utils::removeFilesWithExt(cacheDirName, "cl_cache");
ov::test::utils::removeDir(cacheDirName);
+ core->set_property(ov::cache_dir(cacheDirName));
configuration.insert(ov::cache_dir(cacheDirName));
compile_model();
}