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

Function test_initial_hint

dali/test/python/test_external_source_parallel.py:1182–1215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1180
1181
1182def test_initial_hint():
1183 sample_size = 32 * 1024 * 1024
1184 shapes = [(32, 1024, 1024)]
1185 # make the initial size still smaller than necessary to check if reallocation works
1186 bytes_per_sample_hint = 4 * 1024 * 1024
1187 batch_size = 7
1188 num_workers = 3
1189 min_samples_in_mini_batch = batch_size // num_workers
1190 max_samples_in_mini_batch = (batch_size + num_workers - 1) // num_workers
1191 initial_shm_size = max_samples_in_mini_batch * bytes_per_sample_hint
1192 expected_min_chunk_size = min_samples_in_mini_batch * sample_size
1193
1194 pipe = per_iter_shape_pipeline(
1195 shapes,
1196 bytes_per_sample_hint=bytes_per_sample_hint,
1197 batch_size=batch_size,
1198 py_num_workers=num_workers,
1199 )
1200 sizes = pipe.external_source_shm_statistics()["capacities"]
1201 assert len(sizes) > 0
1202 for size in sizes:
1203 assert (
1204 size == initial_shm_size
1205 ), f"Expected initial size to be {initial_shm_size}, got {size}."
1206
1207 for _ in range(5):
1208 pipe.run()
1209
1210 sizes = pipe.external_source_shm_statistics()["capacities"]
1211 assert len(sizes) > 0
1212 for size in sizes:
1213 assert (
1214 size >= expected_min_chunk_size
1215 ), f"Expected the size to be at least {expected_min_chunk_size}, got {size}."
1216
1217
1218def test_variable_sample_size():

Callers

nothing calls this directly

Calls 3

per_iter_shape_pipelineFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected