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/openaccel-lab/blob/main/workloads/quant_int8/omega.om # openaccel-lab aien-dev/openaccel-lab 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 `openaccel-lab / workloads / quant_int8 / omega.om` 68 lines ยท 964 bytes Raw Blame History 1 note quant_int8: per row s = absmax / 127 (one f32 divide), q = clamp(round_half_even(x / s), -127, 127) 2 global kr ulong 1 3 global kc ulong 1 4 fn rnde y f64 to long 5 a = fabs y 6 f = long a 7 fr = sub a f64 f 8 if gt fr 0.5f64 9 f = add f 1 10 end 11 if eq fr 0.5f64 12 if eq rem f 2 1 13 f = add f 1 14 end 15 end 16 if lt y 0.0f64 17 f = neg f 18 end 19 ret f 20 end 21 fn qrow r ulong c ulong to void 22 b = mul r c 23 amax = 0.0f32 24 for j ulong c 25 amax = fmax amax fabs get fa add b j 26 end 27 sc = div amax 127.0f32 28 put fo r sc 29 for j ulong c 30 v = long 0 31 if gt sc 0.0f32 32 v = rnde f64 div get fa add b j sc 33 end 34 if gt v 127 35 v = 127 36 end 37 if lt v -127 38 v = -127 39 end 40 put qo add b j byte v 41 end 42 end 43 fn kern to void 44 r = get kr 0 45 c = get kc 0 46 for i ulong r 47 qrow i c 48 end 49 end 50 fn main to int 51 oal_begin 52 put kr 0 ulong oal_p 0 53 put kc 0 ulong oal_p 1 54 a = oal_fa 0 55 w = oal_warm 56 for i ulong add w oal_reps 57 t0 = monons 58 kern 59 t1 = monons 60 if ge i w 61 oal_tick sub t1 t0 62 end 63 end 64 oal_sqo 0 mul get kr 0 get kc 0 65 oal_so 1 get kr 0 66 oal_end 67 ret 0 68 end