diff --git a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc index 463f985d8c..95b39bcc05 100644 --- a/onnxruntime/core/providers/openvino/openvino_provider_factory.cc +++ b/onnxruntime/core/providers/openvino/openvino_provider_factory.cc @@ -57,7 +57,7 @@ struct OpenVINO_Provider : Provider { std::shared_ptr CreateExecutionProviderFactory(const void* void_params) override { auto& provider_options_map = *reinterpret_cast(void_params); - const char* device_type = ""; // [device_type]: Overrides the accelerator hardware type and precision + std::string device_type = ""; // [device_type]: Overrides the accelerator hardware type and precision // with these values at runtime. bool enable_vpu_fast_compile = false; // [enable_vpu_fast_compile]: Fast-compile may be optionally enabled to // speeds up the model's compilation to VPU device specific format. @@ -77,6 +77,19 @@ struct OpenVINO_Provider : Provider { if (provider_options_map.find("device_type") != provider_options_map.end()) { device_type = provider_options_map.at("device_type").c_str(); + + std::set ov_supported_device_types = {"CPU_FP32", "CPU_FP16", "GPU_FP32", + "GPU.0_FP32", "GPU.1_FP32", "GPU_FP16", + "GPU.0_FP16", "GPU.1_FP16", + "VPUX_FP16", "VPUX_U8"}; + if (!((ov_supported_device_types.find(device_type) != ov_supported_device_types.end()) || + (device_type.find("HETERO:") == 0) || (device_type.find("MULTI:") == 0) || (device_type.find("AUTO:") == 0))) { + ORT_THROW( + "[ERROR] [OpenVINO] You have selcted wrong configuration value for the key 'device_type'. " + "Select from 'CPU_FP32', 'CPU_FP16', 'GPU_FP32', 'GPU.0_FP32', 'GPU.1_FP32', 'GPU_FP16', " + "'GPU.0_FP16', 'GPU.1_FP16', 'VPUX_FP16', 'VPUX_U8' or from" + " HETERO/MULTI/AUTO options available. \n"); + } } if (provider_options_map.find("device_id") != provider_options_map.end()) { device_id = provider_options_map.at("device_id").c_str(); @@ -90,10 +103,16 @@ struct OpenVINO_Provider : Provider { if (provider_options_map.find("num_of_threads") != provider_options_map.end()) { num_of_threads = std::stoi(provider_options_map.at("num_of_threads")); + if (num_of_threads <= 0) { + num_of_threads = 1; + } } if (provider_options_map.find("num_streams") != provider_options_map.end()) { num_streams = std::stoi(provider_options_map.at("num_streams")); + if (num_streams <= 0 && num_streams > 8) { + ORT_THROW("[ERROR] [OpenVINO] The value for the key 'num_streams' should be in the range of 1-8 \n"); + } } std::string bool_flag = ""; if (provider_options_map.find("enable_vpu_fast_compile") != provider_options_map.end()) { @@ -121,7 +140,7 @@ struct OpenVINO_Provider : Provider { else if (bool_flag == "false" || bool_flag == "False") enable_dynamic_shapes = false; } - return std::make_shared(device_type, + return std::make_shared(const_cast(device_type.c_str()), enable_vpu_fast_compile, device_id, num_of_threads, diff --git a/onnxruntime/core/providers/openvino/ov_versions/capability.cc b/onnxruntime/core/providers/openvino/ov_versions/capability.cc index 865e74aa1f..171dd45c50 100644 --- a/onnxruntime/core/providers/openvino/ov_versions/capability.cc +++ b/onnxruntime/core/providers/openvino/ov_versions/capability.cc @@ -48,11 +48,6 @@ std::vector> GetCapability::Execute() { return result; } - // Check if it is a subgraph - if (graph_viewer_.IsSubgraph() && graph_viewer_.Name() == "tf2onnx") { - return result; - } - // This is a list of initializers that nGraph considers as constants. Example weights, reshape shape etc. std::unordered_set ng_required_initializers; @@ -83,11 +78,15 @@ std::vector> GetCapability::Execute() { const auto& nodes = graph_viewer_.GetNodesInTopologicalOrder(); + const auto& node = graph_viewer_.GetNode(nodes[0]); + // Handle cases where lone, reoccuring Ops in smaller models cannot be supported in OpenVINO // If only a node of the same lone,unsupported type is present, then do not proceed with the subgraph - const auto& node = graph_viewer_.GetNode(nodes[0]); - if (data_ops_->IsOpSupportedOnlyInModel(node->OpType())) - return result; + if (nodes.size() <= 3) { + if (data_ops_->IsOpSupportedOnlyInModel(node->OpType())) { + return result; + } + } // Nodes that work well in models but not as a single node if (nodes.size() == 1) { diff --git a/onnxruntime/test/perftest/ort_test_session.cc b/onnxruntime/test/perftest/ort_test_session.cc index 454ef5dfb2..57b2403e23 100644 --- a/onnxruntime/test/perftest/ort_test_session.cc +++ b/onnxruntime/test/perftest/ort_test_session.cc @@ -496,6 +496,8 @@ OnnxRuntimeTestSession::OnnxRuntimeTestSession(Ort::Env& env, std::random_device } } else if (key == "cache_dir") { ov_options[key] = value; + } else if (key == "context") { + ov_options[key] = value; } else if (key == "num_streams") { if (std::stoi(value) <= 0 && std::stoi(value) > 8) { ORT_THROW("[ERROR] [OpenVINO] The value for the key 'num_streams' should be in the range of 1-8 \n"); diff --git a/onnxruntime/test/util/default_providers.cc b/onnxruntime/test/util/default_providers.cc index bc85ae03d0..28af61e15b 100644 --- a/onnxruntime/test/util/default_providers.cc +++ b/onnxruntime/test/util/default_providers.cc @@ -91,8 +91,8 @@ std::unique_ptr OpenVINOExecutionProviderWithOptions(const O return OpenVINOProviderFactoryCreator::Create(params)->CreateProvider(); #else ORT_UNUSED_PARAMETER(params); -#endif return nullptr; +#endif } std::unique_ptr DefaultOpenVINOExecutionProvider() {