Skip to content

Commit 8e0e715

Browse files
authored
ignore git warning 'globally' (#6833)
* ignore git warning 'globally' * improve comment
1 parent edb3a80 commit 8e0e715

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

test/prototype_transforms_kernel_infos.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import functools
33
import itertools
44
import math
5-
import re
65

76
import numpy as np
87
import pytest
@@ -159,12 +158,6 @@ def sample_inputs_horizontal_flip_video():
159158
KernelInfo(
160159
F.horizontal_flip_bounding_box,
161160
sample_inputs_fn=sample_inputs_horizontal_flip_bounding_box,
162-
test_marks=[
163-
TestMark(
164-
("TestKernels", "test_scripted_vs_eager"),
165-
pytest.mark.filterwarnings(f"ignore:{re.escape('operator() profile_node %72')}:UserWarning"),
166-
)
167-
],
168161
),
169162
KernelInfo(
170163
F.horizontal_flip_mask,
@@ -2045,17 +2038,11 @@ def sample_inputs_convert_dtype_video():
20452038
yield ArgsKwargs(video_loader)
20462039

20472040

2048-
_common_convert_dtype_marks = [
2049-
TestMark(
2050-
("TestKernels", "test_dtype_and_device_consistency"),
2051-
pytest.mark.skip(reason="`convert_dtype_*` kernels convert the dtype by design"),
2052-
condition=lambda args_kwargs: args_kwargs.args[0].dtype != args_kwargs.kwargs.get("dtype", torch.float32),
2053-
),
2054-
TestMark(
2055-
("TestKernels", "test_scripted_vs_eager"),
2056-
pytest.mark.filterwarnings(f"ignore:{re.escape('operator() profile_node %')}:UserWarning"),
2057-
),
2058-
]
2041+
skip_dtype_consistency = TestMark(
2042+
("TestKernels", "test_dtype_and_device_consistency"),
2043+
pytest.mark.skip(reason="`convert_dtype_*` kernels convert the dtype by design"),
2044+
condition=lambda args_kwargs: args_kwargs.args[0].dtype != args_kwargs.kwargs.get("dtype", torch.float32),
2045+
)
20592046

20602047
KERNEL_INFOS.extend(
20612048
[
@@ -2065,7 +2052,7 @@ def sample_inputs_convert_dtype_video():
20652052
reference_fn=reference_convert_dtype_image_tensor,
20662053
reference_inputs_fn=reference_inputs_convert_dtype_image_tensor,
20672054
test_marks=[
2068-
*_common_convert_dtype_marks,
2055+
skip_dtype_consistency,
20692056
TestMark(
20702057
("TestKernels", "test_against_reference"),
20712058
pytest.mark.xfail(reason="Conversion overflows"),
@@ -2083,7 +2070,9 @@ def sample_inputs_convert_dtype_video():
20832070
KernelInfo(
20842071
F.convert_dtype_video,
20852072
sample_inputs_fn=sample_inputs_convert_dtype_video,
2086-
test_marks=_common_convert_dtype_marks,
2073+
test_marks=[
2074+
skip_dtype_consistency,
2075+
],
20872076
),
20882077
]
20892078
)

test/test_prototype_transforms_functional.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22
import os
3+
import re
34

45
import numpy as np
56
import PIL.Image
@@ -26,6 +27,15 @@ def script(fn):
2627
raise AssertionError(f"Trying to `torch.jit.script` '{fn.__name__}' raised the error above.") from error
2728

2829

30+
# Scripting a function often triggers a warning like
31+
# `UserWarning: operator() profile_node %$INT1 : int[] = prim::profile_ivalue($INT2) does not have profile information`
32+
# with varying `INT1` and `INT2`. Since these are uninteresting for us and only clutter the test summary, we ignore
33+
# them.
34+
ignore_jit_warning_no_profile = pytest.mark.filterwarnings(
35+
f"ignore:{re.escape('operator() profile_node %')}:UserWarning"
36+
)
37+
38+
2939
def make_info_args_kwargs_params(info, *, args_kwargs_fn, test_id=None):
3040
args_kwargs = list(args_kwargs_fn(info))
3141
idx_field_len = len(str(len(args_kwargs)))
@@ -87,6 +97,7 @@ class TestKernels:
8797
condition=lambda info: info.reference_fn is not None,
8898
)
8999

100+
@ignore_jit_warning_no_profile
90101
@sample_inputs
91102
@pytest.mark.parametrize("device", cpu_and_gpu())
92103
def test_scripted_vs_eager(self, info, args_kwargs, device):
@@ -218,6 +229,7 @@ class TestDispatchers:
218229
condition=lambda info: features.Image in info.kernels,
219230
)
220231

232+
@ignore_jit_warning_no_profile
221233
@image_sample_inputs
222234
@pytest.mark.parametrize("device", cpu_and_gpu())
223235
def test_scripted_smoke(self, info, args_kwargs, device):
@@ -230,6 +242,7 @@ def test_scripted_smoke(self, info, args_kwargs, device):
230242

231243
# TODO: We need this until the dispatchers below also have `DispatcherInfo`'s. If they do, `test_scripted_smoke`
232244
# replaces this test for them.
245+
@ignore_jit_warning_no_profile
233246
@pytest.mark.parametrize(
234247
"dispatcher",
235248
[

0 commit comments

Comments
 (0)