Skip to content

Commit 94761fb

Browse files
committed
Fix bug
1 parent ee5a9e9 commit 94761fb

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ dependencies = [
1212
[dependency-groups]
1313
dev = [
1414
"pytest>=8.4.0",
15+
"tqdm>=4.67.1",
1516
]

tests/test_loader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import numpy as np
55
import tinygrad
6+
import tqdm
67

78
from tinyloader.loader import load
89
from tinyloader.loader import load_with_workers
@@ -63,12 +64,14 @@ def test_load_with_workers():
6364
def test_share_memory_shim():
6465
data_size = (3, 512, 512)
6566
label_size = (4,)
66-
num_worker = 4
67+
num_worker = 8
6768
n = 1000
6869
count = 0
6970
with SharedMemoryManager() as smm:
7071
loader = SharedMemoryShim(
71-
RandomLoader(data_size=data_size, label_size=label_size), smm=smm
72+
RandomLoader(data_size=data_size, label_size=label_size),
73+
smm=smm,
74+
memory_pool_block_count=num_worker,
7275
)
7376
with load_with_workers(loader, range(n), num_worker) as generator:
7477
for x, y in generator:

tinyloader/loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def post_process(
173173
for shared in response:
174174
array = shared.to_ndarray()
175175
new_resp.append(array)
176-
self._memory_pools[shared.buffer.size].push(shared.buffer)
176+
self._memory_pools[shared.buffer.actual_block_size].push(shared.buffer)
177177
logger.debug("Return shared buffer %s to pool", shared.buffer)
178178
return self.loader.post_process(tuple(new_resp))
179179

uv.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)