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

Function main

examples/arm/visualize.py:285–357  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

283
284
285def main() -> None:
286 parser = argparse.ArgumentParser(
287 description="Visualize a model using model explorer."
288 )
289 parser.add_argument(
290 "--model_dir", required=True, type=str, help="Path to the model directory"
291 )
292 parser.add_argument(
293 "--pte",
294 action="store_true",
295 help="Visualize PTE flatbuffer model and delegates. Cannot be used with --tosa",
296 )
297 parser.add_argument(
298 "--tosa",
299 action="store_true",
300 help="Visualize TOSA flatbuffer model. Cannot be used with --pte",
301 )
302 parser.add_argument(
303 "--trace",
304 required=False,
305 help="(perf mode) PMU trace JSON.gz file with performance data. Can only be used together with --tosa",
306 )
307 parser.add_argument(
308 "--tables",
309 required=False,
310 help="(perf mode) Vela debug database tables XML file",
311 )
312
313 args = parser.parse_args()
314 if args.pte and args.tosa:
315 raise ValueError("Cannot use both --pte and --tosa options together")
316
317 model_dir = Path(args.model_dir).resolve()
318
319 tosa_files = list(model_dir.glob("*TOSA*.tosa"))
320
321 model_files = None
322 if args.pte:
323 model_files = list(model_dir.glob("*.pte"))
324 elif args.tosa:
325 model_files = tosa_files
326
327 if not model_files:
328 raise FileNotFoundError(
329 f"No model files found in {model_dir} for the specified format."
330 )
331
332 model_file = model_files[0]
333
334 validate_file_exists(model_file)
335
336 config = model_explorer_config()
337
338 extensions = []
339
340 if args.pte:
341 set_pte_model_explorer_config(model_file, tosa_files, config)
342 elif args.tosa:

Callers 1

visualize.pyFile · 0.70

Calls 7

visualize_model_explorerFunction · 0.90
validate_file_existsFunction · 0.85
validate_perf_mode_argsFunction · 0.85
build_overlay_dataFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected