@@ -777,7 +777,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
777
777
if (cacheManager && device_supports_model_caching (plugin, parsed._config ) && !is_proxy_device (plugin)) {
778
778
CacheContent cacheContent{cacheManager, parsed._core_config .get_enable_mmap ()};
779
779
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
+ }
781
785
std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock (cacheContent.blobId );
782
786
res = load_model_from_cache (cacheContent, plugin, parsed._config , ov::SoPtr<ov::IRemoteContext>{}, [&]() {
783
787
return compile_model_and_cache (plugin,
@@ -813,7 +817,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
813
817
CacheContent cacheContent{cacheManager, parsed._core_config .get_enable_mmap ()};
814
818
cacheContent.blobId = ov::ModelCache::compute_hash (model, create_compile_config (plugin, parsed._config ));
815
819
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
+ }
817
825
res = load_model_from_cache (cacheContent, plugin, parsed._config , context, [&]() {
818
826
return compile_model_and_cache (plugin, model, parsed._config , context, cacheContent);
819
827
});
0 commit comments