From: Soumith Chintala Date: Thu, 21 Feb 2019 18:55:14 +0000 (-0800) Subject: remove nn.Upsample deprecation warnings from tests (#17352) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~1161 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c63af8837d443db21166b3b92370fce4ede70e4f;p=platform%2Fupstream%2Fpytorch.git remove nn.Upsample deprecation warnings from tests (#17352) Differential Revision: D14168481 Pulled By: soumith fbshipit-source-id: 63c37c5f04d2529abd4f42558a3d5e81993eecec --- diff --git a/test/common_nn.py b/test/common_nn.py index 97d2e0a..4879c63 100644 --- a/test/common_nn.py +++ b/test/common_nn.py @@ -1668,206 +1668,206 @@ new_module_tests = [ input_size=(1, 9, 4, 4), ), dict( - module_name='Upsample', - constructor_args=(12, None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='nearest'), input_size=(1, 2, 4), - desc='nearest_1d', + fullname='interpolate_nearest_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((12, ), None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=(12, ), scale_factor=None, mode='nearest'), input_size=(1, 2, 3), - desc='nearest_tuple_1d', + fullname='interpolate_nearest_tuple_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'nearest'), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='nearest'), input_size=(1, 2, 4), - desc='nearest_scale_1d', + fullname='interpolate_nearest_scale_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'linear', False), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='linear', align_corners=False), input_size=(1, 2, 4), - desc='linear_1d', + fullname='interpolate_linear_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, ), None, 'linear', False), + constructor=wrap_functional(F.interpolate, size=(4, ), scale_factor=None, mode='linear', align_corners=False), input_size=(1, 2, 3), - desc='linear_tuple_1d', + fullname='interpolate_linear_tuple_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'linear', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='linear', align_corners=False), input_size=(1, 2, 4), - desc='linear_scale_1d', + fullname='interpolate_linear_scale_1d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'linear', True), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='linear', align_corners=True), input_size=(1, 2, 4), - desc='linear_1d_align_corners', + fullname='interpolate_linear_1d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'linear', True), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='linear', align_corners=True), input_size=(1, 2, 4), - desc='linear_scale_1d_align_corners', + fullname='interpolate_linear_scale_1d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='nearest'), input_size=(1, 2, 4, 4), - desc='nearest_2d', + fullname='interpolate_nearest_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((12, 16), None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=(12, 16), scale_factor=None, mode='nearest'), input_size=(1, 2, 3, 4), - desc='nearest_tuple_2d', + fullname='interpolate_nearest_tuple_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'nearest'), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='nearest'), input_size=(1, 2, 4, 4), - desc='nearest_scale_2d', + fullname='interpolate_nearest_scale_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'bilinear', False), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='bilinear', align_corners=False), input_size=(1, 2, 4, 4), - desc='bilinear_2d', + fullname='interpolate_bilinear_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6), None, 'bilinear', False), + constructor=wrap_functional(F.interpolate, size=(4, 6), scale_factor=None, mode='bilinear', align_corners=False), input_size=(1, 2, 2, 3), - desc='bilinear_tuple_2d', + fullname='interpolate_bilinear_tuple_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'bilinear', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='bilinear', align_corners=False), input_size=(1, 2, 4, 4), - desc='bilinear_scale_2d', + fullname='interpolate_bilinear_scale_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 2.), 'bilinear', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 2.), mode='bilinear', align_corners=False), input_size=(1, 2, 4, 4), - desc='bilinear_scale_tuple_shared_2d', + fullname='interpolate_bilinear_scale_tuple_shared_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 1.), 'bilinear', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 1.), mode='bilinear', align_corners=False), input_size=(1, 2, 4, 4), - desc='bilinear_scale_tuple_skewed_2d', + fullname='interpolate_bilinear_scale_tuple_skewed_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6), None, 'bilinear', True), + constructor=wrap_functional(F.interpolate, size=(4, 6), scale_factor=None, mode='bilinear', align_corners=True), input_size=(1, 2, 4, 4), - desc='bilinear_tuple_2d_align_corners', + fullname='interpolate_bilinear_tuple_2d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 1.), 'bilinear', True), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 1.), mode='bilinear', align_corners=True), input_size=(1, 2, 4, 4), - desc='bilinear_scale_tuple_skewed_2d_align_corners', + fullname='interpolate_bilinear_scale_tuple_skewed_2d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'bicubic', False), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='bicubic', align_corners=False), input_size=(1, 2, 4, 4), - desc='bicubic_2d', + fullname='interpolate_bicubic_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6), None, 'bicubic', False), + constructor=wrap_functional(F.interpolate, size=(4, 6), scale_factor=None, mode='bicubic', align_corners=False), input_size=(1, 2, 2, 3), - desc='bicubic_tuple_2d', + fullname='interpolate_bicubic_tuple_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'bicubic', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='bicubic', align_corners=False), input_size=(1, 2, 4, 4), - desc='bicubic_scale_2d', + fullname='interpolate_bicubic_scale_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 2.), 'bicubic', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 2.), mode='bicubic', align_corners=False), input_size=(1, 2, 4, 4), - desc='bicubic_scale_tuple_shared_2d', + fullname='interpolate_bicubic_scale_tuple_shared_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 1.), 'bicubic', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 1.), mode='bicubic', align_corners=False), input_size=(1, 2, 4, 4), - desc='bicubic_scale_tuple_skewed_2d', + fullname='interpolate_bicubic_scale_tuple_skewed_2d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6), None, 'bicubic', True), + constructor=wrap_functional(F.interpolate, size=(4, 6), scale_factor=None, mode='bicubic', align_corners=True), input_size=(1, 2, 4, 4), - desc='bicubic_tuple_2d_align_corners', + fullname='interpolate_bicubic_tuple_2d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, (2., 1.), 'bicubic', True), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=(2., 1.), mode='bicubic', align_corners=True), input_size=(1, 2, 4, 4), - desc='bicubic_scale_tuple_skewed_2d_align_corners', + fullname='interpolate_bicubic_scale_tuple_skewed_2d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='nearest'), input_size=(1, 2, 4, 4, 4), - desc='nearest_3d', + fullname='interpolate_nearest_3d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((12, 16, 16), None, 'nearest'), + constructor=wrap_functional(F.interpolate, size=(12, 16, 16), scale_factor=None, mode='nearest'), input_size=(1, 2, 3, 4, 4), - desc='nearest_tuple_3d', + fullname='interpolate_nearest_tuple_3d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 4., 'nearest'), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=4., mode='nearest'), input_size=(1, 2, 4, 4, 4), - desc='nearest_scale_3d', + fullname='interpolate_nearest_scale_3d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(12, None, 'trilinear', False), + constructor=wrap_functional(F.interpolate, size=12, scale_factor=None, mode='trilinear', align_corners=False), input_size=(1, 2, 4, 4, 4), - desc='trilinear_3d', + fullname='interpolate_trilinear_3d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6, 6), None, 'trilinear', False), + constructor=wrap_functional(F.interpolate, size=(4, 6, 6), scale_factor=None, mode='trilinear', align_corners=False), input_size=(1, 2, 2, 3, 3), - desc='trilinear_tuple_3d', + fullname='interpolate_trilinear_tuple_3d', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 3., 'trilinear', False), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=3., mode='trilinear', align_corners=False), input_size=(1, 2, 3, 4, 4), - desc='trilinear_scale_3d', + fullname='interpolate_trilinear_scale_3d', # See https://github.com/pytorch/pytorch/issues/5006 precision=3e-4, + pickle=False, ), dict( - module_name='Upsample', - constructor_args=((4, 6, 6), None, 'trilinear', True), + constructor=wrap_functional(F.interpolate, size=(4, 6, 6), scale_factor=None, mode='trilinear', align_corners=True), input_size=(1, 2, 2, 3, 3), - desc='trilinear_tuple_3d_align_corners', + fullname='interpolate_trilinear_tuple_3d_align_corners', + pickle=False, ), dict( - module_name='Upsample', - constructor_args=(None, 3., 'trilinear', True), + constructor=wrap_functional(F.interpolate, size=None, scale_factor=3., mode='trilinear', align_corners=True), input_size=(1, 2, 3, 4, 4), - desc='trilinear_scale_3d_align_corners', + fullname='interpolate_trilinear_scale_3d_align_corners', # See https://github.com/pytorch/pytorch/issues/5006 precision=3e-4, + pickle=False, ), dict( module_name='AdaptiveMaxPool1d', diff --git a/test/test_nn.py b/test/test_nn.py index 9d61732..0a5d070 100644 --- a/test/test_nn.py +++ b/test/test_nn.py @@ -6432,7 +6432,8 @@ class TestNN(NNTestCase): def test_upsamplingNearest1d(self): m = nn.Upsample(size=4, mode='nearest') in_t = torch.ones(1, 1, 2) - out_t = m(Variable(in_t)) + with warnings.catch_warnings(record=True) as w: + out_t = m(in_t) self.assertEqual(torch.ones(1, 1, 4), out_t.data) input = torch.randn(1, 1, 2, requires_grad=True) @@ -6447,7 +6448,8 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=scale_factor, **kwargs) in_t = torch.ones(1, 1, 2) out_size = int(math.floor(in_t.shape[-1] * scale_factor)) - out_t = m(in_t) + with warnings.catch_warnings(record=True) as w: + out_t = m(in_t) self.assertEqual(torch.ones(1, 1, out_size), out_t.data) input = torch.randn(1, 1, 2, requires_grad=True) @@ -6457,14 +6459,16 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=3, mode='linear', align_corners=False) in_t_9 = torch.zeros(1, 1, 9) in_t_9[:, :, :4].normal_() - out_t_9 = m(in_t_9) - out_t_5 = m(in_t_9[:, :, :5]) + with warnings.catch_warnings(record=True) as w: + out_t_9 = m(in_t_9) + out_t_5 = m(in_t_9[:, :, :5]) self.assertEqual(out_t_9[:, :, :15], out_t_5) def test_upsamplingNearest2d(self): m = nn.Upsample(size=4, mode='nearest') in_t = torch.ones(1, 1, 2, 2) - out_t = m(Variable(in_t)) + with warnings.catch_warnings(record=True) as w: + out_t = m(Variable(in_t)) self.assertEqual(torch.ones(1, 1, 4, 4), out_t.data) input = torch.randn(1, 1, 2, 2, requires_grad=True) @@ -6483,7 +6487,8 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=scale_factor, **kwargs) in_t = torch.ones(1, 1, 2, 2) out_size = int(math.floor(in_t.shape[-1] * scale_factor)) - out_t = m(in_t) + with warnings.catch_warnings(record=True) as w: + out_t = m(in_t) self.assertEqual(torch.ones(1, 1, out_size, out_size), out_t.data) input = torch.randn(1, 1, 2, 2, requires_grad=True) @@ -6518,14 +6523,16 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=3, mode='bilinear', align_corners=False) in_t_9 = torch.zeros(1, 1, 9, 9) in_t_9[:, :, :4, :4].normal_() - out_t_9 = m(in_t_9) - out_t_5 = m(in_t_9[:, :, :5, :5]) + with warnings.catch_warnings(record=True) as w: + out_t_9 = m(in_t_9) + out_t_5 = m(in_t_9[:, :, :5, :5]) self.assertEqual(out_t_9[:, :, :15, :15], out_t_5) def test_upsamplingNearest3d(self): m = nn.Upsample(size=4, mode='nearest') in_t = torch.ones(1, 1, 2, 2, 2) - out_t = m(Variable(in_t)) + with warnings.catch_warnings(record=True) as w: + out_t = m(Variable(in_t)) self.assertEqual(torch.ones(1, 1, 4, 4, 4), out_t.data) input = torch.randn(1, 1, 2, 2, 2, requires_grad=True) @@ -6540,7 +6547,8 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=scale_factor, **kwargs) in_t = torch.ones(1, 1, 2, 2, 2) out_size = int(math.floor(in_t.shape[-1] * scale_factor)) - out_t = m(in_t) + with warnings.catch_warnings(record=True) as w: + out_t = m(in_t) self.assertEqual(torch.ones(1, 1, out_size, out_size, out_size), out_t.data) input = torch.randn(1, 1, 2, 2, 2, requires_grad=True) @@ -6554,8 +6562,9 @@ class TestNN(NNTestCase): m = nn.Upsample(scale_factor=3, mode='trilinear', align_corners=False) in_t_9 = torch.zeros(1, 1, 9, 9, 9) in_t_9[:, :, :4, :4, :4].normal_() - out_t_9 = m(in_t_9) - out_t_5 = m(in_t_9[:, :, :5, :5, :5]) + with warnings.catch_warnings(record=True) as w: + out_t_9 = m(in_t_9) + out_t_5 = m(in_t_9[:, :, :5, :5, :5]) self.assertEqual(out_t_9[:, :, :15, :15, :15], out_t_5) def test_interpolate(self): @@ -6563,7 +6572,8 @@ class TestNN(NNTestCase): out_size = int(math.floor(in_t.shape[-1] * scale_factor)) dim = len(in_t.shape) - 2 out_shape = [1, 1] + [out_size] * dim - out_t = m(in_t) + with warnings.catch_warnings(record=True) as w: + out_t = m(in_t) self.assertEqual(torch.ones(out_shape), out_t) self.assertEqual(