@@ -151,6 +151,12 @@ namespace ov {
151151namespace genai {
152152namespace utils {
153153
154+ enum class ModelType {
155+ Standard,
156+ Whisper,
157+ TextEmbedding
158+ };
159+
154160Tensor init_attention_mask (const Tensor& input_ids) {
155161 auto shape = input_ids.get_shape ();
156162 auto attention_mask = ov::Tensor{input_ids.get_element_type (), shape};
@@ -608,10 +614,7 @@ void import_npu_model(ov::CompiledModel& compiled,
608614}
609615
610616void export_npu_model (ov::CompiledModel& compiled,
611- std::string& blob_path) {
612- if (blob_path.empty ()) {
613- blob_path = " openvino_model.blob" ;
614- }
617+ const std::string& blob_path) {
615618 // Check the path is full
616619 const int EXT_SIZE = 5 ; // ".blob"
617620 if (blob_path.size () < EXT_SIZE) {
@@ -657,8 +660,7 @@ std::pair<ov::CompiledModel, KVDesc>
657660compile_decoder_for_npu_impl (const std::shared_ptr<ov::Model>& model,
658661 const ov::AnyMap& config,
659662 const KVAxesPosition& kv_pos,
660- const bool is_whisper,
661- const bool is_text_embedding,
663+ ModelType model_type,
662664 const ov::AnyMap& text_embed_config = {}) {
663665 ov::CompiledModel compiled;
664666 ov::AnyMap properties = config;
@@ -671,15 +673,25 @@ compile_decoder_for_npu_impl(const std::shared_ptr<ov::Model>& model,
671673 if (do_import) {
672674 import_npu_model (compiled, kv_desc, properties, blob_path);
673675 } else {
674- if (is_text_embedding) {
675- get_npu_text_embedding_config (properties, kv_pos, kv_desc, text_embed_config);
676- } else {
677- get_npu_model_config (properties, kv_pos, kv_desc, is_whisper);
676+ switch (model_type) {
677+ case ModelType::TextEmbedding:
678+ get_npu_text_embedding_config (properties, kv_pos, kv_desc, text_embed_config);
679+ break ;
680+ case ModelType::Whisper:
681+ get_npu_model_config (properties, kv_pos, kv_desc, true );
682+ break ;
683+ case ModelType::Standard:
684+ default :
685+ get_npu_model_config (properties, kv_pos, kv_desc, false );
686+ break ;
678687 }
679688
680689 compiled = ov::genai::utils::singleton_core ().compile_model (model, " NPU" , properties);
681690 // Also export compiled model if required
682691 if (export_blob) {
692+ if (blob_path.empty ()) {
693+ blob_path = " openvino_model.blob" ;
694+ }
683695 export_npu_model (compiled, blob_path);
684696 }
685697 }
@@ -692,15 +704,17 @@ compile_decoder_for_npu(const std::shared_ptr<ov::Model>& model,
692704 const ov::AnyMap& config,
693705 const KVAxesPosition& kv_pos,
694706 const bool is_whisper) {
695- return compile_decoder_for_npu_impl (model, config, kv_pos, is_whisper, false );
707+ return compile_decoder_for_npu_impl (model, config, kv_pos,
708+ is_whisper ? ModelType::Whisper : ModelType::Standard
709+ );
696710}
697711
698712std::pair<ov::CompiledModel, KVDesc>
699713compile_decoder_for_npu_text_embedding (const std::shared_ptr<ov::Model>& model,
700714 const ov::AnyMap& config,
701715 const KVAxesPosition& kv_pos,
702716 const ov::AnyMap& text_embed_config) {
703- return compile_decoder_for_npu_impl (model, config, kv_pos, false , true , text_embed_config);
717+ return compile_decoder_for_npu_impl (model, config, kv_pos, ModelType::TextEmbedding , text_embed_config);
704718}
705719
706720std::optional<ov::Any> pop_option (ov::AnyMap& config, const std::string& option_name) {
0 commit comments