| 637 | self.assertEqual(extra_files["extra.txt"], "moo") |
| 638 | |
| 639 | def test_version_error(self): |
| 640 | def f(x): |
| 641 | return x + x |
| 642 | |
| 643 | ep = export(f, (torch.randn(1, 3),)) |
| 644 | |
| 645 | with tempfile.NamedTemporaryFile() as f: |
| 646 | save(ep, f) |
| 647 | f.seek(0) |
| 648 | |
| 649 | # Modify the version |
| 650 | with zipfile.ZipFile(f, 'a') as zipf: |
| 651 | zipf.writestr('version', "-1") |
| 652 | |
| 653 | with self.assertRaisesRegex(RuntimeError, r"Serialized version -1 does not match our current"): |
| 654 | f.seek(0) |
| 655 | load(f) |
| 656 | |
| 657 | def test_save_constants(self): |
| 658 | class Foo(torch.nn.Module): |