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

Function check_stop_iter

dali/test/python/test_fw_iterators.py:1167–1190  ·  view source on GitHub ↗
(
    fw_iter, iterator_name, batch_size, epochs, iter_num, total_iter_num, auto_reset, infinite
)

Source from the content-addressed store, hash-verified

1165
1166
1167def check_stop_iter(
1168 fw_iter, iterator_name, batch_size, epochs, iter_num, total_iter_num, auto_reset, infinite
1169):
1170 it = TestIterator(iter_num, batch_size, total_iter_num)
1171 pipe = create_test_iter_pipeline(batch_size, 0, it)
1172 if infinite:
1173 iter_size = -1
1174 else:
1175 iter_size = it.size
1176 loader = fw_iter(pipe, iter_size, auto_reset)
1177 count = 0
1178 for _ in range(epochs):
1179 for _ in enumerate(loader):
1180 count += 1
1181 if not auto_reset:
1182 loader.reset()
1183 if total_iter_num < 0:
1184 # infinite source of data
1185 assert count == iter_num * epochs
1186 else:
1187 # at most total_iter_num should be returned by the iterator
1188 assert count == min(
1189 total_iter_num, iter_num * epochs
1190 ), f"{count}, {total_iter_num}, {iter_num} * {epochs} == {iter_num * epochs}"
1191
1192
1193@raises(Exception, glob="Negative size is supported only for a single pipeline")

Callers 3

test_stop_iteration_jaxFunction · 0.85

Calls 5

fw_iterFunction · 0.85
TestIteratorClass · 0.70
minFunction · 0.50
resetMethod · 0.45

Tested by

no test coverage detected