Yield kernel CALLs from a LINEAR UOp. Toposort descends naturally into CUSTOM_FUNCTION graph batches; gate stops at kernel ASTs.
(linear:UOp)
| 14 | |
| 15 | _KERNEL_ASTS = {Ops.SINK, Ops.PROGRAM} |
| 16 | def 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 | |
| 20 | def 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)} |
no test coverage detected
searching dependent graphs…