mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-07 03:00:26 -04:00
cleanup process_replay/* namings [run_process_replay] (#6429)
This commit is contained in:
23
test/external/process_replay/diff_schedule.py
vendored
23
test/external/process_replay/diff_schedule.py
vendored
@@ -40,24 +40,27 @@ def diff_schedule(s:List[Tuple[DefaultDict[LBScheduleItem, List[LBScheduleItem]]
|
||||
seen_diffs.add(cache_key)
|
||||
changed += 1
|
||||
if CAPTURING_PROCESS_REPLAY: diskcache_put("schedule_diff", str(uuid.uuid4()), (str(buf), [ref.ast.key, compare.ast.key]))
|
||||
if not CI: print_si_diff(si[0], si[1])
|
||||
if not CI: print_si_diff(ref, compare)
|
||||
if DEBUG >= 1: print(f"*** process replay: {changed} unique kernel{'s' if changed>1 else ''} changed")
|
||||
return changed
|
||||
|
||||
def print_si_diff(si0:ScheduleItem, si1:ScheduleItem):
|
||||
def print_si_diff(ref:ScheduleItem, compare:ScheduleItem) -> None:
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
print_diff(si0.ast, si1.ast)
|
||||
print_diff(ref.ast, compare.ast)
|
||||
# skip lowering/runtime error
|
||||
with contextlib.suppress(Exception):
|
||||
ei0 = lower_schedule_item(si0)
|
||||
ei1 = lower_schedule_item(si1)
|
||||
assert isinstance(ei0.prg, CompiledRunner) and isinstance(ei1.prg, CompiledRunner)
|
||||
if DEBUG >= 4: print_diff(ei0.prg.p.src, ei1.prg.p.src)
|
||||
with contextlib.suppress(Exception): lower_si_diff(ref, compare)
|
||||
|
||||
def lower_si_diff(ref:ScheduleItem, compare:ScheduleItem) -> None:
|
||||
if DEBUG >= 4:
|
||||
ref_ei = lower_schedule_item(ref)
|
||||
compare_ei = lower_schedule_item(compare)
|
||||
assert isinstance(ref_ei.prg, CompiledRunner) and isinstance(compare_ei.prg, CompiledRunner)
|
||||
print_diff(ref_ei.prg.p.src, compare_ei.prg.p.src)
|
||||
# TODO: create new Buffers for process replay to test correctness
|
||||
if getenv("TIMING"):
|
||||
with Context(DEBUG=2):
|
||||
tm0 = ei0.run(wait=True)
|
||||
tm1 = ei1.run(wait=True)
|
||||
tm0 = ref_ei.run(wait=True)
|
||||
tm1 = compare_ei.run(wait=True)
|
||||
assert tm0 is not None and tm1 is not None
|
||||
tm_diff = ((tm0 - tm1) / tm0) * 100
|
||||
if tm_diff > 0: print(colored(f"{tm_diff:.2f}% faster", "green"))
|
||||
|
||||
Reference in New Issue
Block a user