upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/cf_diff.py
diff options
context:
space:
mode:
authorfadi-abu-basem-25 <241361422+fadi-abu-basem-25@users.noreply.github.com>2026-11-24 00:04:40 +0200
committerfadi-abu-basem-25 <241361422+fadi-abu-basem-25@users.noreply.github.com>2026-11-24 00:04:40 +0200
commit6cdb668e8abe7c5ddae0e4d85dde16d35f92a3fc (patch)
tree46b122d9a8405608f07c25273017de172cc1fe76 /tools/cf_diff.py
parent5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff)
f32_fuzz, cf_diff: import the translator where it is used (EGEN-FUZZ-LAZY-IMPORT)
Both tools set sys.dont_write_bytecode and imported rdna2spirv at the top, so on a checkout without __pycache__ every start compiled the translator before parsing the arguments: about 20 s to print a usage line, which made test_no_arguments_prints_usage time out (5 s) in tests/test_f32_fuzz.py and tests/test_cf_diff.py. They now import it in the functions that use it. Also removes the second, identical CliTests class in tests/test_f32_fuzz.py, which replaced the first one at import. Supersedes #5056, which conflicts with main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/cf_diff.py')
-rw-r--r--tools/cf_diff.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/cf_diff.py b/tools/cf_diff.py
index 78f5f54b0..91f0097e4 100644
--- a/tools/cf_diff.py
+++ b/tools/cf_diff.py
@@ -55,7 +55,9 @@ if SEM_DIR not in sys.path:
55 55
56import cf_ref # noqa: E402 56import cf_ref # noqa: E402
57import cpu_ref # noqa: E402 57import cpu_ref # noqa: E402
58import rdna2spirv # noqa: E402 58# The translator is imported where it is used (run_case), not here: rdna2spirv.py takes seconds to compile, and
59# with dont_write_bytecode the compiled code is never cached, so --help and a usage error would wait for it on
60# every run.
59from spirv_wave_interp import UnsupportedConstruct, run_wave # noqa: E402 61from spirv_wave_interp import UnsupportedConstruct, run_wave # noqa: E402
60 62
61STUB_DXBC = b"DXBC" + bytes(24) + struct.pack("<I", 0) + bytes(4) 63STUB_DXBC = b"DXBC" + bytes(24) + struct.pack("<I", 0) + bytes(4)
@@ -434,6 +436,7 @@ def build(body, wave):
434 436
435def run_case(name, body, wave, structured=True): 437def run_case(name, body, wave, structured=True):
436 """Returns (status, detail): status in {"match", "mismatch", "skip"}.""" 438 """Returns (status, detail): status in {"match", "mismatch", "skip"}."""
439 import rdna2spirv # here, not at the top of the file: see the note above the imports
437 lines = build(body, wave) 440 lines = build(body, wave)
438 text = listing_text(lines, name) 441 text = listing_text(lines, name)
439 with tempfile.TemporaryDirectory(prefix="cf-diff-") as tmp: 442 with tempfile.TemporaryDirectory(prefix="cf-diff-") as tmp: