From cd7ceed91453fb136834e192560128026b6cc5cb Mon Sep 17 00:00:00 2001 From: George Hotz Date: Wed, 30 Aug 2023 10:59:42 -0700 Subject: [PATCH] gpt2: print total instead of sync time --- examples/gpt2.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/gpt2.py b/examples/gpt2.py index c3bd55db3b..71b244e676 100644 --- a/examples/gpt2.py +++ b/examples/gpt2.py @@ -179,11 +179,11 @@ class GPT2: GlobalCounters.reset() if args.timing: print("") st = GlobalCounters.time_sum_s - with Timing(f"ran model in ", on_exit=(lambda et: f", {(GlobalCounters.time_sum_s-st)*1e3:.2f} ms on GPU"+ - f", {GlobalCounters.global_ops*1e-9:.2f} GOPS, {GlobalCounters.global_mem*1e-9:.2f} GB"+ - f", {GlobalCounters.global_mem*1e-9/(GlobalCounters.time_sum_s-st):.2f} GB/s") if DEBUG else None, enabled=timing): - probs = self.model(Tensor([toks[start_pos:]]), start_pos, temperature) - with Timing("sync in ", enabled=timing): + with Timing("total ", enabled=timing): + with Timing(f"ran model in ", on_exit=(lambda et: f", {(GlobalCounters.time_sum_s-st)*1e3:.2f} ms on GPU"+ + f", {GlobalCounters.global_ops*1e-9:.2f} GOPS, {GlobalCounters.global_mem*1e-9:.2f} GB"+ + f", {GlobalCounters.global_mem*1e-9/(GlobalCounters.time_sum_s-st):.2f} GB/s") if DEBUG else None, enabled=timing): + probs = self.model(Tensor([toks[start_pos:]]), start_pos, temperature) probs_np = probs.numpy() tok = int(np.random.choice(len(probs_np), p=probs_np)) start_pos = len(toks)