types

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Unlicense Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDeviceCount

func GetDeviceCount() int32

func GetGlobalGPUUtilization

func GetGlobalGPUUtilization() (float32, error)

func IsGPUComputeError

func IsGPUComputeError(err error) bool

IsGPUComputeError checks if an error is GPUComputeError

func IsGPUError

func IsGPUError(err error) bool

IsGPUError checks if an error is any type of GPU error

func IsGPUInitializationError

func IsGPUInitializationError(err error) bool

IsGPUInitializationError checks if an error is GPUInitializationError

func IsGPUMemoryError

func IsGPUMemoryError(err error) bool

IsGPUMemoryError checks if an error is GPUMemoryError

func IsGPUNotAvailableError

func IsGPUNotAvailableError(err error) bool

IsGPUNotAvailableError checks if an error is GPUNotAvailableError

func IsGPUSyncError

func IsGPUSyncError(err error) bool

IsGPUSyncError checks if an error is GPUSyncError

func IsRetriableGPUError

func IsRetriableGPUError(err error) bool

IsRetriableGPUError determines if a GPU error is retriable

Types

type GPUBackend

type GPUBackend int
const (
	BackendCPU GPUBackend = iota
	BackendCUDA
	BackendMetal
	BackendOpenCL
	BackendTPU
)

func DetectGPUBackend

func DetectGPUBackend() GPUBackend

func (GPUBackend) String

func (b GPUBackend) String() string

type GPUComputeError

type GPUComputeError struct {
	Operation string
	DeviceID  int32
	Cause     error
}

GPUComputeError indicates failure during GPU computation

func (*GPUComputeError) Error

func (e *GPUComputeError) Error() string

func (*GPUComputeError) Unwrap

func (e *GPUComputeError) Unwrap() error

Unwrap returns the underlying cause

type GPUConfig

type GPUConfig struct {
	Backend            GPUBackend
	DeviceID           int32
	Dimension          int
	Enabled            bool
	CUDAHome           string
	FAISSHome          string
	MetalUnifiedMemory bool
	SyncBatchSize      int
	SyncInterval       time.Duration
	MaxMemory          int64
	VendorID           string // e.g., "nvidia", "amd", "intel", "apple"
	DriverVersion      string // GPU driver version
	OpenCLVersion      string // OpenCL platform version
}

func DefaultGPUConfig

func DefaultGPUConfig() GPUConfig

type GPUInfo

type GPUInfo struct {
	Name             string
	Backend          GPUBackend
	DeviceID         int32
	MemoryMB         int64
	ComputeMajor     int
	ComputeMinor     int
	Vendor           string // e.g., "NVIDIA", "AMD", "Intel", "Apple"
	VendorID         string // hex vendor ID (e.g., "0x10de" for NVIDIA)
	DriverVersion    string // driver version string
	OpenCLVersion    string // OpenCL device version
	Profile          string // OpenCL profile (FULL_PROFILE or EMBEDDED_PROFILE)
	MaxComputeUnits  int    // max parallel compute units
	MaxWorkGroupSize int64  // max work group size
	MaxWorkItemDims  []int  // max work item dimensions
}

type GPUInitializationError

type GPUInitializationError struct {
	DeviceID int32
	Backend  GPUBackend
	Cause    error
}

GPUInitializationError indicates failure during GPU initialization

func (*GPUInitializationError) Error

func (e *GPUInitializationError) Error() string

func (*GPUInitializationError) Unwrap

func (e *GPUInitializationError) Unwrap() error

Unwrap returns the underlying cause

type GPUMemoryError

type GPUMemoryError struct {
	Requested uint64
	Available uint64
	DeviceID  int32
}

GPUMemoryError indicates GPU memory allocation failure

func (*GPUMemoryError) Error

func (e *GPUMemoryError) Error() string

type GPUNotAvailableError

type GPUNotAvailableError struct {
	Reason string
}

GPUNotAvailableError indicates that GPU is not available on this system

func (*GPUNotAvailableError) Error

func (e *GPUNotAvailableError) Error() string

type GPUSyncError

type GPUSyncError struct {
	BatchSize int
	DeviceID  int32
	Cause     error
}

GPUSyncError indicates failure during GPU synchronization

func (*GPUSyncError) Error

func (e *GPUSyncError) Error() string

func (*GPUSyncError) Unwrap

func (e *GPUSyncError) Unwrap() error

Unwrap returns the underlying cause

type Index

type Index interface {
	Add(ids []int64, vectors []float32) error
	Search(vector []float32, k int) (ids []int64, distances []float32, err error)
	SearchBatch(vectors [][]float32, k int) (ids [][]int64, distances [][]float32, err error)
	SearchBatchDistances(query []float32, candidateIDs []uint32) ([]float32, error)

	// PQ methods
	AddPQ(ids []int64, codes []byte, m int) error
	SearchPQ(lookupTable []float32, m int, k int) (ids []int64, distances []float32, err error)
	TrainPQ(vectors []float32, m int, k int) error
	EncodePQ(vectors []float32) ([]byte, error)
	AssignToClusters(vectors []float32, centroids []float32) ([]uint32, error)

	// Typed search methods for different vector types
	SearchFloat16(vector []uint16, k int) (ids []int64, distances []float32, err error)
	SearchComplex64(vector []uint16, k int) (ids []int64, distances []float32, err error)
	SearchComplex128(vector []float32, k int) (ids []int64, distances []float32, err error)

	// Integer vector search types
	SearchInt8(vector []int8, k int) (ids []int64, distances []float32, err error)
	SearchUint8(vector []uint8, k int) (ids []int64, distances []float32, err error)
	SearchInt16(vector []int16, k int) (ids []int64, distances []float32, err error)
	SearchUint16(vector []uint16, k int) (ids []int64, distances []float32, err error)
	AddTurboQuant(ids []int64, tqData []byte, bitsPerAngle int) error
	SearchTurboQuant(vector []float32, k int, bitsPerAngle int) (ids []int64, distances []float32, err error)

	// Graph methods
	UpdateGraph(offsets []uint32, neighbors []uint32, weights []float32) error
	GraphExpand(seeds []uint32, depth int, alpha float32) (ids []uint32, scores []float32, err error)
	PruneNeighbors(candidateIds []uint32, candidateDists []float32, maxNeighbors int, allVectors []float32) ([]uint32, error)
	SearchGreedy(query []float32, entryPoint uint32, entryDist float32) (uint32, float32, error)

	// Spatial and Temporal Acceleration
	HaversineSearch(centerLat, centerLon float32, points []float32, earthRadius float32) ([]float32, error)
	NormBatch(vectors []float32, dims int) ([]float32, error)

	// Lifecycle and Metadata
	Close() error
	Sync() error
	Clear() error
	Reset() error
	Backend() GPUBackend
	DeviceID() int32
	GetDeviceInfo() (*GPUInfo, error)
	GetMemoryInfo() (total, free, used int64, err error)
	GetUtilization() (float32, error)
}

Jump to

Keyboard shortcuts

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