SIGN IN SIGN UP

Serialize destruction of the delegate (#5996)

Summary:
Pull Request resolved: https://github.com/pytorch/executorch/pull/5996

When workspace sharing is enabled, if we call `destroy()` from multiple threads it is possible that we enter in `xnn_delete_runtime` from multiple threads. It is not safe to do so, and can cause double free. This serializes the destroy calls for the singleton backend object if/when called multiple times.

Not locking in the failure case because we may not have a real memory to free i.e. empty workspace?

Reviewed By: digantdesai

Differential Revision: D63917052

fbshipit-source-id: 61e6b1c54f887a54501a4fd3433f8470e74dbca3
G
Gregory Comer committed
566902b71f61538f5c2871c17db547925fcabedb
Parent: befc1a9
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 10/9/2024, 4:52:43 PM