Documentation
¶
Overview ¶
Package values implements all values that GX can represent.
Index ¶
- func ToAtom[T dtype.GoDataType](a *HostArray) (T, error)
- func ToElements(vals []Value) []ir.Element
- type Array
- type DeviceArray
- func (a *DeviceArray) DeviceHandle() platform.DeviceHandle
- func (a *DeviceArray) Handle() platform.Handle
- func (a *DeviceArray) Shape() *shape.Shape
- func (a *DeviceArray) String() string
- func (a *DeviceArray) ToDevice(dev platform.Device) (*DeviceArray, error)
- func (a *DeviceArray) ToHost(alloc platform.Allocator) (Value, error)
- func (a *DeviceArray) ToHostArray(alloc platform.Allocator) (*HostArray, error)
- func (a *DeviceArray) Type() ir.Type
- type FuncInputs
- type HostArray
- func ArrayBfloat16Value(typ ir.Type, vals []dtype.Bfloat16T, dims []int) (*HostArray, error)
- func ArrayBoolValue(typ ir.Type, vals []bool, dims []int) (*HostArray, error)
- func ArrayFloatValue[T dtype.Float](typ ir.Type, vals []T, dims []int) (*HostArray, error)
- func ArrayIntegerValue[T dtype.IntegerType](typ ir.Type, vals []T, dims []int) (*HostArray, error)
- func AtomBfloat16Value(typ ir.Type, val dtype.Bfloat16T) (*HostArray, error)
- func AtomBoolValue(typ ir.Type, val bool) (*HostArray, error)
- func AtomFloatValue[T dtype.Float](typ ir.Type, val T) (*HostArray, error)
- func AtomIntegerValue[T dtype.IntegerType](typ ir.Type, val T) (*HostArray, error)
- func AtomNumberInt(x *big.Int, typ ir.Type) (*HostArray, error)
- func NewHostArray(typ ir.Type, handle platform.HostBuffer) (*HostArray, error)
- func (a *HostArray) Buffer() platform.HostBuffer
- func (a *HostArray) Handle() platform.Handle
- func (a *HostArray) Shape() *shape.Shape
- func (a *HostArray) String() string
- func (a *HostArray) ToAtom() (any, error)
- func (a *HostArray) ToDevice(dev platform.Device) (*DeviceArray, error)
- func (a *HostArray) ToFloatNumber() (*big.Float, error)
- func (a *HostArray) ToHost(platform.Allocator) (Value, error)
- func (a *HostArray) ToHostArray(platform.Allocator) (*HostArray, error)
- func (a *HostArray) Type() ir.Type
- type IRNode
- type NamedType
- func (n *NamedType) NamedType() *ir.NamedType
- func (n *NamedType) Select(expr *ir.SelectorExpr) (ir.Element, error)
- func (n *NamedType) String() string
- func (n *NamedType) ToHost(alloc platform.Allocator) (Value, error)
- func (n *NamedType) Type() ir.Type
- func (n *NamedType) Under() ir.Element
- func (n *NamedType) Underlying() Value
- type Slice
- func (s *Slice) Allocate(size int)
- func (s *Slice) Element(i int) Value
- func (s *Slice) Elements() []ir.Element
- func (s *Slice) Len() int
- func (s *Slice) Set(i int, val Value)
- func (s *Slice) SliceType() *ir.SliceType
- func (s *Slice) String() string
- func (s *Slice) ToHost(alloc platform.Allocator) (Value, error)
- func (s *Slice) Type() ir.Type
- type String
- type Struct
- func (vs *Struct) FieldValue(name string) Value
- func (vs *Struct) Select(expr *ir.SelectorExpr) (ir.Element, error)
- func (vs *Struct) SetField(name string, val Value)
- func (vs *Struct) String() string
- func (vs *Struct) StructType() *ir.StructType
- func (vs *Struct) ToHost(alloc platform.Allocator) (Value, error)
- func (vs *Struct) Type() ir.Type
- type Value
- type Valuer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToAtom ¶
func ToAtom[T dtype.GoDataType](a *HostArray) (T, error)
ToAtom converts an array on the host into a Go atom value.
func ToElements ¶ added in v0.3.0
ToElements converts a slice of values into a slice of elements.
Types ¶
type Array ¶
type Array interface { Value // Handle to the data. Handle() platform.Handle // Type returns the GX type of the array. Type() ir.Type // Shape of the array. Shape() *shape.Shape // ToDevice transfers the array to a device. // It is a no-op if the data is already on the device. ToDevice(dev platform.Device) (*DeviceArray, error) // ToHostArray transfers the array on the host if it is not already. // Use the Go allocator. ToHostArray(alloc platform.Allocator) (*HostArray, error) }
Array is an array value (also includes atomic).
type DeviceArray ¶
type DeviceArray struct {
// contains filtered or unexported fields
}
DeviceArray managed by GX where the data is on a device.
func NewDeviceArray ¶
func NewDeviceArray(typ ir.Type, handle platform.DeviceHandle) (*DeviceArray, error)
NewDeviceArray returns a new array managed by GX.
func (*DeviceArray) DeviceHandle ¶
func (a *DeviceArray) DeviceHandle() platform.DeviceHandle
DeviceHandle returns the handle pointing to the data on the device.
func (*DeviceArray) String ¶
func (a *DeviceArray) String() string
String representation of the array.
func (*DeviceArray) ToDevice ¶
func (a *DeviceArray) ToDevice(dev platform.Device) (*DeviceArray, error)
ToDevice transfers the data to a device. It is a no-op if the data is already on the device.
func (*DeviceArray) ToHost ¶
func (a *DeviceArray) ToHost(alloc platform.Allocator) (Value, error)
ToHost transfers the value to the host.
func (*DeviceArray) ToHostArray ¶
func (a *DeviceArray) ToHostArray(alloc platform.Allocator) (*HostArray, error)
ToHostArray transfers the array to the host using the Go allocator.
type FuncInputs ¶ added in v0.3.0
type FuncInputs struct { // Receiver on which the function call was done. // Can be nil. Receiver ir.Element // Args returns list of arguments passed to the interpreter at call time. Args []ir.Element }
FuncInputs are GX values passed to the function call.
type HostArray ¶
type HostArray struct {
// contains filtered or unexported fields
}
HostArray managed by GX where the data is on a device.
func ArrayBfloat16Value ¶
ArrayBfloat16Value returns an array GX value given a Go value.
func ArrayBoolValue ¶
ArrayBoolValue returns an array GX value given a boolean value.
func ArrayFloatValue ¶
ArrayFloatValue returns an array GX value given a Go value.
func ArrayIntegerValue ¶
ArrayIntegerValue returns an array GX value given a Go value.
func AtomBfloat16Value ¶
AtomBfloat16Value returns an array GX value given a Go value.
func AtomBoolValue ¶
AtomBoolValue returns an array GX value given a boolean value.
func AtomFloatValue ¶
AtomFloatValue returns an array GX value given a Go value.
func AtomIntegerValue ¶
AtomIntegerValue returns an array GX value given a Go value.
func AtomNumberInt ¶
AtomNumberInt evaluates a big integer number into a GX array value.
func NewHostArray ¶
NewHostArray returns a new array managed by GX.
func (*HostArray) Buffer ¶
func (a *HostArray) Buffer() platform.HostBuffer
Buffer returns the buffer holding the array data.
func (*HostArray) ToAtom ¶
ToAtom returns the value as an atomic value. An error is returned if the array contains more than one value.
func (*HostArray) ToDevice ¶
func (a *HostArray) ToDevice(dev platform.Device) (*DeviceArray, error)
ToDevice transfers the data to a device. It is a no-op if the data is already on the device.
func (*HostArray) ToFloatNumber ¶
ToFloatNumber returns the value as a float number. An error is returned if the array contains more than one value.
func (*HostArray) ToHostArray ¶
ToHostArray returns the receiver.
type IRNode ¶
type IRNode struct {
// contains filtered or unexported fields
}
IRNode is a GX string value.
func (*IRNode) String ¶
IR representation of the value. The returned string is a string reported to the user.
type NamedType ¶
type NamedType struct {
// contains filtered or unexported fields
}
NamedType is the GX runtime value of a named type.
func NewNamedType ¶
NewNamedType returns a new named type from a GX runtime value and a named type.
func (*NamedType) String ¶
String representation of the value. The returned string is a string reported to the user.
func (*NamedType) Underlying ¶
Underlying returns the underlying value.
type Slice ¶
type Slice struct {
// contains filtered or unexported fields
}
Slice of GX values.
func NewSlice ¶
NewSlice returns a new slice of GX values. vals can be nil when the slice will be allocated and constructed later.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a GX string value.
func (*String) String ¶
String representation of the value. The returned string is a string reported to the user.
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
Struct stores the GX values of a structure.
func (*Struct) FieldValue ¶
FieldValue returns the value of the ith field.
func (*Struct) StructType ¶
func (vs *Struct) StructType() *ir.StructType
StructType returns the structure type of the structure.
type Value ¶
type Value interface { // Type returns the type of the value. Type() ir.Type // ToHost transfers the value to host given an allocator. ToHost(platform.Allocator) (Value, error) // String representation of the value. // The returned string is a string reported to the user. String() string // contains filtered or unexported methods }
Value is a GX value.