From a9080fdd43242e46692bfb4c7bd31613367e6f6f Mon Sep 17 00:00:00 2001 From: qazal Date: Tue, 25 Mar 2025 18:36:50 +0800 Subject: [PATCH] it shouldn't have memory usage --- tinygrad/device.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinygrad/device.py b/tinygrad/device.py index 4399ddbb5c..7213e8ba07 100644 --- a/tinygrad/device.py +++ b/tinygrad/device.py @@ -126,12 +126,12 @@ class Buffer: self._buf: Any = self.allocator._offset(self.base._buf, self.nbytes, self.offset) else: self._buf = opaque if opaque is not None else self.allocator.alloc(self.nbytes, self.options) - if not self.device.startswith("DISK"): GlobalCounters.mem_used += self.nbytes + if not self.device.startswith("DISK") and not self.device.startswith("NULL"): GlobalCounters.mem_used += self.nbytes return self def deallocate(self): assert self.is_allocated(), "buffer must be allocated to deallocate" if self._base is None and (self.options is None or self.options.external_ptr is None): - if not self.device.startswith("DISK"): GlobalCounters.mem_used -= self.nbytes + if not self.device.startswith("DISK") and not self.device.startswith("NULL"): GlobalCounters.mem_used -= self.nbytes self.allocator.free(self._buf, self.nbytes, self.options) del self._buf def __reduce__(self):