[pytorch] add header docs for TORCH_LIBRARY_THREAD_UNSAFE_LAZY_INIT (#150854)

Summary: Add header docs for the experimental TORCH_LIBRARY_THREAD_UNSAFE_LAZY_INIT feature, and guard behind C10_MOBILE.

Reviewed By: albanD

Differential Revision: D72572345

Pull Request resolved: https://github.com/pytorch/pytorch/pull/150854
Approved by: https://github.com/larryliu0820, https://github.com/zou3519
This commit is contained in:
Richard Howell
2025-04-09 12:59:24 +00:00
committed by PyTorch MergeBot
parent 142f0f86ce
commit 64ac41f68d
3 changed files with 10 additions and 4 deletions

View File

@ -647,7 +647,7 @@ mobile::Module _load_for_mobile(
std::optional<at::Device> device,
ExtraFilesMap& extra_files,
uint64_t module_load_options) {
#ifdef TORCH_LIBRARY_THREAD_UNSAFE_LAZY_INIT
#if defined(TORCH_LIBRARY_THREAD_UNSAFE_LAZY_INIT) && defined(C10_MOBILE)
torch::initialize_torch_libraries();
#endif
auto observer = torch::observerConfig().getModuleObserver();