Documentation
¶
Overview ¶
Package kernels implement Go kernels for GX.
Index ¶
- func Allocator() platform.Allocator
- type Array
- func NewArrayFromRaw(data []byte, sh *shape.Shape) (Array, error)
- func ToAlgebraicArray[T dtype.Float | dtype.IntegerType](values []T, dims []int) Array
- func ToBfloat16Array(values []dtype.Bfloat16T, dims []int) Array
- func ToBfloat16Atom(val dtype.Bfloat16T) Array
- func ToBoolArray(values []bool, dims []int) Array
- func ToBoolAtom(val bool) Array
- func ToFloatArray[T dtype.Float](values []T, dims []int) Array
- func ToFloatAtom[T dtype.Float](val T) Array
- func ToIntegerArray[T dtype.IntegerType](values []T, dims []int) Array
- func ToIntegerAtom[T dtype.IntegerType](val T) Array
- func Zero(sh *shape.Shape) (Array, error)
- type Binary
- type Buffer
- func (buf *Buffer) Acquire() []byte
- func (buf *Buffer) Free()
- func (buf *Buffer) KernelValue() Array
- func (buf *Buffer) Release()
- func (buf *Buffer) Shape() *shape.Shape
- func (buf *Buffer) ToDevice(dev platform.Device) (platform.DeviceHandle, error)
- func (buf *Buffer) ToHost(target platform.HostBuffer) error
- type Factory
- type Handle
- type MathFactory
- type NAry
- type Unary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Array ¶
type Array interface { // Factory returns the kernels available for the value. Factory() Factory // Shape returns the shape of the value. Shape() *shape.Shape // Buffer returns the data of the array as a generic []uint8 buffer. Buffer() []byte // ToAtom returns the atomic value contained in the array. // It returns an error if the value is not atomic, that is if the array // contains more than one value. ToAtom() (any, error) // ToFloatNumber returns the atomic value as a float. // It returns an error if the value is not atomic, that is if the array // contains more than one value. ToFloatNumber() (*big.Float, error) // String representation of the array. String() string // contains filtered or unexported methods }
Array is a value (tuple, atomic, or array) managed by the backend.
func NewArrayFromRaw ¶
NewArrayFromRaw returns a new array from raw data.
func ToAlgebraicArray ¶
ToAlgebraicArray converts values and a shape into a native multi-dimensional array owned by a backend.
func ToBfloat16Array ¶
ToBfloat16Array converts values and a shape into a native multi-dimensional array owned by a backend.
func ToBfloat16Atom ¶
ToBfloat16Atom converts a value into an atom owned by a backend.
func ToBoolArray ¶
ToBoolArray converts values and a shape into a native multi-dimensional array owned by a backend.
func ToBoolAtom ¶
ToBoolAtom converts a value into an atom owned by a backend.
func ToFloatArray ¶
ToFloatArray converts values and a shape into a native multi-dimensional array owned by a backend.
func ToFloatAtom ¶
ToFloatAtom converts a value into an atom owned by a backend.
func ToIntegerArray ¶
func ToIntegerArray[T dtype.IntegerType](values []T, dims []int) Array
ToIntegerArray converts values and a shape into a native multi-dimensional array owned by a backend.
func ToIntegerAtom ¶
func ToIntegerAtom[T dtype.IntegerType](val T) Array
ToIntegerAtom converts a value into an atom owned by a backend.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer managed by Go.
func ToBuffer ¶
func ToBuffer[T dtype.GoDataType](vals []T, sh *shape.Shape) *Buffer
ToBuffer converts Go values into a GX array.
func (*Buffer) Acquire ¶
Acquire locks the buffer and returns it. The buffer can be read or written by the caller. All other access is locked. Returns nil if the handle has been freed.
func (*Buffer) Free ¶
func (buf *Buffer) Free()
Free the memory occupied by the buffer. The handle is invalid after calling this function.
func (*Buffer) KernelValue ¶
KernelValue returns the underlying Go backend array storing the data for the buffer.
func (*Buffer) Release ¶
func (buf *Buffer) Release()
Release the buffer. The caller of that function should not read or write data from the buffer.
type Factory ¶
type Factory interface { Concat(dtype.DataType, int) (NAry, *shape.Shape, error) Cast(target dtype.DataType, dims []int) (Unary, *shape.Shape, Factory, error) Slice(*shape.Shape, int) (Unary, *shape.Shape, error) Reshape(*shape.Shape, []int) (Unary, *shape.Shape, error) BroadcastInDim(*shape.Shape, []int) (Unary, *shape.Shape, error) UnaryOp(token.Token, *shape.Shape) (Unary, *shape.Shape, error) BinaryOp(token.Token, *shape.Shape, *shape.Shape) (Binary, *shape.Shape, error) Math() MathFactory }
Factory creates kernels for arrays for all supported types.
type Handle ¶
type Handle interface {
KernelValue() Array
}
Handle is a value owned by the Go backend.
type MathFactory ¶
type MathFactory interface { // Kernelize turns a unary Go math function into a unary kernel. Kernelize(func(float64) float64) Unary }
MathFactory returns a factory to implement functions from the math package.