Skip to content

Commit 6fec065

Browse files
e-ddykimmryzhov
andauthored
Updated to set cacheContent.model only for OPTIMIZE_SIZE mode (#29805)
### Details: - backport from #29804 ### Tickets: - 164342 --------- Co-authored-by: Mikhail Ryzhov <mikhail.ryzhov@intel.com>
1 parent 3faa160 commit 6fec065

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/inference/src/dev/core_impl.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
777777
if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {
778778
CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};
779779
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
780-
cacheContent.model = std::const_pointer_cast<ov::Model>(model);
780+
if (auto mode_it = parsed._config.find(ov::cache_mode.name()); mode_it != parsed._config.end()) {
781+
if (mode_it->second.as<ov::CacheMode>() == ov::CacheMode::OPTIMIZE_SIZE) {
782+
cacheContent.model = std::const_pointer_cast<ov::Model>(model);
783+
}
784+
}
781785
std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
782786
res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() {
783787
return compile_model_and_cache(plugin,
@@ -813,7 +817,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
813817
CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};
814818
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
815819
std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
816-
cacheContent.model = std::const_pointer_cast<ov::Model>(model);
820+
if (auto mode_it = parsed._config.find(ov::cache_mode.name()); mode_it != parsed._config.end()) {
821+
if (mode_it->second.as<ov::CacheMode>() == ov::CacheMode::OPTIMIZE_SIZE) {
822+
cacheContent.model = std::const_pointer_cast<ov::Model>(model);
823+
}
824+
}
817825
res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() {
818826
return compile_model_and_cache(plugin, model, parsed._config, context, cacheContent);
819827
});

0 commit comments

Comments
 (0)