diff options
| author | TreXito <81475944+TreXito@users.noreply.github.com> | 2026-11-23 12:25:55 +0000 |
|---|---|---|
| committer | TreXito <81475944+TreXito@users.noreply.github.com> | 2026-11-23 12:25:55 +0000 |
| commit | c542d871c196eaa5ad32bf05733464ecbe800c00 (patch) | |
| tree | 35dd0b8736559c64fab8cd5979d118d62bef8102 /tests/test_f16misc_diff.py | |
| parent | ee2d373b54aca98eb15b2b9cd8402b62f4977438 (diff) | |
tools/f16misc_diff.py: generate the f16 output modifiers and clamp on v_frexp_exp_i16_f16
Main 7de2d446 and 2c3cc2a8 measured them on gfx1036 and the translator now
accepts them: an output multiplier changes nothing on an f16 result while
clamp still acts, and on v_frexp_exp_i16_f16 clamp and the multiplier are
both no-ops. The self-test still pinned three of them as refused, so the PR
failed its own test once merged onto main.
The model applies the measured rules, min3/max3, frexp_mant, frexp_exp and
ldexp get a multiplier in the random stage, frexp_exp gets clamp, and the
self-test and tests pin the measured words. A translator mutant that applies
the multiplier on clamp_f16 results is caught by the sweep (80 programs) and
the random stage (21).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_f16misc_diff.py')
| -rw-r--r-- | tests/test_f16misc_diff.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/test_f16misc_diff.py b/tests/test_f16misc_diff.py index 9d17d9cd4..c3c9d5c86 100644 --- a/tests/test_f16misc_diff.py +++ b/tests/test_f16misc_diff.py | |||
| @@ -166,6 +166,18 @@ class Reference(unittest.TestCase): | |||
| 166 | w, st = one("v_min3_f16 v8, v9, v10, v11 op_sel:[0,0,0,1]", v9=0x7E00, v10=0x7D00, v11=0xFE00) | 166 | w, st = one("v_min3_f16 v8, v9, v10, v11 op_sel:[0,0,0,1]", v9=0x7E00, v10=0x7D00, v11=0xFE00) |
| 167 | self.assertEqual((w & M16, st), (0x5A5A, [None, "nan"])) # every operand NaN: any NaN | 167 | self.assertEqual((w & M16, st), (0x5A5A, [None, "nan"])) # every operand NaN: any NaN |
| 168 | 168 | ||
| 169 | def test_output_modifiers(self): | ||
| 170 | # mul:2/mul:4/div:2 leave an f16 result as it is and clamp still acts; frexp_exp ignores both. The words | ||
| 171 | # main's translator gives, as measured on gfx1036 (docs/design.md). | ||
| 172 | for line, want in (("v_min3_f16 v8, v9, v10, v11 mul:2", 0xB800), | ||
| 173 | ("v_max3_f16 v8, v9, v10, v11 clamp div:2", 0x3C00), | ||
| 174 | ("v_frexp_mant_f16_e64 v8, v11 mul:4", 0x3900), | ||
| 175 | ("v_frexp_exp_i16_f16_e64 v8, v11 clamp mul:2", 0x0002), | ||
| 176 | ("v_ldexp_f16_e64 v8, v9, v12 div:2", 0x4600), | ||
| 177 | ("v_ldexp_f16_e64 v8, v11, v12 clamp mul:2", 0x3C00)): | ||
| 178 | w, st = one(line, v9=0x12343A00, v10=0x5678B800, v11=0x9ABC4100, v12=3) | ||
| 179 | self.assertEqual((w, st), (0x5A5A0000 | want, [None, None]), line) | ||
| 180 | |||
| 169 | def test_clamp(self): | 181 | def test_clamp(self): |
| 170 | for line, v9, want in (("v_frexp_mant_f16_e64 v8, v9 clamp", 0x7E00, 0x0000), | 182 | for line, v9, want in (("v_frexp_mant_f16_e64 v8, v9 clamp", 0x7E00, 0x0000), |
| 171 | ("v_frexp_mant_f16_e64 v8, v9 clamp", 0xC400, 0x0000), | 183 | ("v_frexp_mant_f16_e64 v8, v9 clamp", 0xC400, 0x0000), |
| @@ -203,7 +215,8 @@ class Reference(unittest.TestCase): | |||
| 203 | self.assertIn("f32 NaN", f.compare([0, 0, 0, 0], [["w32", "w32"], none, none, none], [0x7F800000, 0, 0, 0])) | 215 | self.assertIn("f32 NaN", f.compare([0, 0, 0, 0], [["w32", "w32"], none, none, none], [0x7F800000, 0, 0, 0])) |
| 204 | 216 | ||
| 205 | def test_harness_errors(self): | 217 | def test_harness_errors(self): |
| 206 | for line in ("v_add_f16 v8, v9, v10", "v_frexp_exp_i16_f16_e64 v8, v9 clamp", "v_ldexp_f16_e64 v8, v9, -v9"): | 218 | for line in ("v_add_f16 v8, v9, v10", "v_fmamk_f16 v8, v9, 0x3c00, v10 mul:2", |
| 219 | "v_frexp_mant_f16_e32 v8, v9 div:2", "v_ldexp_f16_e64 v8, v9, -v9"): | ||
| 207 | with self.assertRaises(f.HarnessError, msg=line): | 220 | with self.assertRaises(f.HarnessError, msg=line): |
| 208 | one(line, v9=0x3C00, v10=0x3C00) | 221 | one(line, v9=0x3C00, v10=0x3C00) |
| 209 | 222 | ||