30
30
#include " openvino/runtime/threading/executor_manager.hpp"
31
31
#include " openvino/util/common_util.hpp"
32
32
#include " openvino/util/file_util.hpp"
33
+ #include " openvino/util/log.hpp"
33
34
#include " openvino/util/shared_object.hpp"
34
35
#include " openvino/util/variant_visitor.hpp"
35
36
#include " openvino/util/xml_parse_utils.hpp"
@@ -851,6 +852,16 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
851
852
const auto compiled_config = create_compile_config (plugin, parsed._config );
852
853
cache_content.blobId = ModelCache::compute_hash (model, cache_content.modelPath , compiled_config);
853
854
cache_content.model = model;
855
+
856
+ const auto & cache_mode_it = config.find (cache_mode.name ());
857
+ if (cache_mode_it != config.end () && cache_mode_it->second == CacheMode::OPTIMIZE_SIZE) {
858
+ const auto & rt_info = model->get_rt_info ();
859
+ auto weights_path = rt_info.find (" __weights_path" );
860
+ if (weights_path != rt_info.end ()) {
861
+ parsed._config [ov::weights_path.name ()] = weights_path->second ;
862
+ }
863
+ }
864
+
854
865
const auto lock = cacheGuard.get_hash_lock (cache_content.blobId );
855
866
res = load_model_from_cache (cache_content, plugin, parsed._config , {}, [&]() {
856
867
return compile_model_and_cache (plugin, model, parsed._config , {}, cache_content);
@@ -1594,10 +1605,6 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
1594
1605
update_config[ov::hint::model.name ()] = cacheContent.model ;
1595
1606
}
1596
1607
1597
- if (util::contains (plugin.get_property (ov::supported_properties), ov::hint::model) &&
1598
- cacheContent.model ) {
1599
- update_config[ov::hint::model.name ()] = cacheContent.model ;
1600
- }
1601
1608
if (util::contains (plugin.get_property (ov::supported_properties), ov::weights_path)) {
1602
1609
util::Path weights_path;
1603
1610
@@ -1606,7 +1613,6 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
1606
1613
weights_path = path_hint->second .as <std::string>();
1607
1614
} else if (weights_path = extract_weight_path (header.get_runtime_info ()); weights_path.empty ()) {
1608
1615
weights_path = cacheContent.modelPath ;
1609
- weights_path.replace_extension (" .bin" );
1610
1616
}
1611
1617
weights_path.replace_extension (" .bin" );
1612
1618
@@ -1638,9 +1644,11 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
1638
1644
// throw;
1639
1645
}
1640
1646
1641
- // fallback scenario
1642
- if (!compiled_model)
1647
+ // Fallback scenario
1648
+ if (!compiled_model) {
1649
+ OPENVINO_WARN (" Could not load model from cache." );
1643
1650
compiled_model = compile_model_lambda ();
1651
+ }
1644
1652
1645
1653
return compiled_model;
1646
1654
}
0 commit comments