Skip to content
Open
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
12 changes: 12 additions & 0 deletions onnxruntime/core/providers/openvino/contexts.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,22 @@ class SharedContext : public WeakSingleton<SharedContext> {
size_t weights_size_;
};

void clear() {
metadata.clear();
metadata_filepath.clear();
external_weight_filename.clear();
mapped_weights.reset();
}

fs::path external_weight_filename;
std::unique_ptr<WeightsFile> mapped_weights;
Metadata::Map metadata;
fs::path metadata_filepath;
} shared_weights;

void clear() {
shared_weights.clear();
}
};

using config_t = std::map<std::string, ov::AnyMap>;
Expand Down Expand Up @@ -109,6 +120,7 @@ struct ProviderInfo {
bool so_context_embed_mode{false}; // ORT session option
bool so_share_ep_contexts{false}; // ORT session option
fs::path so_context_file_path{}; // ORT session option
bool so_stop_share_ep_contexts{false}; // ORT session option
const ConfigOptions* config_options{NULL};
const std::unordered_set<std::string> valid_provider_keys = {"device_type", "device_id", "device_luid", "cache_dir", "precision",
"load_config", "context", "num_of_threads", "model_priority", "num_streams", "enable_opencl_throttling", "enable_qdq_optimizer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ OpenVINOExecutionProvider::~OpenVINOExecutionProvider() {
backend_manager.ShutdownBackendManager();
}
backend_managers_.clear();
shared_context_.reset();
}

std::vector<std::unique_ptr<ComputeCapability>>
Expand Down Expand Up @@ -214,6 +215,12 @@ common::Status OpenVINOExecutionProvider::Compile(
file << metadata;
}

if (session_context_.so_stop_share_ep_contexts) {
if (shared_context_) {
shared_context_->clear();
}
}

return status;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void ParseConfigOptions(ProviderInfo& pi) {
pi.so_context_embed_mode = pi.config_options->GetConfigOrDefault(kOrtSessionOptionEpContextEmbedMode, "0") == "1";
pi.so_share_ep_contexts = pi.config_options->GetConfigOrDefault(kOrtSessionOptionShareEpContexts, "0") == "1";
pi.so_context_file_path = pi.config_options->GetConfigOrDefault(kOrtSessionOptionEpContextFilePath, "");
pi.so_stop_share_ep_contexts = pi.config_options->GetConfigOrDefault(kOrtSessionOptionStopShareEpContexts, "0") == "1";

if (pi.so_share_ep_contexts) {
ov::AnyMap map;
Expand Down
Loading