cuVS Package

View as Markdown

Go package: cuvs

Sources: go

Constants

CuvsMemoryNew Constants

1const (
2CuvsMemoryNew = iota
3CuvsMemoryRelease
4)

Source: go/memory_resource.go:12

Supported Distance Metrics

1const (
2DistanceL2 Distance = iota
3DistanceSQEuclidean
4DistanceEuclidean
5DistanceL1
6DistanceCityblock
7DistanceInnerProduct
8DistanceChebyshev
9DistanceCanberra
10DistanceCosine
11DistanceLp
12DistanceCorrelation
13DistanceJaccard
14DistanceHellinger
15DistanceBrayCurtis
16DistanceJensenShannon
17DistanceHamming
18DistanceKLDivergence
19DistanceMinkowski
20DistanceRusselRao
21DistanceDice
22)

Supported distance metrics

Source: go/distance.go:14

Variables

CDistances

1var CDistances = map[Distance]int{

Maps cuvs Go distances to C distances

Source: go/distance.go:38

DeviceDataPointer

1var DeviceDataPointer unsafe.Pointer

Source: go/dlpack.go:219

NewDeviceDataPointer

1var NewDeviceDataPointer unsafe.Pointer

Source: go/dlpack.go:274

Types

CuvsError

1type CuvsError C.cuvsError_t

Source: go/exceptions.go:7

CuvsMemoryCommand

1type CuvsMemoryCommand int

Source: go/memory_resource.go:10

CuvsPoolMemory

1type CuvsPoolMemory struct { ... }

Source: go/memory_resource.go:17

Distance

1type Distance int

Source: go/distance.go:11

Resource

1type Resource struct { ... }

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

1type Tensor[T any] struct { ... }

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

1type TensorNumberType interface { ... }

Source: go/dlpack.go:15

Functions

CheckCuda

1func CheckCuda(error C.cudaError_t) error

Wrapper function to convert cuda error to Go error

Source: go/exceptions.go:18

CheckCuvs

1func CheckCuvs(error CuvsError) error

Wrapper function to convert cuvs error to Go error

Source: go/exceptions.go:10

Example

1func Example() error

Source: go/memory_resource.go:81

NewCuvsPoolMemory

1func 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

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

Returns a new Resource object

Source: go/resources.go:16

NewTensor

1func 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

1func 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

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

Source: go/dlpack.go:79

PairwiseDistance

1func 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

1func (m *CuvsPoolMemory) Close() error

Disables pool memory

Source: go/memory_resource.go:73

Resource.Close

1func (r Resource) Close() error

Source: go/resources.go:50

Resource.GetCudaStream

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

Gets the current cuda stream

Source: go/resources.go:39

Resource.Sync

1func (r Resource) Sync() error

Syncs the current cuda stream

Source: go/resources.go:34

Tensor.Close

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

Destroys Tensor, freeing the memory it was allocated on.

Source: go/dlpack.go:184

Tensor.Expand

1func (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

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

Returns the shape of the Tensor.

Source: go/dlpack.go:244

Tensor.Slice

1func (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

1func (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

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

Transfers the data in the Tensor to the host.

Source: go/dlpack.go:325