MCPcopy Create free account
hub / github.com/NVIDIA/DALI / test_pool_no_overwrite_batch

Method test_pool_no_overwrite_batch

dali/test/python/test_pool.py:157–179  ·  view source on GitHub ↗
(self, start_method)

Source from the content-addressed store, hash-verified

155 # Test that we can safely hold as many results as the keep_alive_queue_size
156 @params(*start_methods)
157 def test_pool_no_overwrite_batch(self, start_method):
158 groups = [MockGroup.from_callback(simple_callback, prefetch_queue_depth=0)]
159 for depth in [1, 2, 4, 8]:
160 with create_pool(
161 groups, keep_alive_queue_size=depth, num_workers=1, start_method=start_method
162 ) as pool:
163 pids = get_pids(pool)
164 pid = pids[0]
165 work_batches = [
166 TaskArgs.make_sample(SampleRange(i, i + 1, i, 0)) for i in range(depth)
167 ]
168 task_list = [[(SampleInfo(i, 0, i, 0),)] for i in range(depth)]
169 for i, work_batch in enumerate(work_batches):
170 pool.schedule_batch(context_i=0, work_batch=work_batch)
171 assert_scheduled_num(pool.contexts[0], depth)
172 batches = []
173 for i in range(depth):
174 batches.append(pool.receive_batch(context_i=0))
175 assert_scheduled_num(pool.contexts[0], depth - 1 - i)
176 tasks_batches = zip(task_list, batches)
177 for tasks, batch in tasks_batches:
178 for task, sample in zip(tasks, batch):
179 np.testing.assert_array_equal(answer(pid, *task), sample)
180
181
182# ################################################################################################ #

Callers

nothing calls this directly

Calls 11

SampleRangeClass · 0.90
SampleInfoClass · 0.90
create_poolFunction · 0.85
get_pidsFunction · 0.85
assert_scheduled_numFunction · 0.85
answerFunction · 0.85
from_callbackMethod · 0.80
make_sampleMethod · 0.80
receive_batchMethod · 0.80
schedule_batchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected