mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-27 19:31:16 +08:00
A temporary fix (#254)
This commit is contained in:
parent
1d053e0d1d
commit
a002797d52
@ -108,6 +108,16 @@ MTL::Library* load_library(
|
||||
}
|
||||
}
|
||||
|
||||
struct PoolHolder {
|
||||
PoolHolder() {
|
||||
p = NS::AutoreleasePool::alloc()->init();
|
||||
}
|
||||
~PoolHolder() {
|
||||
p->release();
|
||||
}
|
||||
NS::AutoreleasePool* p;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
Device::Device()
|
||||
@ -125,6 +135,12 @@ Device::~Device() {
|
||||
for (auto& l : library_map_) {
|
||||
l.second->release();
|
||||
}
|
||||
for (auto& b : buffer_map_) {
|
||||
b.second.second->release();
|
||||
}
|
||||
for (auto& e : encoder_map_) {
|
||||
e.second->release();
|
||||
}
|
||||
device_->release();
|
||||
pool_->release();
|
||||
}
|
||||
@ -282,9 +298,8 @@ Device& device(mlx::core::Device) {
|
||||
}
|
||||
|
||||
NS::AutoreleasePool*& thread_autorelease_pool() {
|
||||
static thread_local NS::AutoreleasePool* p =
|
||||
NS::AutoreleasePool::alloc()->init();
|
||||
return p;
|
||||
static thread_local PoolHolder pool{};
|
||||
return pool.p;
|
||||
}
|
||||
|
||||
void new_stream(Stream stream) {
|
||||
|
Loading…
Reference in New Issue
Block a user