bench() — pytorch Function Reference
Architecture documentation for the bench() function in dynamo_guard_eval.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 9c23b932_759b_0edb_2bd4_7d00709b8aca["bench()"] 0bbb4b04_28a5_9cb6_a2bc_cd88b5f1ed81["main()"] 0bbb4b04_28a5_9cb6_a2bc_cd88b5f1ed81 -->|calls| 9c23b932_759b_0edb_2bd4_7d00709b8aca style 9c23b932_759b_0edb_2bd4_7d00709b8aca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/microbenchmarks/dynamo_guard_eval.py lines 24–38
def bench(name, fn):
torch._dynamo.reset()
inps = [[torch.randn(i) for _ in range(100)] for i in range(10, 101, 10)]
def run_fn():
for inp in inps:
fn(*inp)
start = time.perf_counter()
for _ in range(3):
run_fn()
end = time.perf_counter()
results = timeit.repeat(lambda: run_fn(), number=1000, repeat=10)
print(f"{name} {np.median(results) * 1000:.1f}us (warmup={end - start:.1f}s)")
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does bench() do?
bench() is a function in the pytorch codebase.
What calls bench()?
bench() is called by 1 function(s): main.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free