Skip to content

Commit dd5a564

Browse files
authored
Merge branch 'main' into test-transforms-v2-dropin
2 parents 6768182 + b828671 commit dd5a564

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def get_extensions():
223223
extra_compile_args["nvcc"] = [f for f in nvcc_flags if not ("-O" in f or "-g" in f)]
224224
extra_compile_args["nvcc"].append("-O0")
225225
extra_compile_args["nvcc"].append("-g")
226+
else:
227+
print("Compiling with debug mode OFF")
228+
extra_compile_args["cxx"].append("-g0")
226229

227230
sources = [os.path.join(extensions_dir, s) for s in sources]
228231

test/test_transforms_v2_consistency.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,11 @@ def test_randaug(self, inpt, interpolation, mocker):
755755
v2_transforms.InterpolationMode.BILINEAR,
756756
],
757757
)
758-
def test_randaug_jit(self, interpolation):
758+
@pytest.mark.parametrize("fill", [None, 85, (10, -10, 10), 0.7, [0.0, 0.0, 0.0], [1], 1])
759+
def test_randaug_jit(self, interpolation, fill):
759760
inpt = torch.randint(0, 256, size=(1, 3, 256, 256), dtype=torch.uint8)
760-
t_ref = legacy_transforms.RandAugment(interpolation=interpolation, num_ops=1)
761-
t = v2_transforms.RandAugment(interpolation=interpolation, num_ops=1)
761+
t_ref = legacy_transforms.RandAugment(interpolation=interpolation, num_ops=1, fill=fill)
762+
t = v2_transforms.RandAugment(interpolation=interpolation, num_ops=1, fill=fill)
762763

763764
tt_ref = torch.jit.script(t_ref)
764765
tt = torch.jit.script(t)
@@ -830,10 +831,11 @@ def test_trivial_aug(self, inpt, interpolation, mocker):
830831
v2_transforms.InterpolationMode.BILINEAR,
831832
],
832833
)
833-
def test_trivial_aug_jit(self, interpolation):
834+
@pytest.mark.parametrize("fill", [None, 85, (10, -10, 10), 0.7, [0.0, 0.0, 0.0], [1], 1])
835+
def test_trivial_aug_jit(self, interpolation, fill):
834836
inpt = torch.randint(0, 256, size=(1, 3, 256, 256), dtype=torch.uint8)
835-
t_ref = legacy_transforms.TrivialAugmentWide(interpolation=interpolation)
836-
t = v2_transforms.TrivialAugmentWide(interpolation=interpolation)
837+
t_ref = legacy_transforms.TrivialAugmentWide(interpolation=interpolation, fill=fill)
838+
t = v2_transforms.TrivialAugmentWide(interpolation=interpolation, fill=fill)
837839

838840
tt_ref = torch.jit.script(t_ref)
839841
tt = torch.jit.script(t)
@@ -906,11 +908,12 @@ def test_augmix(self, inpt, interpolation, mocker):
906908
v2_transforms.InterpolationMode.BILINEAR,
907909
],
908910
)
909-
def test_augmix_jit(self, interpolation):
911+
@pytest.mark.parametrize("fill", [None, 85, (10, -10, 10), 0.7, [0.0, 0.0, 0.0], [1], 1])
912+
def test_augmix_jit(self, interpolation, fill):
910913
inpt = torch.randint(0, 256, size=(1, 3, 256, 256), dtype=torch.uint8)
911914

912-
t_ref = legacy_transforms.AugMix(interpolation=interpolation, mixture_width=1, chain_depth=1)
913-
t = v2_transforms.AugMix(interpolation=interpolation, mixture_width=1, chain_depth=1)
915+
t_ref = legacy_transforms.AugMix(interpolation=interpolation, mixture_width=1, chain_depth=1, fill=fill)
916+
t = v2_transforms.AugMix(interpolation=interpolation, mixture_width=1, chain_depth=1, fill=fill)
914917

915918
tt_ref = torch.jit.script(t_ref)
916919
tt = torch.jit.script(t)

torchvision/transforms/v2/_auto_augment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def __init__(
3333
def _extract_params_for_v1_transform(self) -> Dict[str, Any]:
3434
params = super()._extract_params_for_v1_transform()
3535

36-
if not (params["fill"] is None or isinstance(params["fill"], (int, float))):
37-
raise ValueError(f"{type(self).__name__}() can only be scripted for a scalar `fill`, but got {self.fill}.")
36+
if isinstance(params["fill"], dict):
37+
raise ValueError(f"{type(self).__name__}() can not be scripted for when `fill` is a dictionary.")
3838

3939
return params
4040

torchvision/tv_tensors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import torch
22

3-
from ._bounding_box import BoundingBoxes, BoundingBoxFormat
3+
from ._bounding_boxes import BoundingBoxes, BoundingBoxFormat
44
from ._image import Image
55
from ._mask import Mask
66
from ._torch_function_helpers import set_return_type

0 commit comments

Comments
 (0)