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

Function main

test/models/export_program_with_device_info.py:88–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86
87
88def main() -> None:
89 parser = argparse.ArgumentParser()
90 parser.add_argument("--outdir", type=str, required=True)
91 args = parser.parse_args()
92
93 torch.manual_seed(0)
94 model = ModuleAddWithDevice()
95 inputs = model.get_random_inputs()
96
97 edge = to_edge(
98 export(model, inputs),
99 compile_config=EdgeCompileConfig(_check_ir_validity=False),
100 )
101 lowered = edge.to_backend(_DeviceAwarePartitioner())
102 et_prog = lowered.to_executorch(
103 ExecutorchBackendConfig( # type: ignore[call-arg]
104 emit_stacktrace=False,
105 enable_non_cpu_memory_planning=True,
106 )
107 )
108
109 os.makedirs(args.outdir, exist_ok=True)
110 outfile = os.path.join(args.outdir, "ModuleAddWithDevice.pte")
111
112 with open(outfile, "wb") as fp:
113 fp.write(et_prog.buffer)
114 print(f"Exported ModuleAddWithDevice to {outfile}")
115
116
117if __name__ == "__main__":

Calls 10

get_random_inputsMethod · 0.95
to_edgeFunction · 0.90
exportFunction · 0.90
EdgeCompileConfigClass · 0.90
ModuleAddWithDeviceClass · 0.85
writeMethod · 0.80
to_backendMethod · 0.45
to_executorchMethod · 0.45

Tested by

no test coverage detected