cuVS Package

View as Markdown

Go package: cuvs

Sources: go

Constants

CuvsMemoryNew Constants

const (
CuvsMemoryNew = iota
CuvsMemoryRelease
)

Source: go/memory_resource.go:12

Supported Distance Metrics

const (
DistanceL2 Distance = iota
DistanceSQEuclidean
DistanceEuclidean
DistanceL1
DistanceCityblock
DistanceInnerProduct
DistanceChebyshev
DistanceCanberra
DistanceCosine
DistanceLp
DistanceCorrelation
DistanceJaccard
DistanceHellinger
DistanceBrayCurtis
DistanceJensenShannon
DistanceHamming
DistanceKLDivergence
DistanceMinkowski
DistanceRusselRao
DistanceDice
)

Supported distance metrics

Source: go/distance.go:14

Variables

CDistances

var CDistances = map[Distance]int{

Maps cuvs Go distances to C distances

Source: go/distance.go:38

DeviceDataPointer

var DeviceDataPointer unsafe.Pointer

Source: go/dlpack.go:219

NewDeviceDataPointer

var NewDeviceDataPointer unsafe.Pointer

Source: go/dlpack.go:274

Types

CuvsError

type CuvsError C.cuvsError_t

Source: go/exceptions.go:7

CuvsMemoryCommand

type CuvsMemoryCommand int

Source: go/memory_resource.go:10

CuvsPoolMemory

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

Source: go/memory_resource.go:17

Distance

type Distance int

Source: go/distance.go:11

Resource

type Resource struct {
Resource C.cuvsResources_t
}

Resources are objects that are shared between function calls, and includes things like CUDA streams, cuBLAS handles and other resources that are expensive to create.

Source: go/resources.go:11

Tensor

type Tensor[T any] struct {
C_tensor *C.DLManagedTensor
}

ManagedTensor is a wrapper around a dlpack DLManagedTensor object. This lets you pass matrices in device or host memory into cuvs.

Source: go/dlpack.go:21

TensorNumberType

type TensorNumberType interface {
int64 | uint32 | float32
}

Source: go/dlpack.go:15

Functions

CheckCuda

func CheckCuda(error C.cudaError_t) error

Wrapper function to convert cuda error to Go error

Source: go/exceptions.go:18

CheckCuvs

func CheckCuvs(error CuvsError) error

Wrapper function to convert cuvs error to Go error

Source: go/exceptions.go:10

Example

func Example() error

Source: go/memory_resource.go:81

NewCuvsPoolMemory

func NewCuvsPoolMemory(initial_pool_size_percent int, max_pool_size_percent int, managed bool) (*CuvsPoolMemory, error)

Creates new CuvsPoolMemory struct initial_pool_size_percent is the initial size of the pool in percent of total available device memory max_pool_size_percent is the maximum size of the pool in percent of total available device memory managed is whether to use CUDA managed memory

Source: go/memory_resource.go:29

NewResource

func NewResource(stream C.cudaStream_t) (Resource, error)

Returns a new Resource object

Source: go/resources.go:16

NewTensor

func NewTensor[T TensorNumberType](data [][]T) (Tensor[T], error)

Creates a new Tensor on the host and copies the data into it.

Source: go/dlpack.go:27

NewTensorOnDevice

func NewTensorOnDevice[T TensorNumberType](res *Resource, shape []int64) (Tensor[T], error)

Creates a new Tensor with uninitialized data on the current device.

Source: go/dlpack.go:131

NewVector

func NewVector[T TensorNumberType](data []T) (Tensor[T], error)

Source: go/dlpack.go:79

PairwiseDistance

func PairwiseDistance[T any](Resources Resource, x *Tensor[T], y *Tensor[T], distances *Tensor[float32], metric Distance, metric_arg float32) error

Computes the pairwise distance between two vectors.

Source: go/distance.go:62

Methods

CuvsPoolMemory.Close

func (m *CuvsPoolMemory) Close() error

Disables pool memory

Source: go/memory_resource.go:73

Resource.Close

func (r Resource) Close() error

Source: go/resources.go:50

Resource.GetCudaStream

func (r Resource) GetCudaStream() (C.cudaStream_t, error)

Gets the current cuda stream

Source: go/resources.go:39

Resource.Sync

func (r Resource) Sync() error

Syncs the current cuda stream

Source: go/resources.go:34

Tensor.Close

func (t *Tensor[T]) Close() error

Destroys Tensor, freeing the memory it was allocated on.

Source: go/dlpack.go:184

Tensor.Expand

func (t *Tensor[T]) Expand(res *Resource, newData [][]T) (*Tensor[T], error)

Expands the Tensor by adding newData to the end of the current data. The Tensor must be on the device.

Source: go/dlpack.go:250

Tensor.Shape

func (t *Tensor[T]) Shape() []int64

Returns the shape of the Tensor.

Source: go/dlpack.go:244

Tensor.Slice

func (t *Tensor[T]) Slice() ([][]T, error)

Returns a slice of the data in the Tensor. The Tensor must be on the host.

Source: go/dlpack.go:358

Tensor.ToDevice

func (t *Tensor[T]) ToDevice(res *Resource) (*Tensor[T], error)

Transfers the data in the Tensor to the device.

Source: go/dlpack.go:216

Tensor.ToHost

func (t *Tensor[T]) ToHost(res *Resource) (*Tensor[T], error)

Transfers the data in the Tensor to the host.

Source: go/dlpack.go:325