MCPcopy
hub / github.com/tinygrad/tinygrad / test_link_sched_codegen

Method test_link_sched_codegen

test/null/test_viz.py:338–357  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

336
337 # schedule graph CALL nodes have a link to jump to codegen
338 def test_link_sched_codegen(self):
339 with save_viz() as viz:
340 c1 = Tensor.empty(4, device="NULL").add(1)
341 c2 = Tensor.empty(8, device="NULL").add(1)
342 with Context(SCACHE=0):
343 sched = c1.schedule_linear(c2)
344 from tinygrad.engine.realize import compile_linear
345 sched = compile_linear(sched)
346 with Context(NO_COLOR=0):
347 prgs = [to_program(si.src[0], Device[c1.device].renderer).arg.name for si in sched.src]
348 lst = viz.list_items()
349 sched_idx = next(i for i,l in enumerate(lst) if l["name"].startswith("Schedule"))
350 viz_kernel = next(i for i,s in enumerate(lst[sched_idx]["steps"]) if s["name"] == "View Kernel Graph")
351 with Context(NO_COLOR=1):
352 graph = next(viz.get_details(sched_idx, viz_kernel))["graph"]
353 call_nodes = [n for n in graph.values() if n["label"].startswith("CALL")]
354 for i,n in enumerate(call_nodes):
355 assert n["ref"] is not None
356 self.assertEqual(lst[n["ref"]]["name"], prgs[i])
357 assert ansistrip(prgs[i]) in n["label"], f"CALL must contain kernel name, got {n['label']}"
358
359 def test_link_sched_codegen_beam(self):
360 with Context(BEAM=2):

Callers 1

Calls 10

ContextClass · 0.90
compile_linearFunction · 0.90
to_programFunction · 0.90
ansistripFunction · 0.90
save_vizFunction · 0.85
schedule_linearMethod · 0.80
list_itemsMethod · 0.80
get_detailsMethod · 0.80
addMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected