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

Function _test_stitching

dali/test/python/operator_2/test_resize.py:664–746  ·  view source on GitHub ↗
(backend, dim, channel_first, dtype, interp)

Source from the content-addressed store, hash-verified

662
663
664def _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):

Callers

nothing calls this directly

Calls 11

set_outputsMethod · 0.95
runMethod · 0.95
check_batchFunction · 0.90
random_3d_loaderClass · 0.85
backend_deviceFunction · 0.85
resize_opFunction · 0.85
PipelineMethod · 0.80
gpuMethod · 0.45
resizeMethod · 0.45
appendMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected