Home / Function/ main() — pytorch Function Reference

main() — pytorch Function Reference

Architecture documentation for the main() function in cachebench.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  e68c7f5d_5584_dd88_8af3_2bcda2115580["main()"]
  934ad498_2c6a_2ef7_e5d8_072d31076c44["parse_cmd_args()"]
  e68c7f5d_5584_dd88_8af3_2bcda2115580 -->|calls| 934ad498_2c6a_2ef7_e5d8_072d31076c44
  4c5d5750_9c4f_4bb3_15ed_612570273bef["_write_results_to_json()"]
  e68c7f5d_5584_dd88_8af3_2bcda2115580 -->|calls| 4c5d5750_9c4f_4bb3_15ed_612570273bef
  style e68c7f5d_5584_dd88_8af3_2bcda2115580 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/cachebench.py lines 234–249

def main() -> None:
    cmd_args = parse_cmd_args()

    dispatcher: dict[str, tuple[Dispatch_fn_t, list[str]]] = {
        "torchbench": (_run_torchbench_model, TORCHBENCH_MODELS),
        "huggingface": (_run_torchbench_model, HUGGINGFACE_MODELS),
    }
    fn, models = dispatcher[cmd_args.benchmark]
    if cmd_args.model is not None:
        models = [cmd_args.model]

    results: list[RunResult] = []
    for model in models:
        fn(cmd_args, results, model)

    _write_results_to_json(cmd_args, results)

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the pytorch codebase.
What does main() call?
main() calls 2 function(s): _write_results_to_json, parse_cmd_args.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free