Chapter 4
weights — FormatNone MatVec
github.com/openfluke/welvet/weights✅
Why it exists
Unquantized matrices still need a typed store that streams MatVec and SGD without forcing a float32 master or Morph-as-training.
What it is
Store holds DType + Format + Native/Packed bytes. New[T], MatVec, MatVecT, DecodeRow, SelectWire (F32/F64/I8), ApplySGD. FormatNone: update in native lanes (float32 payload is the only f32 buffer; float64 uses native ALU; other dtypes decode→update→re-encode). Packed: unpack→update→re-Pack then drop scratch. RetainsF32Master() is true only for FormatNone+float32. Dense and composite projs share this store.
Go example
Run:
cd welvet/examples/04-weights && source ../env.sh && go run .package main
import (
"fmt"
"github.com/openfluke/welvet/core"
"github.com/openfluke/welvet/quant"
"github.com/openfluke/welvet/weights"
)
func main() {
s, err := weights.New[float32](2, 2, []float32{1, 0, 0, 1}, core.DTypeFloat32, quant.FormatNone)
if err != nil {
panic(err)
}
y := make([]float32, 2)
if err := weights.MatVec(s, []float32{3, 4}, y); err != nil {
panic(err)
}
fmt.Println(y) // ≈ [3, 4]
}
Output
[3 4]