platform

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package platform implements a GX platform for the native Go backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromValue

FromValue returns a handle on a value.

Types

type Device

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

Device is a device for the Go backend, that is a CPU.

func (*Device) Ordinal

func (dev *Device) Ordinal() int

Ordinal of the device on the platform.

func (*Device) Platform

func (dev *Device) Platform() platform.Platform

Platform owning the device.

func (*Device) Send

func (dev *Device) Send(buf []byte, sh *shape.Shape) (platform.DeviceHandle, error)

Send raw data to the device.

type Handle

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

Handle to a value stored by the backend.

func NewDeviceHandle

func NewDeviceHandle(dev *Device, array kernels.Array) *Handle

NewDeviceHandle returns a new device handle given an array and a device.

func ToDevice

func ToDevice(dev *Device, handle platform.Handle) (*Handle, error)

ToDevice sends a generic handle to a device.

func (*Handle) Array

func (h *Handle) Array() kernels.Array

Array returns the underlying array storing the data for the handle.

func (*Handle) Device

func (h *Handle) Device() platform.Device

Device on which the handle is located.

func (*Handle) Platform

func (h *Handle) Platform() platform.Platform

Platform owning the handle.

func (*Handle) Shape

func (h *Handle) Shape() *shape.Shape

Shape of the data stored by the handle.

func (*Handle) ToDevice

func (h *Handle) ToDevice(dev platform.Device) (platform.DeviceHandle, error)

ToDevice transfers the handle to a device.

func (*Handle) ToHost

func (h *Handle) ToHost(buf platform.HostBuffer) error

ToHost fetches the data from the handle and write it to buffer.

type Platform

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

Platform implements a native platform in Go.

func New

func New() *Platform

New returns a Go native platform.

func (*Platform) Device

func (plat *Platform) Device(ordinal int) (platform.Device, error)

Device returns the CPU device.

func (*Platform) GoDevice

func (plat *Platform) GoDevice(ordinal int) (*Device, error)

GoDevice returns a Go CPU device.

func (*Platform) Name

func (plat *Platform) Name() string

Name of the platform.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL