Versions in this module Expand all Collapse all v0 v0.2.0 Mar 16, 2026 v0.1.0 Mar 16, 2026 Changes in this version + func Float16TestData() struct + func Float8TestData() struct + func Pack4BitSlice(values []uint8) ([]uint8, error) + func Pack4BitWeights(low4, high4 uint8) (uint8, error) + func TestArithmeticOp[T any](t *testing.T, opName string, op func(T, T) T, equal func(T, T) bool, ...) + func TestLeakyReLUOp[T any](t *testing.T, opName string, op func(T, float64) T, toFloat32 func(T) float32, ...) + func TestSumOp[T any](t *testing.T, op func([]T) T, toFloat32 func(T) float32, ...) + func TestUnaryOp[T any](t *testing.T, opName string, op func(T) T, equal func(T, T) bool, ...) + func Unpack4BitSlice(packed []uint8) []uint8 + func Unpack4BitWeights(packed uint8) (uint8, uint8) + type Arithmetic interface + Abs func(x T) T + Add func(a, b T) T + Div func(a, b T) T + Exp func(x T) T + FromFloat32 func(f float32) T + FromFloat64 func(f float64) T + GreaterThan func(a, b T) bool + IsZero func(v T) bool + LeakyReLU func(x T, alpha float64) T + LeakyReLUGrad func(x T, alpha float64) T + Log func(x T) T + Mul func(a, b T) T + One func() T + Pow func(base, exponent T) T + ReLU func(x T) T + ReLUGrad func(x T) T + Sigmoid func(x T) T + SigmoidGrad func(x T) T + Sqrt func(x T) T + Sub func(a, b T) T + Sum func(s []T) T + Tanh func(x T) T + TanhGrad func(x T) T + type ArithmeticTestCase struct + type BFloat16Ops struct + func (ops BFloat16Ops) Abs(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Add(a, b float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Div(a, b float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Exp(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) FromFloat32(f float32) float16.BFloat16 + func (ops BFloat16Ops) FromFloat64(f float64) float16.BFloat16 + func (ops BFloat16Ops) GreaterThan(a, b float16.BFloat16) bool + func (ops BFloat16Ops) IsZero(v float16.BFloat16) bool + func (ops BFloat16Ops) LeakyReLU(x float16.BFloat16, alpha float64) float16.BFloat16 + func (ops BFloat16Ops) LeakyReLUGrad(x float16.BFloat16, alpha float64) float16.BFloat16 + func (ops BFloat16Ops) Log(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Mul(a, b float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) One() float16.BFloat16 + func (ops BFloat16Ops) Pow(base, exponent float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) ReLU(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) ReLUGrad(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Sigmoid(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) SigmoidGrad(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Sqrt(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Sub(a, b float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Sum(s []float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) Tanh(x float16.BFloat16) float16.BFloat16 + func (ops BFloat16Ops) TanhGrad(x float16.BFloat16) float16.BFloat16 + type Float16Ops struct + func (ops Float16Ops) Abs(x float16.Float16) float16.Float16 + func (ops Float16Ops) Add(a, b float16.Float16) float16.Float16 + func (ops Float16Ops) Div(a, b float16.Float16) float16.Float16 + func (ops Float16Ops) Exp(x float16.Float16) float16.Float16 + func (ops Float16Ops) FromFloat32(f float32) float16.Float16 + func (ops Float16Ops) FromFloat64(f float64) float16.Float16 + func (ops Float16Ops) GreaterThan(a, b float16.Float16) bool + func (ops Float16Ops) IsZero(v float16.Float16) bool + func (ops Float16Ops) LeakyReLU(x float16.Float16, alpha float64) float16.Float16 + func (ops Float16Ops) LeakyReLUGrad(x float16.Float16, alpha float64) float16.Float16 + func (ops Float16Ops) Log(x float16.Float16) float16.Float16 + func (ops Float16Ops) Mul(a, b float16.Float16) float16.Float16 + func (ops Float16Ops) One() float16.Float16 + func (ops Float16Ops) Pow(base, exponent float16.Float16) float16.Float16 + func (ops Float16Ops) ReLU(x float16.Float16) float16.Float16 + func (ops Float16Ops) ReLUGrad(x float16.Float16) float16.Float16 + func (ops Float16Ops) Sigmoid(x float16.Float16) float16.Float16 + func (ops Float16Ops) SigmoidGrad(x float16.Float16) float16.Float16 + func (ops Float16Ops) Sqrt(x float16.Float16) float16.Float16 + func (ops Float16Ops) Sub(a, b float16.Float16) float16.Float16 + func (ops Float16Ops) Sum(s []float16.Float16) float16.Float16 + func (ops Float16Ops) Tanh(x float16.Float16) float16.Float16 + func (ops Float16Ops) TanhGrad(x float16.Float16) float16.Float16 + func (ops Float16Ops) ToFloat32(t float16.Float16) float32 + type Float32Ops struct + func (ops Float32Ops) Abs(x float32) float32 + func (ops Float32Ops) Add(a, b float32) float32 + func (ops Float32Ops) Div(a, b float32) float32 + func (ops Float32Ops) Exp(x float32) float32 + func (ops Float32Ops) FromFloat32(f float32) float32 + func (ops Float32Ops) FromFloat64(f float64) float32 + func (ops Float32Ops) GreaterThan(a, b float32) bool + func (ops Float32Ops) IsZero(v float32) bool + func (ops Float32Ops) LeakyReLU(x float32, alpha float64) float32 + func (ops Float32Ops) LeakyReLUGrad(x float32, alpha float64) float32 + func (ops Float32Ops) Log(x float32) float32 + func (ops Float32Ops) Mul(a, b float32) float32 + func (ops Float32Ops) One() float32 + func (ops Float32Ops) Pow(base, exponent float32) float32 + func (ops Float32Ops) ReLU(x float32) float32 + func (ops Float32Ops) ReLUGrad(x float32) float32 + func (ops Float32Ops) Sigmoid(x float32) float32 + func (ops Float32Ops) SigmoidGrad(x float32) float32 + func (ops Float32Ops) Sqrt(x float32) float32 + func (ops Float32Ops) Sub(a, b float32) float32 + func (ops Float32Ops) Sum(s []float32) float32 + func (ops Float32Ops) Tanh(x float32) float32 + func (ops Float32Ops) TanhGrad(x float32) float32 + func (ops Float32Ops) ToFloat32(t float32) float32 + type Float64Ops struct + func (ops Float64Ops) Abs(x float64) float64 + func (ops Float64Ops) Add(a, b float64) float64 + func (ops Float64Ops) Div(a, b float64) float64 + func (ops Float64Ops) Exp(x float64) float64 + func (ops Float64Ops) FromFloat32(f float32) float64 + func (ops Float64Ops) FromFloat64(f float64) float64 + func (ops Float64Ops) GreaterThan(a, b float64) bool + func (ops Float64Ops) IsZero(v float64) bool + func (ops Float64Ops) LeakyReLU(x, alpha float64) float64 + func (ops Float64Ops) LeakyReLUGrad(x, alpha float64) float64 + func (ops Float64Ops) Log(x float64) float64 + func (ops Float64Ops) Mul(a, b float64) float64 + func (ops Float64Ops) One() float64 + func (ops Float64Ops) Pow(base, exponent float64) float64 + func (ops Float64Ops) ReLU(x float64) float64 + func (ops Float64Ops) ReLUGrad(x float64) float64 + func (ops Float64Ops) Sigmoid(x float64) float64 + func (ops Float64Ops) SigmoidGrad(x float64) float64 + func (ops Float64Ops) Sqrt(x float64) float64 + func (ops Float64Ops) Sub(a, b float64) float64 + func (ops Float64Ops) Sum(s []float64) float64 + func (ops Float64Ops) Tanh(x float64) float64 + func (ops Float64Ops) TanhGrad(x float64) float64 + func (ops Float64Ops) ToFloat32(t float64) float32 + type Float8Ops struct + func (ops Float8Ops) Abs(x float8.Float8) float8.Float8 + func (ops Float8Ops) Add(a, b float8.Float8) float8.Float8 + func (ops Float8Ops) Div(a, b float8.Float8) float8.Float8 + func (ops Float8Ops) Exp(x float8.Float8) float8.Float8 + func (ops Float8Ops) FromFloat32(f float32) float8.Float8 + func (ops Float8Ops) FromFloat64(f float64) float8.Float8 + func (ops Float8Ops) GreaterThan(a, b float8.Float8) bool + func (ops Float8Ops) IsZero(v float8.Float8) bool + func (ops Float8Ops) LeakyReLU(x float8.Float8, alpha float64) float8.Float8 + func (ops Float8Ops) LeakyReLUGrad(x float8.Float8, alpha float64) float8.Float8 + func (ops Float8Ops) Log(x float8.Float8) float8.Float8 + func (ops Float8Ops) Mul(a, b float8.Float8) float8.Float8 + func (ops Float8Ops) One() float8.Float8 + func (ops Float8Ops) Pow(base, exponent float8.Float8) float8.Float8 + func (ops Float8Ops) ReLU(x float8.Float8) float8.Float8 + func (ops Float8Ops) ReLUGrad(x float8.Float8) float8.Float8 + func (ops Float8Ops) Sigmoid(x float8.Float8) float8.Float8 + func (ops Float8Ops) SigmoidGrad(x float8.Float8) float8.Float8 + func (ops Float8Ops) Sqrt(x float8.Float8) float8.Float8 + func (ops Float8Ops) Sub(a, b float8.Float8) float8.Float8 + func (ops Float8Ops) Sum(s []float8.Float8) float8.Float8 + func (ops Float8Ops) Tanh(x float8.Float8) float8.Float8 + func (ops Float8Ops) TanhGrad(x float8.Float8) float8.Float8 + func (ops Float8Ops) ToFloat32(t float8.Float8) float32 + type Int8Ops struct + func (ops Int8Ops) Abs(x int8) int8 + func (ops Int8Ops) Add(a, b int8) int8 + func (ops Int8Ops) Div(a, b int8) int8 + func (ops Int8Ops) Exp(x int8) int8 + func (ops Int8Ops) FromFloat32(f float32) int8 + func (ops Int8Ops) FromFloat64(f float64) int8 + func (ops Int8Ops) GreaterThan(a, b int8) bool + func (ops Int8Ops) IsZero(v int8) bool + func (ops Int8Ops) LeakyReLU(x int8, alpha float64) int8 + func (ops Int8Ops) LeakyReLUGrad(x int8, alpha float64) int8 + func (ops Int8Ops) Log(x int8) int8 + func (ops Int8Ops) Mul(a, b int8) int8 + func (ops Int8Ops) One() int8 + func (ops Int8Ops) Pow(base, exponent int8) int8 + func (ops Int8Ops) ReLU(x int8) int8 + func (ops Int8Ops) ReLUGrad(x int8) int8 + func (ops Int8Ops) Sigmoid(x int8) int8 + func (ops Int8Ops) SigmoidGrad(x int8) int8 + func (ops Int8Ops) Sqrt(x int8) int8 + func (ops Int8Ops) Sub(a, b int8) int8 + func (ops Int8Ops) Sum(s []int8) int8 + func (ops Int8Ops) Tanh(x int8) int8 + func (ops Int8Ops) TanhGrad(x int8) int8 + type IntOps struct + func (IntOps) Abs(x int) int + func (IntOps) Add(a, b int) int + func (IntOps) Div(a, b int) int + func (IntOps) Exp(x int) int + func (IntOps) FromFloat32(f float32) int + func (IntOps) FromFloat64(f float64) int + func (IntOps) GreaterThan(a, b int) bool + func (IntOps) IsZero(v int) bool + func (IntOps) LeakyReLU(x int, alpha float64) int + func (IntOps) LeakyReLUGrad(x int, alpha float64) int + func (IntOps) Log(x int) int + func (IntOps) Mul(a, b int) int + func (IntOps) One() int + func (IntOps) Pow(base, exponent int) int + func (IntOps) ReLU(x int) int + func (IntOps) ReLUGrad(x int) int + func (IntOps) Sigmoid(x int) int + func (IntOps) SigmoidGrad(x int) int + func (IntOps) Sqrt(x int) int + func (IntOps) Sub(a, b int) int + func (IntOps) Sum(s []int) int + func (IntOps) Tanh(x int) int + func (IntOps) TanhGrad(x int) int + func (IntOps) ToFloat32(t int) float32 + type LeakyReLUTestCase struct + type QuantizationConfig struct + Scale float32 + Symmetric bool + ZeroPoint int64 + func ComputeQuantizationParams(minVal, maxVal float32, symmetric bool) (*QuantizationConfig, error) + func NewQuantizationConfig(scale float32, zeroPoint int64, symmetric bool) (*QuantizationConfig, error) + func (qc *QuantizationConfig) Dequantize(quantized uint8) float32 + func (qc *QuantizationConfig) Dequantize4BitWeights(packed []uint8) []float32 + func (qc *QuantizationConfig) DequantizeSlice(quantized []uint8) []float32 + func (qc *QuantizationConfig) QuantizationError(original []float32) float64 + func (qc *QuantizationConfig) Quantize(value float32) uint8 + func (qc *QuantizationConfig) QuantizeSlice(values []float32) []uint8 + func (qc *QuantizationConfig) ValidateQuantizationRoundTrip(values []float32, tolerance float64) error + type SumTestCase struct + type Uint8Ops struct + func (ops Uint8Ops) Abs(x uint8) uint8 + func (ops Uint8Ops) Add(a, b uint8) uint8 + func (ops Uint8Ops) Div(a, b uint8) uint8 + func (ops Uint8Ops) Exp(x uint8) uint8 + func (ops Uint8Ops) FromFloat32(f float32) uint8 + func (ops Uint8Ops) FromFloat64(f float64) uint8 + func (ops Uint8Ops) GreaterThan(a, b uint8) bool + func (ops Uint8Ops) IsZero(v uint8) bool + func (ops Uint8Ops) LeakyReLU(x uint8, alpha float64) uint8 + func (ops Uint8Ops) LeakyReLUGrad(x uint8, alpha float64) uint8 + func (ops Uint8Ops) Log(x uint8) uint8 + func (ops Uint8Ops) Mul(a, b uint8) uint8 + func (ops Uint8Ops) One() uint8 + func (ops Uint8Ops) Pow(base, exponent uint8) uint8 + func (ops Uint8Ops) ReLU(x uint8) uint8 + func (ops Uint8Ops) ReLUGrad(x uint8) uint8 + func (ops Uint8Ops) Sigmoid(x uint8) uint8 + func (ops Uint8Ops) SigmoidGrad(x uint8) uint8 + func (ops Uint8Ops) Sqrt(x uint8) uint8 + func (ops Uint8Ops) Sub(a, b uint8) uint8 + func (ops Uint8Ops) Sum(s []uint8) uint8 + func (ops Uint8Ops) Tanh(x uint8) uint8 + func (ops Uint8Ops) TanhGrad(x uint8) uint8 + type UnaryTestCase struct