Skip to content

Commit a0909c2

Browse files
author
jorgep31415
committed
Update on "[ET-VK] Move save_cache from Runtime dtor to model destroy"
## Issue `Runtime` is a local static variable. Hence we'd expect the Runtime dtor to be called on program exit. But on Android devices it's not being invoked. This behavior is different than that seen 6 months ago (D57085281). It's unclear what changed. This means the cache is not saved due to the following chain never being invoked. `~Runtime()` > `~Adapter()` > `~ComputePipelineCache()` > `save_cache()`.\ ## Solution Move cache saving to `VulkanBackend.cpp`'s model destroy. This makes sense since the cache is tied to the model and not the runtime. ## Resources https://medium.com/martin00001313/mastering-static-objects-in-c-initialization-destruction-and-best-practices-760b17734195 Differential Revision: [D66179917](https://our.internmc.facebook.com/intern/diff/D66179917/) [ghstack-poisoned]
1 parent 13a640c commit a0909c2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,10 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
621621
void destroy(DelegateHandle* handle) const override {
622622
if (handle != nullptr) {
623623
ComputeGraph* compute_graph = static_cast<ComputeGraph*>(handle);
624-
compute_graph->context()->adapter_ptr()->compute_pipeline_cache().save_cache();
624+
compute_graph->context()
625+
->adapter_ptr()
626+
->compute_pipeline_cache()
627+
.save_cache();
625628
// ComputeGraph is not trivially destructible. Since
626629
// this was constructed manually in init(), we must destroy it manually
627630
// here.

0 commit comments

Comments
 (0)