xref: /aosp_15_r20/external/pytorch/torch/csrc/jit/backends/coreml/cpp/context.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <torch/csrc/jit/backends/coreml/cpp/context.h>
2 #include <atomic>
3 
4 namespace torch {
5 namespace jit {
6 namespace mobile {
7 namespace coreml {
8 
9 std::atomic<ContextInterface*> g_coreml_ctx_registry;
10 
BackendRegistrar(ContextInterface * ctx)11 BackendRegistrar::BackendRegistrar(ContextInterface* ctx) {
12   g_coreml_ctx_registry.store(ctx);
13 }
14 
setModelCacheDirectory(std::string path)15 void setModelCacheDirectory(std::string path) {
16   auto p = g_coreml_ctx_registry.load();
17   if (p) {
18     p->setModelCacheDirectory(path);
19   }
20 }
21 
22 } // namespace coreml
23 } // namespace mobile
24 } // namespace jit
25 } // namespace torch
26