(backend, dim, channel_first, dtype, interp)
| 662 | |
| 663 | |
| 664 | def _test_stitching(backend, dim, channel_first, dtype, interp): |
| 665 | batch_size = 1 if dim == 3 else 10 |
| 666 | pipe = dali.pipeline.Pipeline( |
| 667 | batch_size=batch_size, num_threads=1, device_id=0, seed=1234, prefetch_queue_depth=1 |
| 668 | ) |
| 669 | with pipe: |
| 670 | if dim == 2: |
| 671 | files, labels = dali.fn.readers.caffe(path=db_2d_folder, random_shuffle=True) |
| 672 | images_cpu = dali.fn.decoders.image(files, device="cpu") |
| 673 | else: |
| 674 | images_cpu = dali.fn.external_source(source=random_3d_loader(batch_size), layout="DHWC") |
| 675 | |
| 676 | images_hwc = images_cpu if backend_device(backend) == "cpu" else images_cpu.gpu() |
| 677 | |
| 678 | if channel_first: |
| 679 | images = dali.fn.transpose( |
| 680 | images_hwc, perm=[3, 0, 1, 2] if dim == 3 else [2, 0, 1], transpose_layout=True |
| 681 | ) |
| 682 | else: |
| 683 | images = images_hwc |
| 684 | |
| 685 | out_size_full = [32, 32, 32] if dim == 3 else [160, 160] |
| 686 | out_size_half = [x // 2 for x in out_size_full] |
| 687 | |
| 688 | roi_start = [0] * dim |
| 689 | roi_end = [1] * dim |
| 690 | |
| 691 | resized = resize_op(backend)( |
| 692 | images, dtype=dtype, min_filter=interp, mag_filter=interp, size=out_size_full |
| 693 | ) |
| 694 | |
| 695 | outputs = [resized] |
| 696 | |
| 697 | for z in range(dim - 1): |
| 698 | if dim == 3: |
| 699 | roi_start[0] = z * 0.5 |
| 700 | roi_end[0] = (z + 1) * 0.5 |
| 701 | for y in [0, 1]: |
| 702 | roi_start[-2] = y * 0.5 |
| 703 | roi_end[-2] = (y + 1) * 0.5 |
| 704 | for x in [0, 1]: |
| 705 | roi_start[-1] = x * 0.5 |
| 706 | roi_end[-1] = (x + 1) * 0.5 |
| 707 | |
| 708 | part = fn.resize( |
| 709 | images, |
| 710 | dtype=dtype, |
| 711 | interp_type=interp, |
| 712 | size=out_size_half, |
| 713 | roi_start=roi_start, |
| 714 | roi_end=roi_end, |
| 715 | roi_relative=True, |
| 716 | ) |
| 717 | outputs.append(part) |
| 718 | |
| 719 | pipe.set_outputs(*outputs) |
| 720 | |
| 721 | for iter in range(1): |
nothing calls this directly
no test coverage detected