OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[NPUW] Apply preprocessing to MODEL_PTR cached model (#30676)
Alexey Smirnov2d1577300ded
diff --git a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cppindex 7f815412741..e5491c715f4 100644--- a/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp+++ b/src/plugins/intel_npu/src/plugin/npuw/compiled_model.cpp@@ -985,7 +985,7 @@ std::shared_ptr<ov::npuw::CompiledModel> ov::npuw::CompiledModel::deserialize(// Initialize weights stream if weightless flowstd::string weights_path;- std::shared_ptr<const ov::Model> model_ptr;+ std::shared_ptr<ov::Model> model_ptr;// Cache model's constantsWeightsContext::ConstsCache consts_cache;if (is_weightless) {@@ -994,10 +994,17 @@ std::shared_ptr<ov::npuw::CompiledModel> ov::npuw::CompiledModel::deserialize(NPUW_ASSERT(!weights_path.empty() &&"Empty weights_path. Please provide WEIGHTS_PATH or MODEL_PTR in the configuration.");} else if (properties.find(ov::hint::model.name()) != properties.end()) {- model_ptr = properties.at(ov::hint::model.name()).as<std::shared_ptr<const ov::Model>>();+ model_ptr = std::const_pointer_cast<ov::Model>(+ properties.at(ov::hint::model.name()).as<std::shared_ptr<const ov::Model>>())+ ->clone();NPUW_ASSERT(model_ptr &&"Empty model passed in MODEL_PTR. Please provide WEIGHTS_PATH or MODEL_PTR in the configuration.");+ // NOTE: very important to do preprocessing here since MODEL_PTR contains the original model+ // without any plugin preprocessing. Due to some passes (e.g. bf16_to_f16) we might get+ // modified weights and thus mismatch during weights read.+ // FIXME: consider adding a config it will influence weight modification in the future+ pre_load_transform(model_ptr, {});// Fill the cachefor (const auto& node : model_ptr->get_ordered_ops()) {if (ov::op::util::is_constant(node)) {