Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Device Availability Check #604

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions onnxruntime/core/providers/openvino/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
struct SessionContext : ProviderInfo {
SessionContext(const ProviderInfo& info) : ProviderInfo{info} {}
std::vector<bool> deviceAvailableList = {true, true, true, true, true, true, true, true};
std::vector<std::string> available_devices; // this vector will be used to validate available devices thoughout OVEP lifetime

Check notice on line 111 in onnxruntime/core/providers/openvino/contexts.h

View workflow job for this annotation

GitHub Actions / misspell

[misspell] onnxruntime/core/providers/openvino/contexts.h#L111

"thoughout" is a misspelling of "throughout"
Raw output
./onnxruntime/core/providers/openvino/contexts.h:111:104: "thoughout" is a misspelling of "throughout"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run cpp lint

std::filesystem::path onnx_model_path_name;
uint32_t onnx_opset_version{0};
mutable bool is_wholly_supported_graph = false; // Value is set to mutable to modify from capability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ OpenVINOExecutionProvider::OpenVINOExecutionProvider(const ProviderInfo& info, s
if (info.cache_dir.empty()) {
bool device_found = false;
std::vector<std::string> available_devices = OVCore::Get()->GetAvailableDevices();
for (int i = 0 ; i< available_devices.size() ; i++) {
session_context_.available_devices.push_back(available_devices[i]);
}
// Checking for device_type configuration
if (info.device_type != "") {
if (info.device_type.find("HETERO") != std::string::npos ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ bool ParseBooleanOption(const ProviderOptions& provider_options, std::string opt
}

std::string ParseDeviceType(std::shared_ptr<OVCore> ov_core, const ProviderOptions& provider_options, std::string option_name) {
const std::vector<std::string> ov_available_devices = ov_core->GetAvailableDevices();

std::set<std::string> ov_supported_device_types = {"CPU", "GPU",
"GPU.0", "GPU.1", "NPU"};
std::set<std::string> deprecated_device_types = {"CPU_FP32", "GPU_FP32",
"GPU.0_FP32", "GPU.1_FP32", "GPU_FP16",
"GPU.0_FP16", "GPU.1_FP16"};

// Expand set of supported device with OV devices
ov_supported_device_types.insert(ov_available_devices.begin(), ov_available_devices.end());

if (provider_options.contains(option_name)) {
const auto& selected_device = provider_options.at("device_type");
Expand Down
Loading