()
| 283 | |
| 284 | |
| 285 | def 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: |
no test coverage detected