MCPcopy Create free account
hub / github.com/pytorch/executorch / test_load_program_with_path

Method test_load_program_with_path

runtime/test/test_runtime.py:57–79  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 6

create_programFunction · 0.90
ModuleAddClass · 0.90
writeMethod · 0.80
flushMethod · 0.80
load_programMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected