MCPcopy
hub / github.com/tinygrad/tinygrad / cpu_profile

Function cpu_profile

tinygrad/helpers.py:360–365  ·  view source on GitHub ↗
(name:str|TracingKey, device="TINY", display=True)

Source from the content-addressed store, hash-verified

358cpu_events:list[ProfileEvent] = []
359@contextlib.contextmanager
360def cpu_profile(name:str|TracingKey, device="TINY", display=True) -> Generator[ProfileRangeEvent, None, None]:
361 res = ProfileRangeEvent(device, name, perf_counter_us())
362 try: yield res
363 finally:
364 res.en = perf_counter_us()
365 if PROFILE and display: cpu_events.append(res)
366
367def profile_marker(name:str, color="gray") -> None:
368 cpu_events.append(ProfilePointEvent("TINY", "marker", None, {"name":name, "color":color}))

Callers 15

_apply_map_to_tensorsFunction · 0.90
_wrapperFunction · 0.90
validate_index_with_z3Function · 0.90
__wrapperFunction · 0.90
wrap_profile_matchesFunction · 0.90
_cp_mvMethod · 0.90
__call__Method · 0.90
_transferMethod · 0.90
_do_copyMethod · 0.90
_copyinMethod · 0.90
_copyoutMethod · 0.90
create_scheduleFunction · 0.90

Calls 3

ProfileRangeEventClass · 0.85
perf_counter_usFunction · 0.85
appendMethod · 0.80

Tested by 3

test_calltraceMethod · 0.72
test_layout_orderMethod · 0.72
test_cpu_profileMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…