Bendtorch.RMSNorm: def of bendtorch@1.3.0.0 Import: import bendtorch@1.3.0.0/main.bend as Bendtorch Lines 1685-1687 of bendtorch@1.3.0.0/main.bend: https://jend.leeeet.dev/read.txt?path=bendtorch@1.3.0.0/main.bend&start_line=1685&end_line=1687 import Base import bend-ml-tensor-array@0.1.18.0/main.bend as TA # RMSNorm over rows of d numbers, with a learned gain (Llama's norm); saves its input def RMSNorm(+n: Nat, +d: Nat, +eps: F32) -> Layer, TA.Mat, TA.Mat, TA.Mat>: Layer{p => x => rms_fwd(n, d, eps, p, x), p => s => dy => g => rms_bwd(n, d, eps, p, s, dy, g), op => p => g => st => mat_step(1n, d, op, p, g, st), u => TA.Mat.zeros(1n, d), p => Mat.dump(1n, d, p), p => xs => off => Mat.restore(1n, d, p, xs, off), p => xs => off => Mat.store(1n, d, p, xs, off), u => U32.from_nat(d)} Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=F32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-array@0.1.19.0/main.bend&name=Mat https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-array@0.1.19.0/main.bend&name=Mat.zeros https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Layer https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Mat.dump https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Mat.restore https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=Mat.store https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=mat_step https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=rms_bwd https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=rms_fwd