pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
2.22k stars 368 forks source link

[ET-VK] Move `save_cache` from Runtime dtor to model destroy #6974

Closed jorgep31415 closed 4 days ago

jorgep31415 commented 5 days ago

Stack from ghstack (oldest at bottom):

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

pytorch-bot[bot] commented 5 days ago

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/6974

Note: Links to docs will display an error until the docs builds have been completed.

:heavy_exclamation_mark: 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

:white_check_mark: No Failures

As of commit 5af5944f711fe37db62ad1b4bd71d19d0471fc6c with merge base 711f1c23d32acd798dabf0028b31e8fcb2c2487f (image): :green_heart: Looks good so far! There are no failures yet. :green_heart:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 5 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917

facebook-github-bot commented 4 days ago

This pull request was exported from Phabricator. Differential Revision: D66179917