mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Re-enable TestNamedTensor.test_big_tensor_repr (#29407)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/29407 Fixes https://github.com/pytorch/pytorch/issues/27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests Differential Revision: D18428657 Pulled By: zou3519 fbshipit-source-id: 6bcf247ffba010520878a175e766a496028f87d9
This commit is contained in:
parent
b3b8f522e8
commit
cedca377bd
|
|
@ -275,12 +275,11 @@ class TestNamedTensor(TestCase):
|
|||
with self.assertRaisesRegex(RuntimeError, "NYI"):
|
||||
ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(named_tensor)
|
||||
|
||||
@unittest.skip("Issue 27753")
|
||||
def test_big_tensor_repr(self):
|
||||
def test_big_tensor_repr_has_names(self):
|
||||
def check_repr(named_tensor):
|
||||
unnamed_tensor = named_tensor.rename(None)
|
||||
expected = "{}, names={})".format(repr(unnamed_tensor)[:-1], named_tensor.names)
|
||||
self.assertEqual(repr(named_tensor), expected)
|
||||
names_tag = 'names={}'.format(named_tensor.names)
|
||||
self.assertIn(names_tag, repr(named_tensor))
|
||||
|
||||
check_repr(torch.randn(128, 3, 64, 64, names=('N', 'C', 'H', 'W')))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user