Skip to content

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

[core]Feature/weight sharing properties (#34282)

Pawel Raasz26e55ee6632f
diff --git a/src/inference/dev_api/openvino/runtime/internal_properties.hpp b/src/inference/dev_api/openvino/runtime/internal_properties.hpp
index 88f3be80643..606bff44076 100644
--- a/src/inference/dev_api/openvino/runtime/internal_properties.hpp
+++ b/src/inference/dev_api/openvino/runtime/internal_properties.hpp
@@ -13,6 +13,10 @@
#include "openvino/runtime/properties.hpp"
#include "openvino/runtime/threading/istreams_executor.hpp"
+namespace ov::weight_sharing {
+struct Context;
+}
+
namespace ov {
namespace internal {
@@ -169,5 +173,16 @@ static constexpr Property<CacheQuantMode, PropertyMutability::RW> key_cache_quan
*/
static constexpr Property<CacheQuantMode, PropertyMutability::RW> value_cache_quant_mode{"VALUE_CACHE_QUANT_MODE"};
+
+using WeightSharingCtxPtr = std::shared_ptr<const weight_sharing::Context>;
+
+/**
+ * @brief Property to pass weight sharing context.
+ *
+ * The property is used to pass weight sharing context to plugins on model compile/import.
+ * The property can be retrieved from a compiled model to get the weight sharing context
+ * for further sharing of weights between models.
+ */
+inline constexpr Property<WeightSharingCtxPtr, PropertyMutability::RW> model_sharing_context{"MODEL_SHARING_CONTEXT"};
} // namespace internal
} // namespace ov
diff --git a/src/inference/include/openvino/runtime/properties.hpp b/src/inference/include/openvino/runtime/properties.hpp
index e12652a3634..0b1ef8c3628 100644
--- a/src/inference/include/openvino/runtime/properties.hpp
+++ b/src/inference/include/openvino/runtime/properties.hpp
@@ -721,6 +721,30 @@ static constexpr Property<Level> level{"LOG_LEVEL"};
*/
static constexpr Property<std::string> cache_dir{"CACHE_DIR"};
+/**
+ * @brief This property defines the path which will be used to store any data cached by plugins.
+ * @ingroup ov_runtime_cpp_prop_api
+ *
+ * The underlying cache structure is not defined and might differ between OpenVINO releases
+ * Cached data might be platform / device specific and might be invalid after OpenVINO version change
+ *
+ * If the path is a directory, it has the same effect as the `cache_dir` property. Regular caching is used in this case.
+ *
+ * If this property is not specified or value is empty string, then caching is disabled.
+ * The property might enable caching for the plugin using the following code:
+ *
+ * @code
+ * ie.set_property("GPU", ov::cache_path("cache/")); // enables cache for GPU plugin
+ * @endcode
+ *
+ * The following code enables caching of compiled network blobs for devices where import/export is supported
+ *
+ * @code
+ * ie.set_property(ov::cache_path("cache/")); // enables models cache
+ * @endcode
+ */
+inline constexpr Property<std::filesystem::path> cache_path{"CACHE_PATH"};
+
/**
* @brief Read-only property to notify user that compiled model was loaded from the cache
* @ingroup ov_runtime_cpp_prop_api
@@ -736,6 +760,26 @@ static constexpr Property<bool, PropertyMutability::RO> loaded_from_cache{"LOADE
*/
static inline constexpr Property<std::filesystem::path, PropertyMutability::WO> cache_model_path{"CACHE_MODEL_PATH"};
+/**
+ * @brief The property allows setting a user ID for a cache entry.
+ *
+ * This overrides the internal ID generation mechanism and the user must manage the ID. If defined by the user, the
+ * same ID must be used to restore the model from the cache; otherwise, the model will be compiled.
+ * The custom ID can allow importing a model from the cache file without the original model.
+ *
+ * The following code allows to compile a model with a custom ID.
+ * @code
+ * // store compiled model to cache with ID "746352"
+ * core.compile_model(model, "NPU", ov::AnyMap{ov::cache_blob_id("746352"), ov::cache_path("cache_dir")});
+ * @endcode
+ *
+ * The following code allows to import a model from the cache if the original model is not available.
+ * @code
+ * core.compile_model(empty_model, "NPU", ov::AnyMap{ov::cache_blob_id("746352"), ov::cache_path("cache_dir")});
+ * @endcode
+ */
+inline constexpr Property<uint64_t, PropertyMutability::RW> cache_blob_id{"CACHE_BLOB_ID"};
+
/**
* @brief Enum to define possible workload types
*
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index 3fa58f6fed5..6f159fe918b 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -5,6 +5,7 @@
#include "core_impl.hpp"
#include <memory>
+#include <optional>
#include <variant>
#include "check_network_batchable.hpp"
@@ -73,16 +74,16 @@ void stripDeviceName(std::string& device, const std::string& substr) {
/**
* @brief Converts / flattens ov::device::properties from
* @code
- * core.compile_model(model, "GPU", ov::device::properties("GPU", ov::cache_dir("/tmp")));
+ * core.compile_model(model, "GPU", ov::device::properties("GPU", ov::cache_path("/tmp")));
* // or
* core.compile_model(model, "GPU", ov::device::properties({
- * { "GPU", ov::cache_dir("/tmp") },
- * { "CPU", ov::cache_dir("") }
+ * { "GPU", ov::cache_path("/tmp") },
+ * { "CPU", ov::cache_path("") }
* }));
* @endcode
* To the form:
* @code
- * core.compile_model(model, "GPU", ov::cache_dir("/tmp"));
+ * core.compile_model(model, "GPU", ov::cache_path("/tmp"));
* @endcode
*
* @param user_device_name A device name for which properties flattening is performed
@@ -208,9 +209,11 @@ void clean_batch_properties(const std::string& device_name, ov::AnyMap& config,
}
static const auto core_properties_names = ov::util::make_array(ov::cache_dir.name(),
+ ov::cache_path.name(),
+ ov::cache_model_path.name(),
+ ov::cache_blob_id.name(),
ov::enable_mmap.name(),
- ov::force_tbb_terminate.name(),
- ov::cache_model_path.name());
+ ov::force_tbb_terminate.name());
static const auto auto_batch_properties_names =
ov::util::make_array(ov::auto_batch_timeout.name(), ov::hint::allow_auto_batching.name());
@@ -281,6 +284,14 @@ std::vector<ov::Extension::Ptr> try_get_extensions(std::shared_ptr<void>& so) {
return {};
}
}
+
+std::string get_blob_id_or_compute(const ov::AnyMap& user_config, std::function<std::string()>&& calculate_blob_id) {
+ if (auto blob_id_hint = user_config.find(ov::cache_blob_id.name()); blob_id_hint != user_config.end()) {
+ return blob_id_hint->second.as<std::string>();
+ } else {
+ return calculate_blob_id();
+ }
+}
} // namespace
bool ov::is_config_applicable(const std::string& user_device_name, const std::string& subprop_device_name) {
@@ -395,6 +406,25 @@ ov::Parsed parse_device_config(const std::string& device_name,
return parsed;
}
+std::optional<std::filesystem::path> get_cache_path_from_config(const ov::AnyMap& config) {
+ const auto cache_dir_it = config.find(ov::cache_dir.name());
+ const auto cache_path_it = config.find(ov::cache_path.name());
+
+ if (cache_dir_it != config.end() && cache_path_it != config.end()) {
+ OPENVINO_THROW("Set cache path by '",
+ ov::cache_path.name(),
+ "' or '",
+ ov::cache_dir.name(),
+ "' property. Both set in configuration.");
+ } else if (cache_dir_it != config.end()) {
+ return std::make_optional(ov::util::make_path(cache_dir_it->second.as<std::string>()));
+ } else if (cache_path_it != config.end()) {
+ return std::make_optional(cache_path_it->second.as<std::filesystem::path>());
+ } else {
+ return std::nullopt;
+ }
+}
+
void emplace_cache_dir_if_supported(ov::AnyMap& config,
const ov::Plugin& plugin,
const std::filesystem::path& cache_dir) {
@@ -841,7 +871,9 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
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)};
const auto compiled_config = create_compile_config(plugin, parsed.m_config);
- cache_content.m_blob_id = ModelCache::compute_hash(model, cache_content.m_model_path, compiled_config);
+ cache_content.m_blob_id = get_blob_id_or_compute(config, [&] {
+ return ModelCache::compute_hash(model, cache_content.m_model_path, compiled_config);
+ });
cache_content.model = model;
const auto& cache_mode_it = config.find(cache_mode.name());
@@ -886,7 +918,9 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
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)};
const auto compiled_config = create_compile_config(plugin, parsed.m_config);
- cache_content.m_blob_id = ModelCache::compute_hash(model, cache_content.m_model_path, compiled_config);
+ cache_content.m_blob_id = get_blob_id_or_compute(config, [&] {
+ return ModelCache::compute_hash(model, cache_content.m_model_path, compiled_config);
+ });
cache_content.model = model;
res = load_model_from_cache(cache_content, plugin, parsed.m_config, context, [&]() {
return compile_model_and_cache(plugin, model, parsed.m_config, context, cache_content);
@@ -914,8 +948,9 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::filesystem:
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(cache_content.m_model_path, create_compile_config(plugin, parsed.m_config));
+ cache_content.m_blob_id = get_blob_id_or_compute(config, [&] {
+ return ModelCache::compute_hash(cache_content.m_model_path, create_compile_config(plugin, parsed.m_config));
+ });
const auto lock = m_cache_guard.get_hash_lock(cache_content.m_blob_id);
compiled_model = load_model_from_cache(cache_content, plugin, parsed.m_config, {}, [&]() {
const auto model =
@@ -943,8 +978,9 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
} 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));
+ cache_content.m_blob_id = get_blob_id_or_compute(config, [&] {
+ return ModelCache::compute_hash(model_str, weights, create_compile_config(plugin, parsed.m_config));
+ });
const auto lock = m_cache_guard.get_hash_lock(cache_content.m_blob_id);
compiled_model = load_model_from_cache(cache_content, plugin, parsed.m_config, {}, [&]() {
const auto model = read_model(model_str, weights);
@@ -1248,6 +1284,8 @@ ov::Any ov::CoreImpl::get_property_for_core(const std::string& name) const {
return decltype(ov::force_tbb_terminate)::value_type(flag);
} else if (name == ov::cache_dir.name()) {
return ov::Any(util::path_to_string(m_core_config.get_cache_dir()));
+ } else if (name == ov::cache_path.name()) {
+ return {m_core_config.get_cache_dir()};
} else if (name == ov::enable_mmap.name()) {
const auto flag = m_core_config.get_enable_mmap();
return decltype(ov::enable_mmap)::value_type(flag);
@@ -1279,6 +1317,8 @@ ov::Any ov::CoreImpl::get_property(const std::string& device_name,
} else if (name == ov::cache_dir.name()) {
return util::path_to_string(
m_core_config.get_cache_config_for_device(get_plugin(parsed.m_device_name)).m_cache_dir);
+ } else if (name == ov::cache_path.name()) {
+ return {m_core_config.get_cache_config_for_device(get_plugin(parsed.m_device_name)).m_cache_dir};
}
return get_plugin(parsed.m_device_name).get_property(name, parsed.m_config);
}
@@ -1644,17 +1684,16 @@ ov::CoreConfig::CoreConfig(const CoreConfig& other) {
}
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 = util::make_path(cfg_entry->second.as<std::string>());
+ if (const auto cache_path = get_cache_path_from_config(config); cache_path.has_value()) {
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);
+ m_cache_config = CoreConfig::CacheConfig::create(*cache_path);
// 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);
+ device_cfg.second = CoreConfig::CacheConfig::create(*cache_path);
}
} else {
- m_devices_cache_config[device_name] = CoreConfig::CacheConfig::create(cache_dir);
+ m_devices_cache_config[device_name] = CoreConfig::CacheConfig::create(*cache_path);
}
}
@@ -1694,12 +1733,14 @@ ov::CoreConfig::CacheConfig ov::CoreConfig::get_cache_config_for_device(const ov
}
ov::CoreConfig::CacheConfig ov::CoreConfig::CacheConfig::create(const std::filesystem::path& dir) {
- CacheConfig cache_config{dir, nullptr};
- if (!dir.empty()) {
+ auto cfg = CacheConfig{dir, nullptr};
+ if (dir.extension() == ".bin") {
+ OPENVINO_NOT_IMPLEMENTED;
+ } else if (!dir.empty()) {
ov::util::create_directory_recursive(dir);
- cache_config.m_cache_manager = std::make_shared<ov::FileStorageCacheManager>(dir);
+ cfg.m_cache_manager = std::make_shared<FileStorageCacheManager>(dir);
}
- return cache_config;
+ return cfg;
}
std::mutex& ov::CoreImpl::get_mutex(const std::string& dev_name) const {
diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cpp
index 5a16ca3c070..39dd60dac60 100644
--- a/src/inference/tests/functional/caching_test.cpp
+++ b/src/inference/tests/functional/caching_test.cpp
@@ -2383,7 +2383,7 @@ TEST_P(CachingTest, LoadAUTO_OneDevice) {
.Times(TEST_COUNT - index - 1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
- core.set_property(ov::cache_dir(cacheDir));
+ core.set_property(ov::cache_path(cacheDir));
m_testFunction(core);
}));
}
@@ -2425,7 +2425,7 @@ TEST_P(CachingTest, LoadAUTOWithConfig) {
.Times(TEST_COUNT - index - 1);
EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
- m_testFunctionWithCfg(core, {{ov::cache_dir.name(), cacheDir}});
+ m_testFunctionWithCfg(core, {{ov::cache_path.name(), cacheDir}});
}));
}
std::cout << "Caching LoadAuto Test completed. Tried " << index << " times" << std::endl;
@@ -2959,8 +2959,8 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
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)}};
+ core.set_property(ov::cache_path(new_cache_dir));
+ const auto config = ov::AnyMap{{ov::cache_path(m_cacheDir)}, {ov::enable_mmap(false)}};
m_testFunctionWithCfg(core, config);
m_testFunctionWithCfg(core, config);
});
@@ -3050,7 +3050,7 @@ TEST_P(CachingTest, import_from_cache_model_and_weights_path_properties_are_supp
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) {
- const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}};
+ const auto config = ov::AnyMap{{ov::cache_path(m_cacheDir)}};
m_testFunctionWithCfg(core, config);
// load from cache
m_testFunctionWithCfg(core, config);
@@ -3151,6 +3151,64 @@ TEST_P(CachingTest, import_from_cache_model_by_custom_model_rt_info) {
});
}
+TEST_P(CachingTest, compile_and_import_from_cache_model_by_custom_id) {
+ ON_CALL(*mockPlugin, import_model(A<const ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](const ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 0);
+ EXPECT_EQ(config.count(ov::hint::model.name()), 0);
+ EXPECT_EQ(config.count(ov::weights_path.name()), 0);
+
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
+ EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
+ 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());
+ if (m_remoteContext) {
+ return; // skip the remote Context test for Multi plugin
+ }
+ m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
+ EXPECT_CALL(net, export_model(_)).Times(1);
+ });
+ MkDirGuard guard(m_cacheDir);
+ EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
+ EXPECT_CALL(
+ *mockPlugin,
+ compile_model(A<const std::shared_ptr<const ov::Model>&>(), Not(Contains(Key(ov::cache_blob_id.name())))))
+ .Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(2);
+ 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) {
+ const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}, ov::cache_blob_id(100)};
+
+ // read and load model with custom ID
+ performReadAndLoad(core, config);
+
+ // import model with custom ID
+ performReadAndLoadWithContext(core, config);
+
+ // import model with custom ID
+ performReadAndLoad(core, config);
+
+ // import model with custom ID and empty model
+ auto empty_model = std::make_shared<ov::Model>(ov::ResultVector{}, ov::ParameterVector{}, "empty");
+ auto compiled_model = core.compile_model(empty_model, deviceToLoad, config);
+ EXPECT_TRUE(compiled_model);
+ });
+}
+
+TEST_P(CachingTest, test_cache_path_as_file) {
+ GTEST_SKIP() << "Not implemented yet";
+}
+
#if defined(ENABLE_OV_IR_FRONTEND)
static std::string getTestCaseName(const testing::TestParamInfo<std::tuple<TestParam, std::string>>& obj) {
diff --git a/src/inference/tests/functional/get_supported_property_test.cpp b/src/inference/tests/functional/get_supported_property_test.cpp
index 2b27af26ded..5843a55fcc8 100644
--- a/src/inference/tests/functional/get_supported_property_test.cpp
+++ b/src/inference/tests/functional/get_supported_property_test.cpp
@@ -126,6 +126,16 @@ TEST(PropertyTest, SetCacheDirPropertyCoreNoThrow) {
EXPECT_EQ(value.as<std::string>(), std::string("./tmp_cache_dir"));
}
+TEST(PropertyTest, SetCachePathPropertyCoreNoThrow) {
+ ov::Core core;
+
+ // ov::cache_path property test
+ ov::Any value;
+ OV_ASSERT_NO_THROW(core.set_property(ov::cache_path("./tmp_cache_dir")));
+ OV_ASSERT_NO_THROW(value = core.get_property(ov::cache_path.name()));
+ EXPECT_EQ(value.as<std::filesystem::path>(), std::filesystem::path("./tmp_cache_dir"));
+}
+
TEST(PropertyTest, SetTBBForceTerminatePropertyCoreNoThrow) {
ov::Core core;
diff --git a/src/inference/tests/functional/local_test.cpp b/src/inference/tests/functional/local_test.cpp
index af12221f5d7..b12e1482887 100644
--- a/src/inference/tests/functional/local_test.cpp
+++ b/src/inference/tests/functional/local_test.cpp
@@ -7,6 +7,7 @@
#include "common_test_utils/file_utils.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
#include "common_test_utils/subgraph_builders/split_multi_conv_concat.hpp"
+#include "common_test_utils/test_assertions.hpp"
#include "openvino/op/roi_align.hpp"
#include "openvino/op/util/rnn_cell_base.hpp"
#include "openvino/runtime/core.hpp"
@@ -291,11 +292,15 @@ TEST_F(LocaleTests, DISABLED_WithUSLocaleCPP) {
class LocaleTestsWithCacheDir : public ::testing::Test {
std::string originalLocale;
- std::string cache_dir = "test_cache";
+ std::string cache_dir;
std::shared_ptr<ov::Model> model;
public:
protected:
+ const std::shared_ptr<ov::Model>& get_test_model() const {
+ return model;
+ }
+
void SetUp() override {
originalLocale = setlocale(LC_ALL, nullptr);
model = ov::test::utils::make_split_multi_conv_concat();
@@ -306,7 +311,8 @@ protected:
ov::test::utils::removeDir(cache_dir);
}
}
- void testBody() const {
+
+ void testBody(const std::pair<std::string, ov::Any>& cache_prop) {
std::map<ov::Output<ov::Node>, ov::Tensor> inputs;
for (const auto& input : model->inputs()) {
auto tensor = ov::test::utils::create_and_fill_tensor_normal_distribution(input.get_element_type(),
@@ -318,7 +324,7 @@ protected:
}
ov::Core core;
- ov::AnyMap properties = {ov::hint::inference_precision(ov::element::f32), ov::cache_dir(cache_dir)};
+ ov::AnyMap properties = {ov::hint::inference_precision(ov::element::f32), cache_prop};
auto getOutputBlob = [&]() {
auto compiled_model = core.compile_model(model, "CPU", properties);
@@ -336,17 +342,34 @@ protected:
auto output_from_model_cached = getOutputBlob();
ov::test::utils::compare(output_from_model_read, output_from_model_cached);
- ov::test::utils::removeFilesWithExt(cache_dir, "blob");
+
+ if (cache_prop.first == ov::cache_path.name()) {
+ cache_dir = cache_prop.second.as<std::filesystem::path>().string();
+ ov::test::utils::removeFilesWithExt(cache_dir, "blob");
+ } else if (cache_prop.first == ov::cache_dir.name()) {
+ cache_dir = cache_prop.second.as<std::string>();
+ ov::test::utils::removeFilesWithExt(cache_dir, "blob");
+ }
}
};
TEST_F(LocaleTestsWithCacheDir, WithRULocale) {
setlocale(LC_ALL, "ru_RU.UTF-8");
- testBody();
+ OV_ASSERT_NO_THROW(testBody(ov::cache_dir("test_cache")));
+ OV_ASSERT_NO_THROW(testBody(ov::cache_path("test_cache")));
}
TEST_F(LocaleTestsWithCacheDir, WithUSLocale) {
setlocale(LC_ALL, "en_US.UTF-8");
- testBody();
+ OV_ASSERT_NO_THROW(testBody(ov::cache_dir("test_cache")));
+ OV_ASSERT_NO_THROW(testBody(ov::cache_path("test_cache")));
+}
+
+TEST_F(LocaleTestsWithCacheDir, EnableCachingPropertyCollision) {
+ ov::Core core;
+ OV_EXPECT_THROW(
+ core.compile_model(get_test_model(), "CPU", {ov::cache_dir("test_cache"), ov::cache_path("test_cache")}),
+ ov::Exception,
+ _);
}
#endif // defined(ENABLE_OV_IR_FRONTEND)