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: 9 additions & 3 deletions backends/xnnpack/runtime/XNNPACKBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ class XnnpackBackend final
lock_weights_cache.lock();

const auto& cache_path = options_.get_packed_cache_path();
if (!cache_path.empty()) {
weights_cache_->set_packed_cache_path(cache_path);
}
weights_cache_->set_packed_cache_path(cache_path);

weights_cache_->initialize_for_runtime(
context.get_runtime_allocator(), named_data_map);
Expand Down Expand Up @@ -219,6 +217,14 @@ class XnnpackBackend final
BackendOptionContext& context,
const Span<BackendOption>& backend_options) override {
for (const auto& option : backend_options) {
if (strcmp(option.key, xnnpack::save_packed_index_option_key) == 0) {
auto* val = std::get_if<bool>(&option.value);
if (val && *val) {
const std::lock_guard<std::mutex> lock(weights_cache_mutex_);
return weights_cache_->save_packed_index();
}
continue;
}
Error err = options_.set_option(option);
if (err != Error::Ok) {
return err;
Expand Down
3 changes: 3 additions & 0 deletions backends/xnnpack/runtime/XNNPACKBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const char weight_cache_option_key[] = "weight_cache_enabled";
// @lint-ignore CLANGTIDY facebook-hte-CArray
const char packed_cache_path_option_key[] = "packed_cache_path";

/// Trigger saving the packed weight index for cross-load cache reuse.
const char save_packed_index_option_key[] = "save_packed_index";

/// Workspace sharing mode. This is a backend option that can be set via the
/// set_option API to control memory sharing between CALL_DELEGATE instances.
/// This is useful for reducing memory consumption.
Expand Down
Loading
Loading