diff --git a/tinygrad/ops.py b/tinygrad/ops.py index f3a7b9e403..bba1884c1f 100644 --- a/tinygrad/ops.py +++ b/tinygrad/ops.py @@ -534,19 +534,19 @@ if TRACK_MATCH_STATS: import atexit, pickle @atexit.register def print_match_stats(): - ret = [0,0,0.0,0.0] - for k,v in sorted(list(match_stats.items()), key=lambda x: x[1][2]): - loc_str = f"{k.location[0].split('/')[-1]}:{k.location[1]}" - if v[1] != 0: print(f"{v[0]:6d} / {v[1]:7d} -- {v[3]*1000.:9.2f} / {v[2]*1000.:9.2f} ms -- {loc_str:15s}", k.printable()) - ret = [x+y for x,y in zip(ret, v)] - print(f"{ret[0]:6d} / {ret[1]:7d} -- {ret[3]*1000.:9.2f} / {ret[2]*1000.:9.2f} ms -- TOTAL") if TRACK_MATCH_STATS >= 2: with open("/tmp/rewrites.pkl", "wb") as f: print(f"rewrote {len(contexts)} graphs and applied {sum(len(x.rewrites) for x in contexts)} rules, saved to /tmp/rewrites.pkl") pickle.dump(contexts, f) if getenv("VIZ"): import viz.serve - viz.serve.main() + return viz.serve.main() + ret = [0,0,0.0,0.0] + for k,v in sorted(list(match_stats.items()), key=lambda x: x[1][2]): + loc_str = f"{k.location[0].split('/')[-1]}:{k.location[1]}" + if v[1] != 0: print(f"{v[0]:6d} / {v[1]:7d} -- {v[3]*1000.:9.2f} / {v[2]*1000.:9.2f} ms -- {loc_str:15s}", k.printable()) + ret = [x+y for x,y in zip(ret, v)] + print(f"{ret[0]:6d} / {ret[1]:7d} -- {ret[3]*1000.:9.2f} / {ret[2]*1000.:9.2f} ms -- TOTAL") # *** simple graph rewrite engine *** diff --git a/viz/index.html b/viz/index.html index 6d6f463d9f..ffc286b260 100644 --- a/viz/index.html +++ b/viz/index.html @@ -168,7 +168,7 @@