Home / Function/ read_batch_size_from_file() — pytorch Function Reference

read_batch_size_from_file() — pytorch Function Reference

Architecture documentation for the read_batch_size_from_file() function in common.py from the pytorch codebase.

Entity Profile

Dependency Diagram

graph TD
  e06b2878_0675_86a2_5846_47fa93c9dd10["read_batch_size_from_file()"]
  c9be2096_e6d7_2374_ad2e_a6e33f435ada["run()"]
  c9be2096_e6d7_2374_ad2e_a6e33f435ada -->|calls| e06b2878_0675_86a2_5846_47fa93c9dd10
  ce8fd365_4112_b289_9c73_7345d5e35203["RuntimeError()"]
  e06b2878_0675_86a2_5846_47fa93c9dd10 -->|calls| ce8fd365_4112_b289_9c73_7345d5e35203
  style e06b2878_0675_86a2_5846_47fa93c9dd10 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

benchmarks/dynamo/common.py lines 1615–1635

def read_batch_size_from_file(args, filename, model_name):
    batch_size = None
    if os.path.exists("benchmarks"):
        filename = os.path.join("benchmarks", filename)
    if not os.path.exists(filename):
        raise AssertionError(f"file not found: {filename}")
    with open(filename) as f:
        lines = f.readlines()
        lines = [i.split(",") for i in lines if len(i.strip()) > 0]
        for val in lines:
            cur_name, b = val
            if model_name == cur_name:
                batch_size = int(b)
    if batch_size is None:
        log.warning("Could not find batch size for %s", model_name)
    elif batch_size == -1:
        raise RuntimeError(
            f"Batch size is unset for {model_name} in {args.batch_size_file}"
        )
    print(f"batch size: {batch_size}")
    return batch_size

Subdomains

Called By

Frequently Asked Questions

What does read_batch_size_from_file() do?
read_batch_size_from_file() is a function in the pytorch codebase.
What does read_batch_size_from_file() call?
read_batch_size_from_file() calls 1 function(s): RuntimeError.
What calls read_batch_size_from_file()?
read_batch_size_from_file() is called by 1 function(s): run.

Analyze Your Own Codebase

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

Try Supermodel Free