Chapter 15

layers/layernorm

github.com/openfluke/welvet/layers/layernorm


Why it exists

Classic mean+var normalization with γ/β — still required for many HF architectures.

What it is

WebGPU forward; backward host today. Same dtype×quant axes as other weighted layers.

Go example

examples/15-layernorm/main.go

Run:cd welvet/examples/15-layernorm && source ../env.sh && go run .
package main

import (
	"fmt"

	"github.com/openfluke/welvet/core"
	"github.com/openfluke/welvet/layers/layernorm"
)

func main() {
	l, err := layernorm.New(layernorm.Config{Dim: 8})
	if err != nil {
		panic(err)
	}
	x := core.NewTensor[float32](1, 8)
	_, y, err := layernorm.Forward(l, x)
	fmt.Println(len(y.Data), err)
}

Output

exit 0 · last run via go run .

8 <nil>