From 3635540ddb15f0096f07b1ac7c49eaf2ca9d3620 Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:34:17 -0800 Subject: [PATCH] shorter line (#2733) --- tinygrad/device.py | 7 ++++--- tinygrad/tensor.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tinygrad/device.py b/tinygrad/device.py index c4078b740e..2f93adfa9c 100644 --- a/tinygrad/device.py +++ b/tinygrad/device.py @@ -56,8 +56,9 @@ def update_stats(name:str, op_estimate:sint, mem_estimate:sint, var_vals: Option GlobalCounters.global_mem += mem_estimate if et is not None: GlobalCounters.time_sum_s += et if DEBUG >= 2: - print(f"{colored(f'*** {GlobalCounters.kernel_count:4d}', ('magenta' if num_kernels == 1 else 'CYAN') if jit else ('green' if first_run else None))} {name+' '*(37-ansilen(name))} arg {buf_count:3d} sz {str(lra.get('global_size', '') if lra else ''):18s} dev {device[:10]:10s} OPs {int(op_estimate/1e6):6d}M/{GlobalCounters.global_ops/1e9:7.2f}G mem {GlobalCounters.mem_used/1e9:5.2f} GB " + - (str() if et is None else f"tm {et*1e6:9.2f}us/{GlobalCounters.time_sum_s*1e3:9.2f}ms ({op_estimate/((et or 1e-20)*1e9):8.2f} GFLOPS, {mem_estimate/((et or 1e-20)*1e9):7.2f} GB/s)")) + ptm = (colored(f"{et*1e3:9.2f}ms", "RED") if et > 0.01 else f"{et*1e6:9.2f}us") if et is not None else "" + print(f"{colored(f'** {device[:7]:7} {GlobalCounters.kernel_count:4d}', ('magenta' if num_kernels == 1 else 'CYAN') if jit else ('green' if first_run else None))} {name+' '*(37-ansilen(name))} arg {buf_count:3d} mem {GlobalCounters.mem_used/1e9:5.2f} GB " + + (str() if et is None else f"tm {ptm}/{GlobalCounters.time_sum_s*1e3:9.2f}ms ({op_estimate/((et or 1e-20)*1e9):8.2f} GFLOPS, {mem_estimate/((et or 1e-20)*1e9):7.2f} GB/s)")) # **************** Buffer / Allocator **************** @@ -123,7 +124,7 @@ class _BufferCopy(JITRunner): if wait or DEBUG >= 2: Device[dest.device].synchronize() et = time.perf_counter() - st - update_stats(colored(f"copy {dest.device[:10]:10s} <- {src.device[:10]:10s}", "yellow"), 0, dest.size*dest.dtype.itemsize, {}, et, 2, jit, lra={"global_size": dest.size}, device=dest.device) + update_stats(colored(f"copy {dest.size:8d}, {dest.device[:7]:7} <- {src.device[:7]:7}", "yellow"), 0, dest.size*dest.dtype.itemsize, {}, et, 2, jit, lra={"global_size": dest.size}, device=dest.device) BufferCopy = _BufferCopy() # TODO: size, dest, src are the same type. can we enforce this? diff --git a/tinygrad/tensor.py b/tinygrad/tensor.py index 49cee2d692..a94a67e0a4 100644 --- a/tinygrad/tensor.py +++ b/tinygrad/tensor.py @@ -886,7 +886,7 @@ if IMAGE: # TODO: remove the custom op and replace with threefry def custom_random(out:Buffer): Tensor._seed += 1 - if DEBUG >= 2: print(f"*** rand {out.device} seed {Tensor._seed} size {out.size:<16d} dtype {out.dtype}") + if DEBUG >= 2: print(f"** {out.device} rand seed {Tensor._seed} size {out.size:<15d} dtype {out.dtype}") rng = np.random.default_rng(Tensor._seed) rng_np_buffer = rng.random(size=out.size, dtype=np.float32).astype(dtype=out.dtype.np, copy=False) out.copyin(rng_np_buffer.data)