()
| 348 | |
| 349 | @attr("pytorch") |
| 350 | def test_dali_proxy_error_propagation(): |
| 351 | from nvidia.dali.plugin.pytorch.experimental import proxy as dali_proxy |
| 352 | import torchvision.datasets as datasets |
| 353 | |
| 354 | batch_size = 4 |
| 355 | num_threads = 3 |
| 356 | device_id = 0 |
| 357 | nworkers = 2 |
| 358 | |
| 359 | @pipeline_def |
| 360 | def pipe_with_error(): |
| 361 | images = fn.external_source(name="images", no_copy=True) |
| 362 | error_anchor = types.Constant(np.array([-10], dtype=np.float32)) |
| 363 | return fn.crop( |
| 364 | images, crop=(224, 224), crop_pos_x=error_anchor, out_of_bounds_policy="error" |
| 365 | ) |
| 366 | |
| 367 | pipe = pipe_with_error( |
| 368 | batch_size=batch_size, |
| 369 | num_threads=num_threads, |
| 370 | device_id=device_id, |
| 371 | prefetch_queue_depth=3, |
| 372 | ) |
| 373 | with dali_proxy.DALIServer(pipe) as dali_server: |
| 374 | |
| 375 | dataset = datasets.ImageFolder(jpeg, transform=dali_server.proxy) |
| 376 | loader = dali_proxy.DataLoader( |
| 377 | dali_server, |
| 378 | dataset, |
| 379 | batch_size=batch_size, |
| 380 | num_workers=nworkers, |
| 381 | ) |
| 382 | |
| 383 | err_msg = "Critical error in pipeline:*Anchor for dimension 1*is out of range*" |
| 384 | with assert_raises(RuntimeError, glob=err_msg): |
| 385 | next(iter(loader)) |
| 386 | |
| 387 | # For some reason if we don't do this in this test, we see some ignored exception |
| 388 | # messages in the next test |
| 389 | pipe._shutdown() |
| 390 | del pipe |
| 391 | |
| 392 | |
| 393 | @attr("pytorch") |
nothing calls this directly
no test coverage detected