MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / iter_kernel_calls

Function iter_kernel_calls

extra/export_model.py:16–18  ·  view source on GitHub ↗

Yield kernel CALLs from a LINEAR UOp. Toposort descends naturally into CUSTOM_FUNCTION graph batches; gate stops at kernel ASTs.

(linear:UOp)

Source from the content-addressed store, hash-verified

14
15_KERNEL_ASTS = {Ops.SINK, Ops.PROGRAM}
16def iter_kernel_calls(linear:UOp):
17 """Yield kernel CALLs from a LINEAR UOp. Toposort descends naturally into CUSTOM_FUNCTION graph batches; gate stops at kernel ASTs."""
18 return (u for u in linear.toposort(gate=lambda x: x.op not in _KERNEL_ASTS) if u.op is Ops.CALL and u.src[0].op in _KERNEL_ASTS)
19
20def compile_net(linear:UOp, output_bufs:List[Buffer]) -> Tuple[Dict[str,str], List, Dict[str,Tuple[int,DType,int]], Dict[str,Buffer]]:
21 output_name = {id(b): f"output{i}" for i, b in enumerate(output_bufs)}

Callers 1

compile_netFunction · 0.85

Calls 1

toposortMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…