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

Method test_save_buffer

test/export/test_serialize.py:572–591  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

570@unittest.skipIf(not torchdynamo.is_dynamo_supported(), "dynamo doesn't support")
571class TestSaveLoad(TestCase):
572 def test_save_buffer(self):
573 inp = (torch.tensor([0.1, 0.1]),)
574 linear = torch.nn.Linear(2, 2)
575
576 class Module(torch.nn.Module):
577 def forward(self, x):
578 x = x + 1
579 y = x.t()
580 y = y.relu()
581 y = linear(y)
582 return y
583
584 ep = export(Module(), inp)
585
586 buffer = io.BytesIO()
587 save(ep, buffer)
588 buffer.seek(0)
589 loaded_ep = load(buffer)
590
591 self.assertTrue(torch.allclose(ep(*inp), loaded_ep(*inp)))
592
593 def test_save_file(self):
594

Callers

nothing calls this directly

Calls 6

exportFunction · 0.90
saveFunction · 0.90
loadFunction · 0.90
seekMethod · 0.80
ModuleClass · 0.70
tensorMethod · 0.45

Tested by

no test coverage detected