ggml

package
v0.0.0-...-e1ffba4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToF32

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

func QuantizationVersion() uint32

func Quantize

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

func Threads

func Threads(n int) int

Types

type Backend

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

func (*Backend) BackendDevices

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

func (*Backend) BackendMemory

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

func (*Backend) CacheConfig

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

func (*Backend) Close

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

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

func (*Backend) NewContext

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

func (*Backend) NewContextSize

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

type Context

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

func (Context) Arange

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

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

func (*Context) Empty

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

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

func (*Context) FromFloats

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

func (*Context) FromInts

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

func (*Context) Input

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

func (*Context) Layer

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

func (*Context) MaxGraphNodes

func (c *Context) MaxGraphNodes() int

func (*Context) Reserve

func (c *Context) Reserve()

func (*Context) SetBatchSize

func (c *Context) SetBatchSize(batchSize int)

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

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

func (*Tensor) Argsort

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

func (*Tensor) AvgPool2D

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

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

func (*Tensor) Clamp

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

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

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

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

func (*Tensor) Duplicate

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

func (*Tensor) Floats

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

func (*Tensor) FromBytes

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

func (*Tensor) FromFloats

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

func (*Tensor) FromInts

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

func (*Tensor) GELU

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

func (*Tensor) IM2Col

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

func (*Tensor) L2Norm

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

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

Mulmat performs matrix multiplication between two tensors. If t has shape [m, p, ...] and t2 has shape [m, n, ...], Mulmat returns a new Tensor with shape [p, n, ...].

Note: this is similar to matmul(t2, t.tranpose(-1, -2)) in other libraries.

func (*Tensor) MulmatFullPrec

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

func (*Tensor) MulmatID

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

func (*Tensor) Neg

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, order ...int) ml.Tensor

Permute permutes t according to order. Permute panics if the number of dimensions in order does not match the number of dimensions in t.

func (*Tensor) RELU

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

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

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

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

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

func (*Tensor) Sin

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

func (*Tensor) Softmax

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

func (*Tensor) Sqr

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

func (*Tensor) Sqrt

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

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

func (*Tensor) Stride

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

func (*Tensor) Sub

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

func (*Tensor) SumRows

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

func (*Tensor) Tanh

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

func (*Tensor) TopK

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

func (*Tensor) Variance

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