BendtorchGpu.adam_loop: def of bendtorch-gpu@1.3.0.0 Import: import bendtorch-gpu@1.3.0.0/main.bend as BendtorchGpu Lines 235-244 of bendtorch-gpu@1.3.0.0/main.bend: https://jend.leeeet.dev/read.txt?path=bendtorch-gpu@1.3.0.0/main.bend&start_line=235&end_line=244 import Base import bend-ml-tensor-gpu@0.1.5.0/main.bend as TG import bendtorch@1.3.0.0/main.bend as T def adam_loop(k: Nat, +i: U32, +l: U32, +lr: F32, +c1: F32, +b2: F32, +c2: F32, +eps: F32, +wd: F32, +dec: Bool, +step: F32, +bc2: F32, rw: Array & F32, rg: Array & F32, rm: Array & F32, rv: Array & F32) -> TG.O4: match k rw rg rm rv: case 0n Tuple{w, +x} Tuple{g, +y} Tuple{m, +a} Tuple{v, +b}: TG.O4{w, g, m, v} case 1n+q Tuple{w, +x} Tuple{g, +y} Tuple{m, +a} Tuple{v, +b}: +gg = T.adam_grad(dec, wd, x, y) +nm = T.adam_m(c1, a, gg) +nv = T.adam_v(b2, c2, b, gg) +nw = T.adam_w(step, bc2, eps, T.adam_decay(dec, lr, wd, x), nm, nv) +u = (i + l : U32) adam_loop(q, u, l, lr, c1, b2, c2, eps, wd, dec, step, bc2, Array.get(F32, Array.set(F32, w, i, nw), u), Array.get(F32, Array.set(F32, g, i, 0.0), u), Array.get(F32, Array.set(F32, m, i, nm), u), Array.get(F32, Array.set(F32, v, i, nv), u)) Uses (16): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.set https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool 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=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-gpu@0.1.5.1/main.bend&name=O4 https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_decay https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_grad https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_m https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_v https://jend.leeeet.dev/definition.txt?path=bendtorch@1.3.0.0/main.bend&name=adam_w