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

Function convert_weights

examples/models/codegen/convert_weight.py:65–74  ·  view source on GitHub ↗
(input_dir_or_checkpoint: str, output_file: str)

Source from the content-addressed store, hash-verified

63
64
65def convert_weights(input_dir_or_checkpoint: str, output_file: str) -> None:
66 pt_path = os.path.join(input_dir_or_checkpoint, "pytorch_model.bin")
67 print("Loading checkpoint from file...")
68 sd = torch.load(pt_path, map_location="cpu", weights_only=True)
69 print("Converting checkpoint...")
70 sd = codegen_hf_to_meta(sd)
71
72 print("Saving checkpoint...")
73 torch.save(sd, output_file)
74 print("Done.")
75
76
77def main():

Callers 1

mainFunction · 0.70

Calls 3

codegen_hf_to_metaFunction · 0.85
loadMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected