diff --git a/onnxruntime/core/providers/openvino/backends/basic_backend.cc b/onnxruntime/core/providers/openvino/backends/basic_backend.cc index 2f174110dd31b..a950538c7c5fd 100644 --- a/onnxruntime/core/providers/openvino/backends/basic_backend.cc +++ b/onnxruntime/core/providers/openvino/backends/basic_backend.cc @@ -242,13 +242,13 @@ void BasicBackend::PopulateConfigValue(ov::AnyMap& device_config) { } } -void BasicBackend::EnableCaching() { +void BasicBackend::EnableCaching(ov::AnyMap& device_config) { // cache_dir argument has no effect when working with an embed-mode EPContext Graph if (subgraph_context_.is_ep_ctx_graph) return; if (!session_context_.cache_dir.empty() && !session_context_.so_context_enable) { LOGS_DEFAULT(INFO) << log_tag << "Enables Caching"; - OVCore::Get()->SetCache(session_context_.cache_dir.string()); + device_config.emplace(ov::cache_dir(session_context_.cache_dir.string())); } } @@ -262,7 +262,7 @@ void BasicBackend::EnableGPUThrottling(ov::AnyMap& device_config) { } } -void BasicBackend::EnableStreams() { +void BasicBackend::EnableStreams(ov::AnyMap& device_config) { // Return silently for NPU as it's currently treated as a read-only flag by the NPU plugin // and throws an exception for the same if (session_context_.device_type.find("NPU") != std::string::npos) @@ -279,7 +279,7 @@ void BasicBackend::EnableStreams() { } // Do nothing } else { - OVCore::Get()->SetStreams(session_context_.device_type, session_context_.num_streams); + device_config.emplace(ov::num_streams(session_context_.num_streams)); } } @@ -293,13 +293,13 @@ void BasicBackend::SetOVDeviceConfiguration(ov::AnyMap& device_config) { PopulateConfigValue(device_config); // Enable caching - EnableCaching(); + EnableCaching(device_config); // Setting OpenCL queue throttling for GPU EnableGPUThrottling(device_config); // Enable streams; default=1 unless overridden by user configuration - EnableStreams(); + EnableStreams(device_config); // Set the inference_num_threads property of the CPU SetNumThreads(device_config); diff --git a/onnxruntime/core/providers/openvino/backends/basic_backend.h b/onnxruntime/core/providers/openvino/backends/basic_backend.h index 5c75a9ae183e2..2cf3d3faa8b47 100644 --- a/onnxruntime/core/providers/openvino/backends/basic_backend.h +++ b/onnxruntime/core/providers/openvino/backends/basic_backend.h @@ -142,9 +142,9 @@ class BasicBackend : public IBackend { private: bool ValidateSubgraph(std::map>& const_outputs_map); void PopulateConfigValue(ov::AnyMap& device_config); - void EnableCaching(); + void EnableCaching(ov::AnyMap& device_config); void EnableGPUThrottling(ov::AnyMap& device_config); - void EnableStreams(); + void EnableStreams(ov::AnyMap& device_config); void SetNumThreads(ov::AnyMap& device_config); void SetOVDeviceConfiguration(ov::AnyMap& device_config); void ValidateOrtDimsAgainstPartialShape(const std::vector& ort_dims, diff --git a/onnxruntime/core/providers/openvino/ov_interface.cc b/onnxruntime/core/providers/openvino/ov_interface.cc index 899845d4890cf..7723ce0a6c7f7 100644 --- a/onnxruntime/core/providers/openvino/ov_interface.cc +++ b/onnxruntime/core/providers/openvino/ov_interface.cc @@ -270,10 +270,6 @@ OVExeNetwork OVCore::ImportEPCtxOVIREncapsulation(std::istream& model_stream, "Exception while Loading Network from OVIR model file: {}", model_file_path.string()); } -void OVCore::SetCache(const std::string& cache_dir_path) { - core.set_property(ov::cache_dir(cache_dir_path)); -} - std::vector OVCore::GetAvailableDevices() const { std::vector available_devices = core.get_available_devices(); return available_devices; @@ -312,10 +308,6 @@ std::vector OVCore::GetAvailableDevices(const std::string& device_t return available_devices; } -void OVCore::SetStreams(const std::string& device_type, int num_streams) { - core.set_property(device_type, {ov::num_streams(num_streams)}); -} - std::shared_ptr OVExeNetwork::CreateInferRequest() { return OvExceptionBoundary([&]() { auto infReq = compiled_model_obj.create_infer_request(); diff --git a/onnxruntime/core/providers/openvino/ov_interface.h b/onnxruntime/core/providers/openvino/ov_interface.h index 38ea883078e85..5f8fb36c1cbec 100644 --- a/onnxruntime/core/providers/openvino/ov_interface.h +++ b/onnxruntime/core/providers/openvino/ov_interface.h @@ -95,8 +95,6 @@ struct OVCore : WeakSingleton { std::vector GetAvailableDevices() const; std::vector GetAvailableDevices(const std::string& device_type) const; - void SetCache(const std::string& cache_dir_path); - void SetStreams(const std::string& device_type, int num_streams); }; class OVExeNetwork {