@@ -444,24 +444,27 @@ struct OpenVINO_Provider : Provider {
444444 return Status (common::ONNXRUNTIME, ORT_EP_FAIL, " OpenVINO EP only supports one device." );
445445 }
446446
447- ProviderInfo pi;
448- const auto & config_options = session_options.GetConfigOptions ();
449- ParseProviderInfo (provider_options, &config_options, pi);
450-
447+ // Extract device type from EP metadata
451448 const auto & device_meta_data = ep_metadata[0 ];
452449 auto it = device_meta_data->Entries ().find (" ov_device" );
453450 if (it == device_meta_data->Entries ().end ()) {
454451 return Status (common::ONNXRUNTIME, ORT_INVALID_ARGUMENT, " OpenVINO EP device metadata not found." );
455452 }
456- pi.device_type = it->second ;
457453
458- /*
459- TODO: This is where we need to perform some checking / manupulation of the session_options before
460- they are passed into CreateProviders() below.
461- Note: pi.device_type is getting set above, but I *think* it will just get overridden by the
462- ParseConfigOptions() that will be done inside of CreateProvider();
463- */
454+ std::string metadata_device_type = it->second ;
455+
456+ // If user didn't specify device_type, use the one from metadata
457+ if (provider_options.find (" device_type" ) == provider_options.end ()) {
458+ provider_options[" device_type" ] = metadata_device_type;
459+ }
460+
461+ // Parse provider info with the device type
462+ ProviderInfo pi;
463+ const auto & config_options = session_options.GetConfigOptions ();
464+ ParseProviderInfo (provider_options, &config_options, pi);
465+ ParseConfigOptions (pi);
464466
467+ // Create and return the execution provider
465468 auto factory = std::make_unique<OpenVINOProviderFactory>(pi, SharedContext::Get ());
466469 ep = factory->CreateProvider (session_options, logger);
467470 return Status::OK ();
0 commit comments