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/layernorm/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 / layernorm / omega.om` 55 lines ยท 1015 bytes Raw Blame History 1 note layernorm over rows of x[R][D] in f32: biased variance, eps = 1e-5, y = (x-mu) rsqrt(var+eps) gamma + beta 2 global kr ulong 1 3 global kd ulong 1 4 global kmu f32 1 5 fn lnstat o ulong d ulong inv f32 to f32 6 note returns rsqrt(var + eps) of the row at o; the row mean goes to kmu 7 s = 0.0f32 8 for k ulong d 9 s = add s get fa add o k 10 end 11 mu = mul s inv 12 put kmu 0 mu 13 q = 0.0f32 14 for k ulong d 15 c = sub get fa add o k mu 16 q = add q mul c c 17 end 18 ret div 1.0f32 fsqrt add mul q inv 0.`00001f32` 19 end 20 fn lnout o ulong d ulong mu f32 rs f32 to void 21 for k ulong d 22 c = sub get fa add o k mu 23 p = mul mul c rs get fb k 24 put fo add o k add p get fc k 25 end 26 end 27 fn kern to void 28 d = get kd 0 29 inv = div 1.0f32 f32 d 30 for i ulong get kr 0 31 o = mul i d 32 rs = lnstat o d inv 33 lnout o d get kmu 0 rs 34 end 35 end 36 fn main to int 37 oal_begin 38 put kr 0 ulong oal_p 0 39 put kd 0 ulong oal_p 1 40 a = oal_fa 0 41 b = oal_fb 1 42 c = oal_fc 2 43 w = oal_warm 44 for i ulong add w oal_reps 45 t0 = monons 46 kern 47 t1 = monons 48 if ge i w 49 oal_tick sub t1 t0 50 end 51 end 52 oal_so 0 a 53 oal_end 54 ret 0 55 end