ggml

package
v0.12.7-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 25 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToF32 added in v0.7.0

func ConvertToF32(data []byte, dtype uint32, nelements uint64) []float32

ConvertToF32 converts (dequantizes) the raw data to F32 so we can then quantize it

func New

func New(modelPath string, params ml.BackendParams) (ml.Backend, error)

func QuantizationVersion added in v0.7.0

func QuantizationVersion() uint32

func Quantize added in v0.7.0

func Quantize(newType fsggml.TensorType, f32s []float32, shape []uint64) []byte

func Threads added in v0.6.0

func Threads(n int) int

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

func (*Backend) BackendDevices added in v0.12.4

func (b *Backend) BackendDevices() []ml.DeviceInfo

func (*Backend) BackendMemory added in v0.7.1

func (b *Backend) BackendMemory() ml.BackendMemory

func (*Backend) CacheConfig added in v0.5.13

func (b *Backend) CacheConfig() ml.CacheConfig

func (*Backend) Close added in v0.11.5

func (b *Backend) Close()

func (*Backend) Config

func (b *Backend) Config() fs.Config

func (*Backend) Get

func (b *Backend) Get(name string) ml.Tensor

func (*Backend) Load added in v0.7.1

func (b *Backend) Load(ctx context.Context, progress func(float32)) error

func (*Backend) NewContext

func (b *Backend) NewContext() ml.Context

func (*Backend) NewContextSize added in v0.6.0

func (b *Backend) NewContextSize(n int) ml.Context

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (Context) Arange added in v0.6.6

func (c Context) Arange(start, stop, step float32, dtype ml.DType) ml.Tensor

func (*Context) Close

func (c *Context) Close()

func (*Context) Compute

func (c *Context) Compute(tensors ...ml.Tensor)

func (*Context) ComputeWithNotify added in v0.11.9

func (c *Context) ComputeWithNotify(cb func(), tensors ...ml.Tensor)

func (*Context) Empty added in v0.5.13

func (c *Context) Empty(dtype ml.DType, shape ...int) ml.Tensor

func (*Context) Forward

func (c *Context) Forward(tensors ...ml.Tensor) ml.Context

func (Context) FromBytes added in v0.11.1

func (c Context) FromBytes(dtype ml.DType, s []uint8, shape ...int) ml.Tensor

func (*Context) FromFloats added in v0.12.7

func (c *Context) FromFloats(s []float32, shape ...int) ml.Tensor

func (*Context) FromInts added in v0.12.7

func (c *Context) FromInts(s []int32, shape ...int) ml.Tensor

func (*Context) Input added in v0.6.0

func (c *Context) Input() ml.Context

func (*Context) Layer added in v0.6.0

func (c *Context) Layer(i int) ml.Context

func (*Context) MaxGraphNodes added in v0.6.0

func (c *Context) MaxGraphNodes() int

func (*Context) Reserve added in v0.6.6

func (c *Context) Reserve()

func (*Context) Zeros

func (c *Context) Zeros(dtype ml.DType, shape ...int) ml.Tensor

type Tensor

type Tensor struct {
	// contains filtered or unexported fields
}

func (*Tensor) Add

func (t *Tensor) Add(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) AddID added in v0.11.5

func (t *Tensor) AddID(ctx ml.Context, t2, ids ml.Tensor) ml.Tensor

func (*Tensor) Argsort added in v0.7.0

func (t *Tensor) Argsort(ctx ml.Context) ml.Tensor

func (*Tensor) AvgPool2D added in v0.6.0

func (t *Tensor) AvgPool2D(ctx ml.Context, k, s int, p float32) ml.Tensor

func (*Tensor) Bytes

func (t *Tensor) Bytes() (data []byte)

func (*Tensor) Cast added in v0.11.6

func (t *Tensor) Cast(ctx ml.Context, dtype ml.DType) ml.Tensor

func (*Tensor) Clamp added in v0.9.3

func (t *Tensor) Clamp(ctx ml.Context, min, max float32) ml.Tensor

func (*Tensor) Concat

func (t *Tensor) Concat(ctx ml.Context, t2 ml.Tensor, dim int) ml.Tensor

func (*Tensor) Contiguous

func (t *Tensor) Contiguous(ctx ml.Context, shape ...int) ml.Tensor

func (*Tensor) Conv2D

func (t *Tensor) Conv2D(ctx ml.Context, t2 ml.Tensor, s0, s1, p0, p1, d0, d1 int) ml.Tensor

func (*Tensor) Conv3D added in v0.12.7

func (t *Tensor) Conv3D(ctx ml.Context, t2 ml.Tensor, c, s0, s1, s2, p0, p1, p2, d0, d1, d2 int) ml.Tensor

func (*Tensor) Copy

func (t *Tensor) Copy(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) Cos added in v0.6.5

func (t *Tensor) Cos(ctx ml.Context) ml.Tensor

func (*Tensor) DType

func (t *Tensor) DType() ml.DType

func (*Tensor) Dim

func (t *Tensor) Dim(n int) int

func (*Tensor) Div added in v0.7.1

func (t *Tensor) Div(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) Duplicate added in v0.6.5

func (t *Tensor) Duplicate(ctx ml.Context) ml.Tensor

func (*Tensor) Floats

func (t *Tensor) Floats() (data []float32)

func (*Tensor) FromBytes added in v0.12.7

func (t *Tensor) FromBytes(s []byte)

