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

Function main

examples/qualcomm/scripts/export_example.py:27–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26
27def main() -> None:
28 parser = argparse.ArgumentParser()
29 parser.add_argument(
30 "-m",
31 "--model_name",
32 required=True,
33 help=f"provide a model name. Valid ones: {list(MODEL_NAME_TO_MODEL.keys())}",
34 )
35 parser.add_argument(
36 "-g",
37 "--generate_etrecord",
38 action="store_true",
39 required=True,
40 help="Generate ETRecord metadata to link with runtime results (used for profiling)",
41 )
42
43 parser.add_argument(
44 "-f",
45 "--output_folder",
46 type=str,
47 default="",
48 help="The folder to store the exported program",
49 )
50
51 parser.add_argument(
52 "--soc",
53 type=str,
54 default="SM8650",
55 help="Specify the SoC model.",
56 )
57
58 parser.add_argument(
59 "-q",
60 "--quantization",
61 choices=["ptq", "qat"],
62 help="Run post-traininig quantization.",
63 )
64
65 args = parser.parse_args()
66
67 if args.model_name not in MODEL_NAME_TO_MODEL:
68 raise RuntimeError(
69 f"Model {args.model_name} is not a valid name. "
70 f"Available models are {list(MODEL_NAME_TO_MODEL.keys())}."
71 )
72
73 # Get model and example inputs
74 model, example_inputs, _, _ = EagerModelFactory.create_model(
75 *MODEL_NAME_TO_MODEL[args.model_name]
76 )
77
78 # Get quantizer
79 if args.quantization:
80 print("Quantizing model...")
81 # It is the model quantization path
82 quantizer = QnnQuantizer(
83 backend=QnnExecuTorchBackendType.kHtpBackend,
84 soc_model=get_soc_to_chipset_map()[args.soc],

Callers 1

export_example.pyFile · 0.70

Calls 13

QnnQuantizerClass · 0.90
get_soc_to_chipset_mapFunction · 0.90
save_pte_programFunction · 0.90
keysMethod · 0.80
moduleMethod · 0.80
create_modelMethod · 0.45
exportMethod · 0.45
to_executorchMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected