File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ namespace fs = std::filesystem;
1717
1818namespace mlx ::core::metal {
1919
20+ static Device metal_device_;
21+
2022namespace {
2123
2224// TODO nicer way to set this or possibly expose as an environment variable
@@ -108,16 +110,6 @@ MTL::Library* load_library(
108110 }
109111}
110112
111- struct PoolHolder {
112- PoolHolder () {
113- p = NS::AutoreleasePool::alloc ()->init ();
114- }
115- ~PoolHolder () {
116- p->release ();
117- }
118- NS::AutoreleasePool* p;
119- };
120-
121113} // namespace
122114
123115Device::Device ()
@@ -293,13 +285,13 @@ MTL::ComputePipelineState* Device::get_kernel(
293285}
294286
295287Device& device (mlx::core::Device) {
296- static Device metal_device_;
297288 return metal_device_;
298289}
299290
300291NS::AutoreleasePool*& thread_autorelease_pool () {
301- static thread_local PoolHolder pool{};
302- return pool.p ;
292+ static thread_local NS::AutoreleasePool* p =
293+ NS::AutoreleasePool::alloc ()->init();
294+ return p;
303295}
304296
305297void new_stream (Stream stream) {
You can’t perform that action at this time.
0 commit comments