Documentation
¶
Overview ¶
Package types defines types used in the Go bindings.
Index ¶
- func AtomFromHost[T dtype.GoDataType](hostValue *values.HostArray) T
- type Array
- type ArrayBridge
- type Atom
- type Bridge
- type Bridger
- type DeviceArray
- func (bb *DeviceArray) Bridge() Bridge
- func (bb *DeviceArray) Bridger() Bridger
- func (array *DeviceArray[T]) Fetch() (*HostArray[T], error)
- func (array *DeviceArray[T]) FetchWithAlloc(alloc platform.Allocator) (*HostArray[T], error)
- func (bb *DeviceArray) GXValue() values.Value
- func (array *DeviceArray[T]) Shape() *shape.Shape
- func (array *DeviceArray[T]) String() string
- func (bb *DeviceArray) ToDevice(dev *api.Device) (ArrayBridge, error)
- type DeviceAtom
- func (bb *DeviceAtom) Bridge() Bridge
- func (bb *DeviceAtom) Bridger() Bridger
- func (atom *DeviceAtom[T]) Fetch() (*HostAtom[T], error)
- func (atom *DeviceAtom[T]) FetchValue() (val T, err error)
- func (atom *DeviceAtom[T]) FetchWithAlloc(alloc platform.Allocator) (*HostAtom[T], error)
- func (bb *DeviceAtom) GXValue() values.Value
- func (bb *DeviceAtom) Shape() *shape.Shape
- func (atom *DeviceAtom[T]) String() string
- func (bb *DeviceAtom) ToDevice(dev *api.Device) (ArrayBridge, error)
- type Factory
- type HostArray
- func ArrayBool(vals []bool, dims ...int) *HostArray[bool]
- func ArrayFloat32(vals []float32, dims ...int) *HostArray[float32]
- func ArrayFloat64(vals []float64, dims ...int) *HostArray[float64]
- func ArrayInt32(vals []int32, dims ...int) *HostArray[int32]
- func ArrayInt64(vals []int64, dims ...int) *HostArray[int64]
- func ArrayUint32(vals []uint32, dims ...int) *HostArray[uint32]
- func ArrayUint64(vals []uint64, dims ...int) *HostArray[uint64]
- func NewHostArray[T dtype.GoDataType](val *values.HostArray) *HostArray[T]
- func (bb *HostArray) Bridge() Bridge
- func (bb *HostArray) Bridger() Bridger
- func (array *HostArray[T]) CopyFlat() []T
- func (array *HostArray[T]) Fetch() (*HostArray[T], error)
- func (bb *HostArray) GXValue() values.Value
- func (array *HostArray[T]) Shape() *shape.Shape
- func (array *HostArray[T]) String() string
- func (bb *HostArray) ToDevice(dev *api.Device) (ArrayBridge, error)
- type HostAtom
- func Bool(val bool) *HostAtom[bool]
- func DefaultInt(val ir.Int) *HostAtom[ir.Int]
- func Float32(val float32) *HostAtom[float32]
- func Float64(val float64) *HostAtom[float64]
- func Int32(val int32) *HostAtom[int32]
- func Int64(val int64) *HostAtom[int64]
- func NewHostAtom[T dtype.GoDataType](val *values.HostArray) *HostAtom[T]
- func Uint32(val uint32) *HostAtom[uint32]
- func Uint64(val uint64) *HostAtom[uint64]
- func (bb *HostAtom) Bridge() Bridge
- func (bb *HostAtom) Bridger() Bridger
- func (atom *HostAtom[T]) Fetch() (*HostAtom[T], error)
- func (atom *HostAtom[T]) FetchValue() (val T, err error)
- func (bb *HostAtom) GXValue() values.Value
- func (atom *HostAtom[T]) SendTo(dev *api.Device) (*DeviceAtom[T], error)
- func (bb *HostAtom) Shape() *shape.Shape
- func (atom *HostAtom[T]) String() string
- func (bb *HostAtom) ToDevice(dev *api.Device) (ArrayBridge, error)
- func (atom *HostAtom[T]) Value() T
- type Slice
- type SliceBridge
- type StructBridge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomFromHost ¶
func AtomFromHost[T dtype.GoDataType](hostValue *values.HostArray) T
AtomFromHost returns an atom from a value stored on the host.
Types ¶
type Array ¶
type Array[T dtype.GoDataType] interface { Bridger Fetch() (*HostArray[T], error) Shape() *shape.Shape }
Array managed by GX.
type ArrayBridge ¶
type ArrayBridge interface { Bridge // Shape returns the shape of the array. Shape() *shape.Shape // ToDevice transfers the array to a device. ToDevice(*api.Device) (ArrayBridge, error) }
ArrayBridge is a bridge value representing an array (or an atomic value).
type Atom ¶
type Atom[T dtype.GoDataType] interface { Bridger // Fetch the value from the device to the host and returns a handle to the host value. Fetch() (*HostAtom[T], error) // FetchValue fetches the atom value from the device. FetchValue() (T, error) }
Atom managed by GX.
type Bridge ¶
type Bridge interface { values.Valuer // Bridger returns the Go object owning the GX value. Bridger() Bridger }
Bridge is implemented by all types used by the Go bindings. It provides the bridge between the Go instance and the GX value.
type Bridger ¶
type Bridger interface {
Bridge() Bridge
}
Bridger is able to return a Go-GX value bridge.
type DeviceArray ¶
type DeviceArray[T dtype.GoDataType] struct { // contains filtered or unexported fields }
DeviceArray is an array stored on a device.
func NewDeviceArray ¶
func NewDeviceArray[T dtype.GoDataType](val *values.DeviceArray) *DeviceArray[T]
NewDeviceArray returns a new Go array given a device value managed by GX.
func (*DeviceArray) Bridge ¶
func (bb *DeviceArray) Bridge() Bridge
Bridge between the Go value and the GX value.
func (*DeviceArray) Bridger ¶
func (bb *DeviceArray) Bridger() Bridger
Bridger returns the Go value of the object.
func (*DeviceArray[T]) Fetch ¶
func (array *DeviceArray[T]) Fetch() (*HostArray[T], error)
Fetch the value from the device.
func (*DeviceArray[T]) FetchWithAlloc ¶
func (array *DeviceArray[T]) FetchWithAlloc(alloc platform.Allocator) (*HostArray[T], error)
FetchWithAlloc the value from the device given a specific allocator.
func (*DeviceArray[T]) Shape ¶
func (array *DeviceArray[T]) Shape() *shape.Shape
Shape of the array.
func (*DeviceArray[T]) String ¶
func (array *DeviceArray[T]) String() string
type DeviceAtom ¶
type DeviceAtom[T dtype.GoDataType] struct { // contains filtered or unexported fields }
DeviceAtom is an array stored on a device.
func NewDeviceAtom ¶
func NewDeviceAtom[T dtype.GoDataType](val *values.DeviceArray) *DeviceAtom[T]
NewDeviceAtom returns a new Go array given a device value managed by GX.
func (*DeviceAtom) Bridge ¶
func (bb *DeviceAtom) Bridge() Bridge
Bridge between the Go value and the GX value.
func (*DeviceAtom) Bridger ¶
func (bb *DeviceAtom) Bridger() Bridger
Bridger returns the Go value of the object.
func (*DeviceAtom[T]) Fetch ¶
func (atom *DeviceAtom[T]) Fetch() (*HostAtom[T], error)
Fetch the value from the device.
func (*DeviceAtom[T]) FetchValue ¶
func (atom *DeviceAtom[T]) FetchValue() (val T, err error)
FetchValue returns the atom value from the device.
func (*DeviceAtom[T]) FetchWithAlloc ¶
func (atom *DeviceAtom[T]) FetchWithAlloc(alloc platform.Allocator) (*HostAtom[T], error)
FetchWithAlloc the value from the device given a specific allocator.
func (*DeviceAtom[T]) String ¶
func (atom *DeviceAtom[T]) String() string
type Factory ¶
Factory creates instances given a type. Numerical types (atoms or arrays) are not supported.
type HostArray ¶
type HostArray[T dtype.GoDataType] struct { // contains filtered or unexported fields }
HostArray is an array stored on a host.
func ArrayFloat32 ¶
ArrayFloat32 returns a new Go host array of float32.
func ArrayFloat64 ¶
ArrayFloat64 returns a new Go host array of float64.
func ArrayInt32 ¶
ArrayInt32 returns a new Go host array of int32.
func ArrayInt64 ¶
ArrayInt64 returns a new Go host array of int64.
func ArrayUint32 ¶
ArrayUint32 returns a new Go host array of uint32.
func ArrayUint64 ¶
ArrayUint64 returns a new Go host array of uint64.
func NewHostArray ¶
func NewHostArray[T dtype.GoDataType](val *values.HostArray) *HostArray[T]
NewHostArray returns a new Go array given a device value managed by GX.
func (*HostArray) Bridge ¶
func (bb *HostArray) Bridge() Bridge
Bridge between the Go value and the GX value.
func (*HostArray) Bridger ¶
func (bb *HostArray) Bridger() Bridger
Bridger returns the Go value of the object.
func (*HostArray[T]) CopyFlat ¶
func (array *HostArray[T]) CopyFlat() []T
CopyFlat makes a copy of the data and returns it as a flat representation of an array.
type HostAtom ¶
type HostAtom[T dtype.GoDataType] struct { // contains filtered or unexported fields }
HostAtom is an array stored on a host.
func DefaultInt ¶
DefaultInt returns a new Go host atom of int32.
func NewHostAtom ¶
func NewHostAtom[T dtype.GoDataType](val *values.HostArray) *HostAtom[T]
NewHostAtom returns a new Go array given a device value managed by GX.
func (*HostAtom) Bridge ¶
func (bb *HostAtom) Bridge() Bridge
Bridge between the Go value and the GX value.
func (*HostAtom) Bridger ¶
func (bb *HostAtom) Bridger() Bridger
Bridger returns the Go value of the object.
func (*HostAtom[T]) FetchValue ¶
FetchValue returns the atom value from the device.
func (*HostAtom[T]) SendTo ¶
func (atom *HostAtom[T]) SendTo(dev *api.Device) (*DeviceAtom[T], error)
SendTo sends the value to a device.
type Slice ¶
type Slice[T Bridger] struct { // contains filtered or unexported fields }
Slice of Go instances.
func NewEmptySlice ¶
NewEmptySlice creates an empty slice that will be allocated later.
type SliceBridge ¶
type SliceBridge struct {
// contains filtered or unexported fields
}
SliceBridge is the bridge between Go and GX values for a slice.
func (*SliceBridge) Allocate ¶
func (b *SliceBridge) Allocate(size int)
Allocate the slice to a given number of elements.
func (*SliceBridge) Bridger ¶
func (b *SliceBridge) Bridger() Bridger
Bridger returns the Go value of the slice.
func (*SliceBridge) DType ¶
func (b *SliceBridge) DType() ir.Type
DType returns the data type of the slice.
func (*SliceBridge) GXValue ¶
func (b *SliceBridge) GXValue() values.Value
GXValue returns the underlying GX value.
func (*SliceBridge) Get ¶
func (b *SliceBridge) Get(i int) Bridge
Get returns the value of the ith position.
type StructBridge ¶
type StructBridge interface { Bridge // StructValue returns the GX value of the structure. StructValue() *values.Struct // NewFromField returns a new instance of the type defined by the field of the structure. // An error is returned if the field does not belong to the structure. NewFromField(field *ir.Field) (Bridge, error) // SetField sets a field with a value. // An error is returns if the value cannot be casted to the field type. SetField(field *ir.Field, val Bridge) error }
StructBridge is a bridge for a structure.