gguf

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: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("unsupported")

Functions

This section is empty.

Types

type File

type File struct {
	Magic   [4]byte
	Version uint32
	// contains filtered or unexported fields
}

func Open

func Open(path string) (f *File, err error)

func (*File) Close

func (f *File) Close() error

func (*File) KeyValue

func (f *File) KeyValue(key string) KeyValue

func (*File) KeyValues

func (f *File) KeyValues() iter.Seq2[int, KeyValue]

func (*File) NumKeyValues

func (f *File) NumKeyValues() int

func (*File) NumTensors

func (f *File) NumTensors() int

func (*File) TensorInfo

func (f *File) TensorInfo(name string) TensorInfo

func (*File) TensorInfos

func (f *File) TensorInfos() iter.Seq2[int, TensorInfo]

func (*File) TensorReader

func (f *File) TensorReader(name string) (TensorInfo, io.Reader, error)

type KeyValue

type KeyValue struct {
	Key string
	Value
}

func (KeyValue) Valid

func (kv KeyValue) Valid() bool

type TensorInfo

type TensorInfo struct {
	Name   string
	Offset uint64
	Shape  []uint64
	Type   TensorType
}

func (TensorInfo) LogValue

func (ti TensorInfo) LogValue() slog.Value

func (TensorInfo) NumBytes

func (ti TensorInfo) NumBytes() int64

NumBytes returns the number of bytes in the tensor.

func (TensorInfo) NumValues

func (ti TensorInfo) NumValues() int64

func (TensorInfo) Valid

func (ti TensorInfo) Valid() bool

type TensorType

type TensorType uint32
const (
	TensorTypeF32 TensorType = iota
	TensorTypeF16
	TensorTypeQ4_0
	TensorTypeQ4_1

	TensorTypeQ5_0
	TensorTypeQ5_1
	TensorTypeQ8_0
	TensorTypeQ8_1
	TensorTypeQ2_K
	TensorTypeQ3_K
	TensorTypeQ4_K
	TensorTypeQ5_K
	TensorTypeQ6_K
	TensorTypeQ8_K

	TensorTypeI8
	TensorTypeI16
	TensorTypeI32
	TensorTypeI64
	TensorTypeF64

	TensorTypeBF16
)

func (TensorType) LogValue

func (tt TensorType) LogValue() slog.Value

func (TensorType) NumBytes

func (tt TensorType) NumBytes() float64

func (TensorType) String

func (tt TensorType) String() string

type Value

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

func (Value) Bool

func (v Value) Bool() bool

Bool returns Value as a boolean. If it is not a boolean, it returns false.

func (Value) Bools

func (v Value) Bools() (bools []bool)

Bools returns Value as a boolean slice. If it is not a boolean slice, it returns nil.

func (Value) Float

func (v Value) Float() float64

Float returns Value as a float. If it is not a float, it returns 0.

func (Value) Floats

func (v Value) Floats() (f64s []float64)

Floats returns Value as a float slice. If it is not a float slice, it returns nil.

func (Value) Int

func (v Value) Int() int64

Int returns Value as a signed integer. If it is not a signed integer, it returns 0.

func (Value) Ints

func (v Value) Ints() (i64s []int64)

Ints returns Value as a signed integer slice. If it is not a signed integer slice, it returns nil.

func (Value) String

func (v Value) String() string

String returns Value as a string. If it is not a string, it returns an empty string.

func (Value) Strings

func (v Value) Strings() (strings []string)

Strings returns Value as a string slice. If it is not a string slice, it returns nil.

func (Value) Uint

func (v Value) Uint() uint64

Uint converts an unsigned integer value to uint64. If the value is not a unsigned integer, it returns 0.

func (Value) Uints

func (v Value) Uints() (u64s []uint64)

Uints returns Value as a unsigned integer slice. If it is not a unsigned integer slice, it returns nil.

Jump to

Keyboard shortcuts

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