MCPcopy
hub / github.com/tinygrad/tinygrad / type_verify

Function type_verify

tinygrad/uop/spec.py:31–40  ·  view source on GitHub ↗
(ast:UOp|list[UOp], check_spec:PatternMatcher)

Source from the content-addressed store, hash-verified

29 return validate_index_with_z3(sz, idx, gate)
30
31def type_verify(ast:UOp|list[UOp], check_spec:PatternMatcher):
32 lst = list(ast.toposort()) if isinstance(ast, UOp) else ast
33 if SPEC > 1: test_pyrender(lst[-1]) # assume this is the sink
34
35 with Context(TRACK_MATCH_STATS=0):
36 for i,u in enumerate(lst):
37 ret = check_spec.rewrite(u)
38 if cast(bool|None, ret) is not True:
39 if DEBUG >= 3: print_uops(lst)
40 raise RuntimeError(f"UOp verification failed at {i} on {u.op} {u.dtype} {len(u.src)} {[(x.op, x.dtype, x.arg) for x in u.src]} {u.arg}")
41
42# ***** new specs *****
43

Callers 4

full_rewrite_to_sinkFunction · 0.90
do_linearizeFunction · 0.90
lower_sink_to_linearFunction · 0.90

Calls 6

ContextClass · 0.90
print_uopsFunction · 0.90
test_pyrenderFunction · 0.85
castFunction · 0.85
toposortMethod · 0.80
rewriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…