MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / _time_model

Function _time_model

kernelbench/bench_kb.py:456–473  ·  view source on GitHub ↗

Time a model using CUDA events.

(model, inputs_list, n_warm, n_iter)

Source from the content-addressed store, hash-verified

454 ]
455
456 def _time_model(model, inputs_list, n_warm, n_iter):
457 """Time a model using CUDA events."""
458 for _ in range(n_warm):
459 with torch.no_grad():
460 model(*inputs_list)
461 torch.cuda.synchronize()
462
463 times = []
464 for _ in range(n_iter):
465 start = torch.cuda.Event(enable_timing=True)
466 end = torch.cuda.Event(enable_timing=True)
467 start.record()
468 with torch.no_grad():
469 model(*inputs_list)
470 end.record()
471 torch.cuda.synchronize()
472 times.append(start.elapsed_time(end))
473 return times
474
475 try:
476 ref_times = _time_model(model_ref, inputs_dev, n_warmup, n_timed)

Callers 1

run_performanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected