Skip to content

Commit 7408ce2

Browse files
David Riazatifacebook-github-bot
authored andcommitted
Supress warnings on generated tests
Summary: Removes all warnings spew for the TestJitGenerated tests Differential Revision: D13420919 fbshipit-source-id: f251c12f923088ccc5daa2984c15003a67cbd1c1
1 parent 04b65df commit 7408ce2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/test_jit.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
freeze_rng_state
1717
from common_nn import module_tests, new_module_tests, criterion_tests
1818
from textwrap import dedent
19+
from functools import wraps
1920
import os
2021
import io
2122
import itertools
@@ -10708,6 +10709,14 @@ def fn(*inputs, **kwargs):
1070810709
post_add_test(test_name, skipTestIf, do_test)
1070910710

1071010711

10712+
def suppress_warnings(fn):
10713+
@wraps(fn)
10714+
def wrapper(*args, **kwargs):
10715+
with warnings.catch_warnings(record=True):
10716+
return fn(*args, **kwargs)
10717+
return wrapper
10718+
10719+
1071110720
def add_nn_functional_test(name, self_size, args, variant_name='', skipTestIf=(),
1071210721
output_process_fn=lambda x: x, kwargs=None):
1071310722
test_name = 'test_nn_' + name
@@ -10717,6 +10726,7 @@ def add_nn_functional_test(name, self_size, args, variant_name='', skipTestIf=()
1071710726

1071810727
no_grad = variant_name == 'inplace'
1071910728

10729+
@suppress_warnings
1072010730
def do_test(self, name=name, args=args, test_name=test_name):
1072110731
torch.manual_seed(2)
1072210732

@@ -10780,6 +10790,7 @@ def add_nn_module_test(*args, **kwargs):
1078010790
test_name = "{}_{}".format(test_name, kwargs['desc'])
1078110791
test_name = 'test_nn_{}'.format(test_name)
1078210792

10793+
@suppress_warnings
1078310794
def do_test(self):
1078410795
if test_name in EXCLUDE_SCRIPT_MODULES:
1078510796
return

0 commit comments

Comments
 (0)