test/q8_test.bend relies on unsafe/foreign
raw source on the hub · import bend-gpu-kernels@0.1.0.0/test/q8_test.bend as Q8_test
Run-time test of N.q8 (int8 quantization: v / s rounded half to even, clamped to -128..127, as a byte) against values computed by PyTorch: torch.clamp(torch.round(v / s), -128, 127).to(torch.int8), in float32. q8's rounding works on F32, which the proof checker does not evaluate, so it is pinned by this test instead of a law. Inputs are exact F32 bit patterns. Build and run from this folder: bend q8_test.bend -o q8_test && ./q8_test (prints each mismatch; exits 1 if any)
3 imports
import Base import ../bang.bend as B import ../nn.bend as N
Types
type Case source · line 10 · raw
Data
Case@v:U32 -> @s:U32 -> @want:U32 -> @why:String -> Case
Definitions
def cases source · line 13 · raw
List<&1, Case>
def check_eq source · line 43 · raw
@ok:Bool -> @+want:U32 -> @+got:U32 -> @why:String -> IO(Nat)
def check_got source · line 52 · raw
@+want:U32 -> @why:String -> @+got:U32 -> IO(Nat)
def report_exit source · line 71 · raw
@ok:Bool -> IO(Unit)
def report source · line 78 · raw
@r:Pair(Nat, Nat) -> IO(Unit)
Unsafe
unsafe check source · line 56 · raw
@c:Case -> IO(Nat)
unsafe run source · line 62 · raw
@xs:List<&1, Case> -> @+fails:Nat -> @+n:Nat -> IO(Pair(Nat, Nat))
unsafe main source · line 86 · raw
IO(Unit)