Skip to content
4 changes: 4 additions & 0 deletions backends/vulkan/runtime/VulkanBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,10 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
void destroy(DelegateHandle* handle) const override {
if (handle != nullptr) {
ComputeGraph* compute_graph = static_cast<ComputeGraph*>(handle);
compute_graph->context()
->adapter_ptr()
->compute_pipeline_cache()
.save_cache();
// ComputeGraph is not trivially destructible. Since
// this was constructed manually in init(), we must destroy it manually
// here.
Expand Down
2 changes: 0 additions & 2 deletions backends/vulkan/runtime/vk_api/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ ComputePipelineCache::~ComputePipelineCache() {
return;
}

save_cache();

vkDestroyPipelineCache(device_, pipeline_cache_, nullptr);
pipeline_cache_ = VK_NULL_HANDLE;
}
Expand Down
3 changes: 2 additions & 1 deletion backends/vulkan/runtime/vk_api/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ class ComputePipelineCache final {
}
};

void save_cache();

private:
std::vector<char> load_cache();
void save_cache();

// Multiple threads could potentially be adding entries into the cache, so use
// a mutex to manage access
Expand Down
Loading