Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-exec/fp8gemv.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-exec / fp8gemv.py` 214 lines · 7835 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Test only. FP8 format definition -> exact Fraction -> nearest-even binary32. 4 The table, fixtures and results are recorded by the gate; no host FP8 library is used. 5 """ 6 from fractions import Fraction 7 import itertools 8 import pathlib 9 import runpy 10 import struct 11 import subprocess 12 import sys 13 14 SG = runpy.run_path(str(pathlib.Path(__file__).with_name('sgemm.py'))) 15 SHAPES = tuple(itertools.product((1, 63, 64, 65), (0, 1, 3, 64, 65))) + ((0, 3),) 16 SCALES = (0x40000000, 0xbf000000, 0, 0x80000000, 1, 0x80000001, 0x7f7fffff) 17 18 19 def decode(byte): 20 # MI300 ISA PDF p58: bias8, unsigned zero, sole NaN0x80; exponent15 is finite. 21 if byte == 0x80: 22 return 0x7fc00000 # documented host canonical-NaN policy 23 exponent, fraction = (byte >> 3) & 15, byte & 7 24 value = Fraction(fraction if exponent == 0 else 8 + fraction, 8) 25 value *= Fraction(2) ** ((exponent if exponent else 1) - 8) 26 if byte & 128: 27 value = -value 28 return SG['round32'](value) 29 30 31 def fixture(m, k, special=False, all_bytes=False): 32 wp = 64 33 xp = (wp + m*k + 19) & ~3 34 sp = xp + 4*k + 16 35 yp = sp + 4*m + 16 36 data = bytearray([0xa5] * (yp + 4*m + 64)) 37 struct.pack_into('