(self)
| 55 | self.assertIn("aten::add.out", operator_names) |
| 56 | |
| 57 | def test_load_program_with_path(self): |
| 58 | ep, inputs = create_program(ModuleAdd()) |
| 59 | runtime = Runtime.get() |
| 60 | |
| 61 | def test_add(program): |
| 62 | method = program.load_method("forward") |
| 63 | outputs = method.execute(inputs) |
| 64 | self.assertTrue(torch.allclose(outputs[0], inputs[0] + inputs[1])) |
| 65 | |
| 66 | with tempfile.NamedTemporaryFile() as f: |
| 67 | f.write(ep.buffer) |
| 68 | f.flush() |
| 69 | # filename |
| 70 | program = runtime.load_program(f.name) |
| 71 | test_add(program) |
| 72 | # pathlib.Path |
| 73 | path = Path(f.name) |
| 74 | program = runtime.load_program(path) |
| 75 | test_add(program) |
| 76 | # BytesIO |
| 77 | with open(f.name, "rb") as f: |
| 78 | program = runtime.load_program(f.read()) |
| 79 | test_add(program) |
| 80 | |
| 81 | def test_load_program_with_file_like_objects(self): |
| 82 | """Regression test: Ensure file-like objects (BytesIO, etc.) work correctly. |
nothing calls this directly
no test coverage detected