@@ -145,51 +145,106 @@ void update_log_level(const std::map<std::string, std::string>& propertiesMap) {
145145}
146146
147147std::string getDeviceFromProperties (const ov::AnyMap& propertiesMap) {
148- const std::string defaultDevice = std::string (ov::intel_npu::Platform::NPU4000) ;
148+ const std::string defaultDevice = " " ;
149149 auto it = propertiesMap.find (std::string (DEVICE_ID::key ()));
150150 if (it != propertiesMap.end ()) {
151151 return it->second .as <std::string>();
152152 }
153153
154154 it = propertiesMap.find (std::string (PLATFORM::key ()));
155155 if (it != propertiesMap.end ()) {
156- return it->second .as <std::string>();
156+ auto platformStr = it->second .as <std::string>();
157+ if (platformStr == ov::intel_npu::Platform::AUTO_DETECT) {
158+ return defaultDevice;
159+ }
160+
161+ platformStr = utils::getPlatformByDeviceName (platformStr);
162+ platformStr = ov::intel_npu::Platform::standardize (platformStr);
163+ std::cout << " S====tandardized platform is: " << platformStr << std::endl;
164+ return platformStr;
157165 }
158166 return defaultDevice;
159167}
160168
161- void checkUpdateforspecialPlatform (const FilteredConfig& base_conf, ov::AnyMap& propertiesMap, Logger& log) {
162- // If there is no compiler_type provided, use base_config value, check and update by the device
163- // update the compilerType by device:
169+ void checkUpdateforSpecialPlatform (const FilteredConfig& base_conf,
170+ ov::AnyMap& propertiesMap,
171+ const std::string& deviceName,
172+ Logger& log) {
173+ // If there is no compiler_type provided, use base_config default value
174+ // Default compilerType for different platform is up to device:
164175 // 3720 -> DRIVER
165- // 4000 and later -> MLIR
166- auto it_compiler_type = propertiesMap.find (std::string (COMPILER_TYPE::key ()));
167- // If user set compilerType, will not update by device
168- if (it_compiler_type == propertiesMap.end ()) {
169- // if platform is provided by local config = use that
170- const ov::AnyMap localProperties = propertiesMap;
171- std::string getdevice = getDeviceFromProperties (localProperties);
172- if (getdevice == std::string ((ov::intel_npu::Platform::NPU3720))) {
173- if (base_conf.get <COMPILER_TYPE>() != ov::intel_npu::CompilerType::DRIVER) {
174- log.warning (
175- " Platform '3720' is selected, but the used compiler_type is not set to 'DRIVER'. Forcely use the "
176- " compiler_type to 'DRIVER'. Maybe cause the compilerType inconsistency issues." );
177- }
178- // To avoid compilerType inconsistency issues, only set DRIVER if compiler_type is not set by user
179- propertiesMap[std::string (COMPILER_TYPE::key ())] =
180- COMPILER_TYPE::toString (ov::intel_npu::CompilerType::DRIVER);
176+ // 4000 and later -> default
177+
178+ // const ov::AnyMap localProperties = propertiesMap;
179+ std::string getdevice = getDeviceFromProperties (propertiesMap);
180+ std::cout << " The device from properties '" << getdevice << " ' VS actual device from backend'" << deviceName << " '"
181+ << std::endl;
182+ if (deviceName.empty () && getdevice.empty ()) {
183+ OPENVINO_THROW (" Device name is empty!" );
184+ }
185+ std::cout << " ==checkUpdateforSpecialPlatform==1==" << std::endl;
186+ std::string usedDevice = deviceName;
187+ if (deviceName != getdevice) {
188+ log.info (" The device from properties '%s' is different from the actual device '%s', use device '%s' to check "
189+ " compiler_type." ,
190+ getdevice.c_str (),
191+ deviceName.c_str (),
192+ deviceName.c_str ());
193+
194+ usedDevice = deviceName.empty () ? getdevice : deviceName;
195+ std::cout << " ==checkUpdateforSpecialPlatform==2==" << std::endl;
196+ }
197+ std::cout << " ==checkUpdateforSpecialPlatform==3==" << std::endl;
198+ // If the platform is not 3720 or user set compilerType, will not update by device
199+ auto it = propertiesMap.find (std::string (COMPILER_TYPE::key ()));
200+ if (usedDevice != std::string (ov::intel_npu::Platform::NPU3720) || it != propertiesMap.end ()) {
201+ std::cout << " ==checkUpdateforSpecialPlatform==3==" << std::endl;
202+ return ;
203+ }
204+ std::cout << " ==checkUpdateforSpecialPlatform==4==" << std::endl;
205+ if (it == propertiesMap.end ()) {
206+ std::cout << " ==checkUpdateforSpecialPlatform==5==" << std::endl;
207+ if (base_conf.get <COMPILER_TYPE>() != ov::intel_npu::CompilerType::DRIVER) {
208+ std::cout << " ==checkUpdateforSpecialPlatform==6==" << std::endl;
209+ log.warning (
210+ " Platform '3720' is selected, but the used compiler_type is not set to 'DRIVER'. Forcely use the "
211+ " compiler_type to 'DRIVER'. Maybe cause the compilerType inconsistency issues." );
181212 }
213+ std::cout << " ==checkUpdateforSpecialPlatform==7==" << std::endl;
214+ // To avoid compilerType inconsistency issues, only set DRIVER if compiler_type is not set by user
215+ propertiesMap[std::string (COMPILER_TYPE::key ())] = COMPILER_TYPE::toString (ov::intel_npu::CompilerType::DRIVER);
216+ std::cout << " ==checkUpdateforSpecialPlatform==8==" << std::endl;
182217 }
183218}
184219
185- static ov::intel_npu::CompilerType resolveCompilerType (const FilteredConfig& base_conf, const ov::AnyMap& local_conf) {
220+ static ov::intel_npu::CompilerType resolveCompilerType (const FilteredConfig& base_conf,
221+ const ov::AnyMap& local_conf,
222+ const std::string& deviceName) {
186223 // first look if provided config changes compiler type
187224 auto it = local_conf.find (std::string (COMPILER_TYPE::key ()));
188225 if (it != local_conf.end ()) {
189226 // if compiler_type is provided by local config = use that
190227 return COMPILER_TYPE::parse (it->second .as <std::string>());
191228 }
192- // if there is no compiler_type provided = use base_config value
229+ // if there is no compiler_type provided = use base_config value and update default vaule by platform if needed
230+ // Default compilerType for different platform is up to device:
231+ // 3720 -> DRIVER
232+ // 4000 and later -> default
233+ if (!deviceName.empty ()) {
234+ if (deviceName == std::string (ov::intel_npu::Platform::NPU3720)) {
235+ return ov::intel_npu::CompilerType::DRIVER;
236+ }
237+ } else {
238+ std::string getdevice = getDeviceFromProperties (local_conf);
239+ if (getdevice == std::string (ov::intel_npu::Platform::NPU3720)) {
240+ return ov::intel_npu::CompilerType::DRIVER;
241+ }
242+ if (getdevice == std::string (ov::intel_npu::Platform::AUTO_DETECT)) {
243+ Logger::global ().warning (" Device is set to AUTO_DETECT, cannot decide the default compiler_type by device, "
244+ " use the default compiler_type." );
245+ }
246+ }
247+
193248 return base_conf.get <COMPILER_TYPE>();
194249}
195250
@@ -663,6 +718,9 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
663718 // activate the NPUW path
664719 auto useNpuwKey = ov::intel_npu::use_npuw.name ();
665720 ov::AnyMap localProperties = properties;
721+ for (auto it : localProperties) {
722+ std::cout << " Compile_model: Local property: " << it.first << " =" << it.second .as <std::string>() << std::endl;
723+ }
666724 if (localProperties.count (useNpuwKey)) {
667725 if (localProperties.at (useNpuwKey).as <bool >() == true ) {
668726 return ov::npuw::ICompiledModel::create (model->clone (), shared_from_this (), localProperties);
@@ -679,17 +737,27 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
679737 }
680738
681739 // For 3720, need check and update its compiler_type
682- checkUpdateforspecialPlatform (_globalConfig, localProperties, _logger);
683-
740+ auto deviceTmp = _backend == nullptr ? nullptr : _backend->getDevice ();
741+ std::string deviceName = deviceTmp != nullptr ? deviceTmp->getName () : " " ;
742+ checkUpdateforSpecialPlatform (_globalConfig, localProperties, deviceName, _logger);
743+ std::cout << " ==compile_model=========2====" << std::endl;
684744 const std::map<std::string, std::string> localPropertiesMap = any_copy (localProperties);
745+ for (auto it : localPropertiesMap) {
746+ std::cout << " Compile_model2: Local property: " << it.first << " =" << it.second << std::endl;
747+ }
748+
685749 update_log_level (localPropertiesMap);
686750
687751 // create compiler
752+ std::cout << " ==compile_model=== compile create ==========1====" << std::endl;
688753 CompilerAdapterFactory compilerAdapterFactory;
689- auto compiler = compilerAdapterFactory.getCompiler (_backend, resolveCompilerType (_globalConfig, properties));
754+ auto compiler =
755+ compilerAdapterFactory.getCompiler (_backend, resolveCompilerType (_globalConfig, localProperties, deviceName));
756+ std::cout << " ==compile_model=== compile create ==========2====" << std::endl;
690757
691758 OV_ITT_TASK_CHAIN (PLUGIN_COMPILE_MODEL, itt::domains::NPUPlugin, " Plugin::compile_model" , " fork_local_config" );
692759 auto localConfig = fork_local_config (localPropertiesMap, compiler);
760+ std::cout << " ===== the final config is: " << localConfig.toString () << std::endl;
693761
694762 const auto set_cache_dir = localConfig.get <CACHE_DIR>();
695763 if (!set_cache_dir.empty ()) {
@@ -703,7 +771,31 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
703771 utils::getCompilationPlatform (localConfig.get <PLATFORM>(),
704772 localConfig.get <DEVICE_ID>(),
705773 _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames ());
774+ std::string getPlatfrom1 = getDeviceFromProperties (localProperties);
775+ std::cout << " The platform from properties is: '" << getPlatfrom1 << " '" << std::endl;
776+ std::cout << " The platform from getCompilationPlatform is: '" << platform << " '" << std::endl;
777+
706778 auto device = _backend == nullptr ? nullptr : _backend->getDevice (localConfig.get <DEVICE_ID>());
779+
780+ if (deviceTmp == device) {
781+ if (deviceTmp != nullptr ) {
782+ std::cout << " The selected device is: " << device->getName () << std::endl;
783+ } else {
784+ if (deviceTmp == nullptr ) {
785+ std::cout << " The selected device from driver is: nullptr" << std::endl;
786+ } else {
787+ std::cout << " The selected device from driver is: " << deviceTmp->getName () << std::endl;
788+ }
789+ if (device == nullptr ) {
790+ std::cout << " The selected device from config and driver is: nullptr" << std::endl;
791+ } else {
792+ std::cout << " The selected device from config and driver is: " << device->getName () << std::endl;
793+ }
794+ }
795+ } else {
796+ std::cout << " The selected device is NOT EQUAL, deviceTmp is " << deviceTmp->getName () << " , device is "
797+ << device->getName () << std::endl;
798+ }
707799 localConfig.update ({{ov::intel_npu::platform.name (), platform}});
708800
709801 auto updateBatchMode = [&](ov::intel_npu::BatchMode mode) {
@@ -981,12 +1073,23 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
9811073 CompilerAdapterFactory compilerAdapterFactory;
9821074 auto npu_plugin_properties = properties;
9831075 exclude_model_ptr_from_map (npu_plugin_properties);
984- checkUpdateforspecialPlatform (_globalConfig, npu_plugin_properties, _logger);
1076+ for (auto it : npu_plugin_properties) {
1077+ std::cout << " Query_model: Local property: " << it.first << " =" << it.second .as <std::string>() << std::endl;
1078+ }
1079+
1080+ auto device = _backend == nullptr ? nullptr : _backend->getDevice ();
1081+ std::string deviceName = device != nullptr ? device->getName () : " " ;
1082+ checkUpdateforSpecialPlatform (_globalConfig, npu_plugin_properties, deviceName, _logger);
1083+ for (auto it : npu_plugin_properties) {
1084+ std::cout << " Query_model2: Local property: " << it.first << " =" << it.second .as <std::string>() << std::endl;
1085+ }
9851086 const std::map<std::string, std::string> propertiesMap = any_copy (npu_plugin_properties);
9861087 update_log_level (propertiesMap);
1088+ std::cout << " ==query_model=== compile create ==========1====" << std::endl;
9871089 auto compiler =
988- compilerAdapterFactory.getCompiler (_backend, resolveCompilerType (_globalConfig, npu_plugin_properties));
989-
1090+ compilerAdapterFactory.getCompiler (_backend,
1091+ resolveCompilerType (_globalConfig, npu_plugin_properties, deviceName));
1092+ std::cout << " ==query_model=== compile create ==========1====" << std::endl;
9901093 auto localConfig = fork_local_config (propertiesMap, compiler, OptionMode::CompileTime);
9911094 _logger.setLevel (localConfig.get <LOG_LEVEL>());
9921095 const auto platform =
@@ -1017,13 +1120,24 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
10171120 // ov::hint::model has no corresponding "Config" implementation thus we need to remove it from the
10181121 // list of properties
10191122 auto originalModel = exclude_model_ptr_from_map (npu_plugin_properties);
1020- checkUpdateforspecialPlatform (_globalConfig, npu_plugin_properties, _logger);
1123+ for (auto it : npu_plugin_properties) {
1124+ std::cout << " Parse: Local property1: " << it.first << " =" << it.second .as <std::string>() << std::endl;
1125+ }
1126+ auto deviceTmp = _backend == nullptr ? nullptr : _backend->getDevice ();
1127+ std::string deviceName = deviceTmp != nullptr ? deviceTmp->getName () : " " ;
1128+ checkUpdateforSpecialPlatform (_globalConfig, npu_plugin_properties, deviceName, _logger);
1129+ for (auto it : npu_plugin_properties) {
1130+ std::cout << " Parse2: Local property: " << it.first << " =" << it.second .as <std::string>() << std::endl;
1131+ }
10211132
10221133 CompilerAdapterFactory compilerAdapterFactory;
10231134 const auto propertiesMap = any_copy (npu_plugin_properties);
10241135 update_log_level (propertiesMap);
1136+ std::cout << " ==parse=== compile create ==========1====" << std::endl;
10251137 auto compiler =
1026- compilerAdapterFactory.getCompiler (_backend, resolveCompilerType (_globalConfig, npu_plugin_properties));
1138+ compilerAdapterFactory.getCompiler (_backend,
1139+ resolveCompilerType (_globalConfig, npu_plugin_properties, deviceName));
1140+ std::cout << " ==parse=== compile create ==========2====" << std::endl;
10271141 OV_ITT_TASK_CHAIN (PLUGIN_PARSE_MODEL, itt::domains::NPUPlugin, " Plugin::parse" , " fork_local_config" );
10281142 auto localConfig = fork_local_config (propertiesMap, compiler, OptionMode::RunTime);
10291143 _logger.setLevel (localConfig.get <LOG_LEVEL>());
@@ -1033,6 +1147,12 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
10331147 _backend == nullptr ? std::vector<std::string>() : _backend->getDeviceNames ());
10341148 localConfig.update ({{ov::intel_npu::platform.name (), platform}});
10351149 auto device = _backend == nullptr ? nullptr : _backend->getDevice (localConfig.get <DEVICE_ID>());
1150+ if (deviceTmp == device) {
1151+ std::cout << " 2The selected device is: " << device->getName () << std::endl;
1152+ } else {
1153+ std::cout << " 2The selected device is NOT EQUAL, deviceTmp is " << deviceTmp->getName () << " , device is "
1154+ << device->getName () << std::endl;
1155+ }
10361156
10371157 const auto loadedFromCache = localConfig.get <LOADED_FROM_CACHE>();
10381158 if (!loadedFromCache) {
0 commit comments