From 4d232c7c95668ea267b8552e1cce167fa6280027 Mon Sep 17 00:00:00 2001 From: George Hotz Date: Mon, 20 Feb 2023 09:50:46 -0800 Subject: [PATCH] optional networkx + DEBUGCL=2 --- extra/thneed.py | 5 +++-- tinygrad/graph.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extra/thneed.py b/extra/thneed.py index dc674bbcee..f514087eb4 100644 --- a/extra/thneed.py +++ b/extra/thneed.py @@ -277,8 +277,9 @@ class Thneed: et = time.monotonic() - st print(f"submit in {(mt-st)*1000.0:.2f} ms, total runtime is {et*1000.0:.2f} ms") - #for i, ((prg, args), e) in enumerate(zip(self.cl_cache, events)): - # print(f"{i:3d} {prg.name:20s} " + "queued @ %5.2f ms, submit @ %5.2fms, start @ %5.2f ms, end @ %5.2f ms" % tuple((x*OSX_TIMING_RATIO - st*1e9)/1e6 for x in [e.profile.queued, e.profile.submit, e.profile.start, e.profile.end])) + if DEBUGCL >= 2: + for i, ((prg, args), e) in enumerate(zip(self.cl_cache, events)): + print(f"{i:3d} {prg.name:20s} " + "queued @ %5.2f ms, submit @ %5.2fms, start @ %5.2f ms, end @ %5.2f ms" % tuple((x*OSX_TIMING_RATIO - st*1e9)/1e6 for x in [e.profile.queued, e.profile.submit, e.profile.start, e.profile.end])) if DEBUGCL >= 1: total_runtime = 0 for i, ((prg, args), e) in enumerate(zip(self.cl_cache, events)): diff --git a/tinygrad/graph.py b/tinygrad/graph.py index 87c24aef6a..851473b306 100644 --- a/tinygrad/graph.py +++ b/tinygrad/graph.py @@ -1,7 +1,10 @@ import os import atexit import itertools -import networkx as nx # type: ignore +try: + import networkx as nx # type: ignore +except ImportError: + pass # graph won't work from collections import defaultdict from typing import Dict, List, Optional from tinygrad.ops import DeviceBuffer, DEBUG, UnaryOps, BinaryOps, ReduceOps, MovementOps, ProcessingOps, LoadOps, Op, OpType, LazyOp, get_buffers, get_lazyops