(self, size, interpolation, use_max_size, antialias, dtype, device)
| 725 | @pytest.mark.parametrize("dtype", [torch.float32, torch.uint8]) |
| 726 | @pytest.mark.parametrize("device", cpu_and_cuda()) |
| 727 | def test_kernel_image(self, size, interpolation, use_max_size, antialias, dtype, device): |
| 728 | if not (max_size_kwarg := self._make_max_size_kwarg(use_max_size=use_max_size, size=size)): |
| 729 | return |
| 730 | |
| 731 | if interpolation is transforms.InterpolationMode.LANCZOS and str(device) == "cuda": |
| 732 | pytest.skip("Lanczos is not supported on CUDA") |
| 733 | |
| 734 | if interpolation is transforms.InterpolationMode.LANCZOS and not antialias: |
| 735 | pytest.skip("Lanczos requires antialias=True") |
| 736 | |
| 737 | # In contrast to CPU, there is no native `InterpolationMode.BICUBIC` implementation for uint8 images on CUDA. |
| 738 | # Internally, it uses the float path. Thus, we need to test with an enormous tolerance here to account for that. |
| 739 | atol = ( |
| 740 | 30 |
| 741 | if ( |
| 742 | interpolation in (transforms.InterpolationMode.BICUBIC, transforms.InterpolationMode.LANCZOS) |
| 743 | and dtype is torch.uint8 |
| 744 | ) |
| 745 | else 1 |
| 746 | ) |
| 747 | check_cuda_vs_cpu_tolerances = dict(rtol=0, atol=atol / 255 if dtype.is_floating_point else atol) |
| 748 | |
| 749 | check_kernel( |
| 750 | F.resize_image, |
| 751 | make_image(self.INPUT_SIZE, dtype=dtype, device=device), |
| 752 | size=size, |
| 753 | interpolation=interpolation, |
| 754 | **max_size_kwarg, |
| 755 | antialias=antialias, |
| 756 | check_cuda_vs_cpu=check_cuda_vs_cpu_tolerances, |
| 757 | check_scripted_vs_eager=not isinstance(size, int), |
| 758 | ) |
| 759 | |
| 760 | @pytest.mark.parametrize("format", list(tv_tensors.BoundingBoxFormat)) |
| 761 | @pytest.mark.parametrize("size", OUTPUT_SIZES) |
nothing calls this directly
no test coverage detected