mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-24 17:31:16 +08:00
only add to residency set once (#2049)
This commit is contained in:
parent
ba09f01ce8
commit
1a28b69ee2
@ -272,9 +272,13 @@ Buffer MetalAllocator::malloc(size_t size) {
|
|||||||
if (!buf) {
|
if (!buf) {
|
||||||
buf = device_->newBuffer(size, resource_options);
|
buf = device_->newBuffer(size, resource_options);
|
||||||
}
|
}
|
||||||
|
if (!buf) {
|
||||||
|
return Buffer{nullptr};
|
||||||
|
}
|
||||||
lk.lock();
|
lk.lock();
|
||||||
if (buf) {
|
|
||||||
num_resources_++;
|
num_resources_++;
|
||||||
|
if (!buf->heap()) {
|
||||||
|
residency_set_.insert(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,10 +292,6 @@ Buffer MetalAllocator::malloc(size_t size) {
|
|||||||
get_cache_memory() - max_pool_size_);
|
get_cache_memory() - max_pool_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buf->heap()) {
|
|
||||||
residency_set_.insert(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Buffer{static_cast<void*>(buf)};
|
return Buffer{static_cast<void*>(buf)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user