Spaces:
Sleeping
Sleeping
Download vram/dram_cache.py from factorstudios/FServe: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/factorstudios/FServe/resolve/main/vram/dram_cache.py
- Command line
-
hf download hf://spaces/factorstudios/FServe/vram/dram_cache.py
-
curl -L -o dram_cache.py https://huggingface.co/spaces/factorstudios/FServe/resolve/main/vram/dram_cache.py
1.12 kB
| class DRAMCache: | |
| def __init__(self, size_mb=None): | |
| """Initialize DRAM cache with unlimited capacity""" | |
| self.cache = {} | |
| self.access_order = [] | |
| self.is_unlimited = True | |
| def read(self, key): | |
| if key in self.cache: | |
| self.access_order.remove(key) | |
| self.access_order.append(key) | |
| return self.cache[key] | |
| return None | |
| def write(self, key, value): | |
| """Write to cache with unlimited capacity - no eviction needed""" | |
| if key in self.cache: | |
| self.access_order.remove(key) | |
| self.cache[key] = value | |
| self.access_order.append(key) | |
| class Buffer: | |
| def __init__(self, size_mb=None): | |
| """Initialize buffer with unlimited capacity""" | |
| self.buffer = [] | |
| self.is_unlimited = True | |
| def add(self, data): | |
| """Add data to buffer - no size restrictions""" | |
| self.buffer.append(data) | |
| def flush(self): | |
| """Flush buffer and return all data""" | |
| flushed = self.buffer[:] | |
| self.buffer = [] | |
| return flushed | |