func (*Tensor) FromFloats added in v0.12.7

func (t *Tensor) FromFloats(s []float32)

func (*Tensor) FromInts added in v0.12.7

func (t *Tensor) FromInts(s []int32)

func (*Tensor) GELU

func (t *Tensor) GELU(ctx ml.Context, t2 ...ml.Tensor) ml.Tensor

func (*Tensor) IM2Col added in v0.6.5

func (t *Tensor) IM2Col(ctx ml.Context, t2 ml.Tensor, s0, s1, p0, p1, d0, d1 int) ml.Tensor

func (*Tensor) L2Norm added in v0.12.0

func (t *Tensor) L2Norm(ctx ml.Context, eps float32) ml.Tensor

func (*Tensor) LayerNorm

func (t *Tensor) LayerNorm(ctx ml.Context, w, b ml.Tensor, eps float32) ml.Tensor

func (*Tensor) LogValue

func (t *Tensor) LogValue() slog.Value

func (*Tensor) Mean added in v0.9.3

func (t *Tensor) Mean(ctx ml.Context) ml.Tensor

func (*Tensor) Mul

func (t *Tensor) Mul(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) Mulmat

func (t *Tensor) Mulmat(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) MulmatFullPrec

func (t *Tensor) MulmatFullPrec(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) MulmatID added in v0.6.7

func (t *Tensor) MulmatID(ctx ml.Context, t2, ids ml.Tensor) ml.Tensor

func (*Tensor) Neg added in v0.6.5

func (t *Tensor) Neg(ctx ml.Context) ml.Tensor

func (*Tensor) Pad

func (t *Tensor) Pad(ctx ml.Context, shape ...int) ml.Tensor

func (*Tensor) Permute

func (t *Tensor) Permute(ctx ml.Context, shape ...int) ml.Tensor

func (*Tensor) RELU added in v0.9.3

func (t *Tensor) RELU(ctx ml.Context, t2 ...ml.Tensor) ml.Tensor

func (*Tensor) RMSNorm

func (t *Tensor) RMSNorm(ctx ml.Context, w ml.Tensor, eps float32) ml.Tensor

func (*Tensor) Repeat added in v0.6.5

func (t *Tensor) Repeat(ctx ml.Context, dim, n int) ml.Tensor

func (*Tensor) Reshape

func (t *Tensor) Reshape(ctx ml.Context, shape ...int) ml.Tensor

func (*Tensor) RoPE

func (t *Tensor) RoPE(ctx ml.Context, positions ml.Tensor, ropeDim int, ropeBase, ropeScale float32, options ...func(*rope.Options)) ml.Tensor

func (*Tensor) Rows

func (t *Tensor) Rows(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) SILU

func (t *Tensor) SILU(ctx ml.Context, t2 ...ml.Tensor) ml.Tensor

func (*Tensor) SILUAlphaLimit added in v0.12.0

func (t *Tensor) SILUAlphaLimit(ctx ml.Context, up ml.Tensor, alpha, limit float32) ml.Tensor

func (*Tensor) Scale

func (t *Tensor) Scale(ctx ml.Context, s float64) ml.Tensor

func (*Tensor) ScaledDotProductAttention

func (t *Tensor) ScaledDotProductAttention(ctx ml.Context, key, value, mask, sinks ml.Tensor, scale float64) ml.Tensor

func (*Tensor) Set added in v0.6.0

func (t *Tensor) Set(ctx ml.Context, t2 ml.Tensor, offset int, strides ...int) ml.Tensor

func (*Tensor) Shape

func (t *Tensor) Shape() []int

func (*Tensor) Sigmoid added in v0.6.7

func (t *Tensor) Sigmoid(ctx ml.Context) ml.Tensor

func (*Tensor) Sin added in v0.6.5

func (t *Tensor) Sin(ctx ml.Context) ml.Tensor

func (*Tensor) Softmax

func (t *Tensor) Softmax(ctx ml.Context) ml.Tensor

func (*Tensor) Sqr added in v0.9.3

func (t *Tensor) Sqr(ctx ml.Context) ml.Tensor

func (*Tensor) Sqrt added in v0.9.3

func (t *Tensor) Sqrt(ctx ml.Context) ml.Tensor

func (*Tensor) Stack

func (t *Tensor) Stack(ctx ml.Context, dim int, s ...ml.Tensor) ml.Tensor

func (*Tensor) Stddev added in v0.9.3

func (t *Tensor) Stddev(ctx ml.Context) ml.Tensor

func (*Tensor) Stride

func (t *Tensor) Stride(n int) int

func (*Tensor) Sub added in v0.9.3

func (t *Tensor) Sub(ctx ml.Context, t2 ml.Tensor) ml.Tensor

func (*Tensor) SumRows added in v0.7.1

func (t *Tensor) SumRows(ctx ml.Context) ml.Tensor

func (*Tensor) Tanh

func (t *Tensor) Tanh(ctx ml.Context) ml.Tensor

func (*Tensor) TopK added in v0.6.7

func (t *Tensor) TopK(ctx ml.Context, k int) ml.Tensor

func (*Tensor) Variance added in v0.9.3

func (t *Tensor) Variance(ctx ml.Context) ml.Tensor

func (*Tensor) View

func (t *Tensor) View(ctx ml.Context, offset int, shape ...int) ml.Tensor

Directories

Path Synopsis
ggml
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL