Skip to content
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
19 changes: 17 additions & 2 deletions onnxruntime/core/providers/openvino/backends/basic_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,28 @@ 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());
config_t& load_config = session_context_.load_config;

Choose a reason for hiding this comment

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

I see that you are setting the values explicitly, can we not directly pass below & let ov toolkit take care of it. In my opinion this change is not needed, as we are delegating all the heavy lifting & setting of ov::AnyMap device_config properties to OV toolkit internally going ahead

{
 "GPU": {
    "CACHE_MODE": "OPTIMIZE_SIZE"
    // "CACHE_MODE": "OPTIMIZE_SPEED"
  }
}


if (session_context_.device_type.find("GPU") != std::string::npos) {
if (const auto& gpu_config = load_config.find("GPU"); gpu_config != load_config.end()) {
if (const auto& it = gpu_config->second.find("CACHE_MODE"); it != gpu_config->second.end()) {
if (it->second.is<std::string>()) {
if (it->second.as<std::string>() == "OPTIMIZE_SIZE")
device_config["CACHE_MODE"] = ov::CacheMode::OPTIMIZE_SIZE;
else if (it->second.as<std::string>() == "OPTIMIZE_SPEED")
device_config["CACHE_MODE"] = ov::CacheMode::OPTIMIZE_SPEED;
}
}
}
}
}
}

Expand Down Expand Up @@ -364,7 +379,7 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class BasicBackend : public IBackend {
private:
bool ValidateSubgraph(std::map<std::string, std::shared_ptr<ov::Node>>& 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 SetNumThreads(ov::AnyMap& device_config);
Expand Down
Loading