Skip to content

Commit 64f50e3

Browse files
RyanMetcalfeInt8ankitm3k
authored andcommitted
CreateIExecutionProvider: For some disallowed provider options, give better guidance
1 parent cfab7a4 commit 64f50e3

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

onnxruntime/core/providers/openvino/openvino_provider_factory.cc

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,35 @@ struct OpenVINO_Provider : Provider {
445445
return Status(common::ONNXRUNTIME, ORT_EP_FAIL, "No devices provided to CreateEp");
446446
}
447447

448-
// Block setting certain provider options via AppendExecutionProvider_V2
449-
// TODO: Expand this out and give better guidance for keys that should now flow through load_config.
450-
const std::unordered_set<std::string> blocked_provider_keys = {
451-
"device_type", "device_id", "device_luid", "cache_dir", "precision",
452-
"context", "num_of_threads", "model_priority", "num_streams",
453-
"enable_opencl_throttling", "enable_qdq_optimizer", "disable_dynamic_shapes"};
448+
// For provider options that we don't support anymore, give some guidance & examples
449+
// about how to make use of the option through load_config.
450+
const std::vector<std::pair<std::string, std::string>> block_and_advise_entries = {
451+
{"cache_dir", "\"CACHE_DIR\": \"<filesystem_path>\""},
452+
{"precision", "\"INFERENCE_PRECISION_HINT\": \"F32\""},
453+
{"num_streams", "\"NUM_STREAMS\": \"1\""},
454+
{"model_priority", "\"MODEL_PRIORITY\": \"LOW\""},
455+
{"enable_opencl_throttling", "\"GPU\": {\"PLUGIN_THROTTLE\": \"1\"}"},
456+
{"enable_qdq_optimizer", "\"NPU\": {\"NPU_QDQ_OPTIMIZATION\": \"YES\"}"}
457+
};
458+
459+
for (auto& block_and_advise_entry : block_and_advise_entries) {
460+
if (provider_options.find(block_and_advise_entry.first) != provider_options.end()) {
461+
std::string message = "OpenVINO EP: Option '" + block_and_advise_entry.first +
462+
"' cannot be set when using AppendExecutionProvider_V2. " +
463+
"It can instead be enabled by a load_config key / value pair. For example: " +
464+
block_and_advise_entry.second;
465+
return Status(common::ONNXRUNTIME, ORT_INVALID_ARGUMENT, message);
466+
}
467+
}
468+
469+
// For the rest of the disallowed provider options, give a generic error message.
470+
const std::vector<std::string> blocked_provider_keys = {
471+
"device_type", "device_id", "device_luid", "context", "num_of_threads", "disable_dynamic_shapes"};
454472

455473
for (const auto& key : blocked_provider_keys) {
456474
if (provider_options.find(key) != provider_options.end()) {
457475
return Status(common::ONNXRUNTIME, ORT_INVALID_ARGUMENT,
458-
"OpenVINO EP: Option '" + key + "' cannot be set explicitly when using AppendExecutionProvider_V2.");
476+
"OpenVINO EP: Option '" + key + "' cannot be set when using AppendExecutionProvider_V2.");
459477
}
460478
}
461479

0 commit comments

Comments
 (0)