MCPcopy Create free account
hub / github.com/tile-ai/tilelang / check_fastmath_usage

Function check_fastmath_usage

testing/python/math/test_math_fast_math.py:23–45  ·  view source on GitHub ↗

Check source for fastmath/non-fastmath versions

(source, mathop_name, expect_fastmath=False)

Source from the content-addressed store, hash-verified

21
22
23def check_fastmath_usage(source, mathop_name, expect_fastmath=False):
24 """Check source for fastmath/non-fastmath versions"""
25 fastmath_pattern = rf"__({mathop_name}f?)\b"
26 non_fastmath_pattern = rf"(?<!__)({mathop_name}f?)\b"
27
28 fastmath_matches = re.findall(fastmath_pattern, source)
29 non_fastmath_matches = re.findall(non_fastmath_pattern, source)
30
31 print(f"Found {len(fastmath_matches)} fastmath calls, {len(non_fastmath_matches)} non-fastmath calls")
32 if len(fastmath_matches) > 0:
33 print(f"Fastmath calls found: {fastmath_matches}")
34 if len(non_fastmath_matches) > 0:
35 print(f"Non-fastmath calls found: {non_fastmath_matches}")
36 print(f"Source preview for {mathop_name}:")
37 print(get_mathop_lines(source, mathop_name))
38
39 if expect_fastmath:
40 assert len(fastmath_matches) > 0, "Expected fastmath calls but found none"
41 print(f"✓ {mathop_name} correctly uses fastmath versions")
42 else:
43 assert len(fastmath_matches) == 0, f"Found unexpected fastmath calls: {fastmath_matches}"
44 assert len(non_fastmath_matches) > 0, f"No {mathop_name} calls found"
45 print(f"✓ {mathop_name} correctly uses non-fastmath versions")
46
47
48def check_non_fastmath_usage(source, mathop_name):

Callers 3

check_non_fastmath_usageFunction · 0.70
run_fastmath_mathop_testFunction · 0.70

Calls 2

printFunction · 0.85
get_mathop_linesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…