MCPcopy Create free account
hub / github.com/pytorch/pytorch / _test_serialization_data

Method _test_serialization_data

test/test_serialization.py:86–96  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

84
85class SerializationMixin:
86 def _test_serialization_data(self):
87 a = [torch.randn(5, 5).float() for i in range(2)]
88 b = [a[i % 2] for i in range(4)] # 0-3
89 b += [a[0].storage()] # 4
90 b += [a[0].reshape(-1)[1:4].storage()] # 5
91 b += [torch.arange(1, 11).int()] # 6
92 t1 = torch.FloatTensor().set_(a[0].reshape(-1)[1:4].clone().storage(), 0, (3,), (1,))
93 t2 = torch.FloatTensor().set_(a[0].reshape(-1)[1:4].clone().storage(), 0, (3,), (1,))
94 b += [(t1.storage(), t1.storage(), t2.storage())] # 7
95 b += [a[0].reshape(-1)[0:2].storage()] # 8
96 return b
97
98 def _test_serialization_assert(self, b, c):
99 self.assertEqual(b, c, atol=0, rtol=0)

Callers 4

_test_serializationMethod · 0.95

Calls 8

arangeMethod · 0.80
rangeFunction · 0.50
floatMethod · 0.45
randnMethod · 0.45
storageMethod · 0.45
reshapeMethod · 0.45
intMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected