mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add warning for weights_only (#129239)
Also changes default for `weights_only` to `None` per comment below (hence the `suppress-bc-linter` tag) Pull Request resolved: https://github.com/pytorch/pytorch/pull/129239 Approved by: https://github.com/albanD ghstack dependencies: #129244, #129251
This commit is contained in:
committed by
PyTorch MergeBot
parent
c5f7755e86
commit
381ce0821c
@ -837,7 +837,6 @@ class TestBothSerialization(TestCase):
|
||||
test(f_new, f_old)
|
||||
self.assertTrue(len(w) == 0, msg=f"Expected no warnings but got {[str(x) for x in w]}")
|
||||
|
||||
|
||||
class TestOldSerialization(TestCase, SerializationMixin):
|
||||
# unique_key is necessary because on Python 2.7, if a warning passed to
|
||||
# the warning module is the same, it is not raised again.
|
||||
@ -865,7 +864,8 @@ class TestOldSerialization(TestCase, SerializationMixin):
|
||||
loaded = torch.load(checkpoint)
|
||||
self.assertTrue(isinstance(loaded, module.Net))
|
||||
if can_retrieve_source:
|
||||
self.assertEqual(len(w), 0)
|
||||
self.assertEqual(len(w), 1)
|
||||
self.assertEqual(w[0].category, FutureWarning)
|
||||
|
||||
# Replace the module with different source
|
||||
fname = get_file_path_2(os.path.dirname(os.path.dirname(torch.__file__)), 'torch', 'testing',
|
||||
@ -876,8 +876,8 @@ class TestOldSerialization(TestCase, SerializationMixin):
|
||||
loaded = torch.load(checkpoint)
|
||||
self.assertTrue(isinstance(loaded, module.Net))
|
||||
if can_retrieve_source:
|
||||
self.assertEqual(len(w), 1)
|
||||
self.assertTrue(w[0].category, 'SourceChangeWarning')
|
||||
self.assertEqual(len(w), 2)
|
||||
self.assertTrue(w[1].category, 'SourceChangeWarning')
|
||||
|
||||
def test_serialization_container(self):
|
||||
self._test_serialization_container('file', tempfile.NamedTemporaryFile)
|
||||
|
Reference in New Issue
Block a user