mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Context: https://github.com/pytorch/torchdynamo/issues/1588 This PR moves [TorchDynamo](https://github.com/pytorch/torchdynamo) and TorchInductor into PyTorch core. - `torchdynamo` becomes `torch._dynamo` - `torchinductor` becomes `torch._inductor` This PR was generated by running `copy_to_core.sh` in https://github.com/pytorch/torchdynamo/pull/1538 Pull Request resolved: https://github.com/pytorch/pytorch/pull/86461 Approved by: https://github.com/voznesenskym
14 lines
343 B
Python
14 lines
343 B
Python
from torch.utils.benchmark import Timer
|
|
|
|
|
|
def time_with_torch_timer(fn, args, kwargs=None, iters=100):
|
|
kwargs = kwargs or {}
|
|
env = {"args": args, "kwargs": kwargs, "fn": fn}
|
|
fn_call = "fn(*args, **kwargs)"
|
|
|
|
# Measure end-to-end time
|
|
timer = Timer(stmt=f"{fn_call}", globals=env)
|
|
tt = timer.timeit(iters)
|
|
|
|
return tt
|