MCPcopy
hub / github.com/tinygrad/tinygrad / get_runtime

Function get_runtime

tinygrad/engine/realize.py:109–114  ·  view source on GitHub ↗
(device:str, ast:UOp, cache=True)

Source from the content-addressed store, hash-verified

107
108runtime_cache: dict[tuple[bytes, str], Any] = {}
109def get_runtime(device:str, ast:UOp, cache=True):
110 assert ast.op is Ops.PROGRAM and isinstance(ast.arg, ProgramInfo), "get_runtime should only be called with a PROGRAM ast"
111 if (runtime:=runtime_cache.get(key:=(ast.key, device))) is None:
112 runtime = Device[device].runtime(ast.arg.function_name, ast.src[4].arg, *ast.arg.aux, runtimevars=ast.arg.runtimevars, prg=ast)
113 if cache: runtime_cache[key] = runtime
114 return runtime
115
116graph_cache:weakref.WeakKeyDictionary[UOp, Any] = weakref.WeakKeyDictionary()
117def get_graph_runtime(ast:UOp, input_uops:tuple[UOp, ...]|None=None):

Callers 12

__init__Method · 0.90
__init__Method · 0.90
setUpClassMethod · 0.90
_get_runnerFunction · 0.90
setUpClassMethod · 0.90
test_exec_update_fuzzMethod · 0.90
test_memory_barrierMethod · 0.90
setUpClassMethod · 0.90
exec_kernelFunction · 0.85
exec_validateFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 5

setUpClassMethod · 0.72
setUpClassMethod · 0.72
test_exec_update_fuzzMethod · 0.72
test_memory_barrierMethod · 0.72
setUpClassMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…