MCPcopy
hub / github.com/tinygrad/tinygrad / exec_validate

Function exec_validate

tinygrad/engine/realize.py:182–191  ·  view source on GitHub ↗
(ctx:ExecContext, call:UOp, ast:UOp)

Source from the content-addressed store, hash-verified

180 return et
181
182def exec_validate(ctx:ExecContext, call:UOp, ast:UOp) -> float|None:
183 import numpy as np
184 for bufs, device_vars in unwrap_multi(call, resolve_params(call, ctx.input_uops)):
185 bufs, dev_bufs = bufs[:len(bufs)//2], bufs[len(bufs)//2:]
186 var_vals = {**ctx.var_vals, **device_vars}
187 cpu_rt = get_runtime("CPU", prg:=to_program(ast.src[0], Device["CPU"].renderer))
188 global_size, local_size = prg.arg.launch_dims(var_vals)
189 cpu_rt(*[bufs[i].ensure_allocated()._buf for i in prg.arg.globals], global_size=global_size, local_size=local_size, vals=prg.arg.vals(var_vals))
190 for i in prg.arg.outs: np.testing.assert_allclose(dev_bufs[i].ensure_allocated().numpy(), bufs[i].numpy(), rtol=1e-3, atol=1e-3)
191 return None
192
193def exec_encdec(ctx:ExecContext, call:UOp, ast:UOp) -> float|None:
194 bufs = [cast(Buffer, b.buffer).ensure_allocated() for b in resolve_params(call, ctx.input_uops)]

Callers

nothing calls this directly

Calls 8

to_programFunction · 0.90
unwrap_multiFunction · 0.85
resolve_paramsFunction · 0.85
get_runtimeFunction · 0.85
launch_dimsMethod · 0.80
ensure_allocatedMethod · 0.80
valsMethod · 0.80
numpyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…