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

Function _test_external_source_callback

dali/test/python/test_external_source_impl.py:239–257  ·  view source on GitHub ↗
(use_fn_api, batch, as_tensor, device)

Source from the content-addressed store, hash-verified

237
238
239def _test_external_source_callback(use_fn_api, batch, as_tensor, device):
240 iter_num = 5
241 batch_size = 9
242 pipe = Pipeline(batch_size, 3, 0)
243
244 # this should produce a single Tensor / TensorList per batch,
245 # not wrapped in additional list
246 source = TestIterator(iter_num, batch_size, 4, device == "gpu")
247
248 iter_in = iter(source) if batch else iter(SampleIterator(iter(source)))
249
250 if use_fn_api:
251 input = fn.external_source(lambda: next(iter_in), device=device, batch=batch)
252 else:
253 ext_source = ops.ExternalSource(lambda: next(iter_in), device=device, batch=batch)
254 input = ext_source()
255 pipe.set_outputs(input)
256
257 run_and_check(pipe, source)
258
259
260def test_external_source_callback():

Callers

nothing calls this directly

Calls 7

set_outputsMethod · 0.95
PipelineClass · 0.90
SampleIteratorClass · 0.85
nextFunction · 0.85
ExternalSourceMethod · 0.80
TestIteratorClass · 0.70
run_and_checkFunction · 0.70

Tested by

no test coverage detected