(use_fn_api, batch, as_tensor, device)
| 237 | |
| 238 | |
| 239 | def _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 | |
| 260 | def test_external_source_callback(): |
nothing calls this directly
no test coverage detected