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
[NPU] Plugin batch - set performance_mode to THROUGHPUT (#32669)
Daria Mityaginad8266a912f27
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cppindex 610cf717be4..e1b585c151e 100644--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp@@ -701,14 +701,32 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<std::shared_ptr<intel_npu::IGraph> graph;+ auto compileWithConfig = [&](const auto& modelToCompile, const auto& config) {+ if (!localConfig.get<WEIGHTLESS_BLOB>()) {+ return compiler->compile(modelToCompile, config);+ } else {+ check_weightless_cache_attribute_occurrence(model);+ return compiler->compileWS(modelToCompile, config);+ }+ };+try {_logger.debug("performing compile");- if (!localConfig.get<WEIGHTLESS_BLOB>()) {- graph = compiler->compile(successfullyDebatched ? batchedModel : model->clone(), localConfig);+ // Determine which model to use+ auto modelToCompile = successfullyDebatched ? batchedModel : model->clone();++ if (successfullyDebatched && localConfig.get<PERFORMANCE_HINT>() == ov::hint::PerformanceMode::LATENCY) {+ _logger.info("Override performance mode to THROUGHPUT for compilation");++ auto modifiedConfig = localConfig; // Copy only when needed+ std::stringstream strStream;+ strStream << ov::hint::PerformanceMode::THROUGHPUT;+ modifiedConfig.update({{ov::hint::performance_mode.name(), strStream.str()}});++ graph = compileWithConfig(modelToCompile, modifiedConfig);} else {- check_weightless_cache_attribute_occurrence(model);- graph = compiler->compileWS(successfullyDebatched ? batchedModel : model->clone(), localConfig);+ graph = compileWithConfig(modelToCompile, localConfig); // No copy}} catch (const std::exception& ex) {OPENVINO_THROW(ex.what());diff --git a/src/plugins/intel_npu/src/plugin/src/transformations.cpp b/src/plugins/intel_npu/src/plugin/src/transformations.cppindex b30d054598e..0dc0480f648 100644--- a/src/plugins/intel_npu/src/plugin/src/transformations.cpp+++ b/src/plugins/intel_npu/src/plugin/src/transformations.cpp@@ -244,6 +244,7 @@ std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(logger.info("Couldn't validate and reshape the model. Batching will be handled by compiler. Error: %s",ex.what());}+return {reshapedModel, successfullyDebatched};}