xvm

package
v0.9.11 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoMachine

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

GoMachine is a computation VM for Gorgonia. Every edge of the graph is associated with a channel of Value. The channels are identified by two IDs, tail and head, which are the IDs of the starting node and the ending node.

Every node with a non-nil Op launches a goroutine.

Each goroutine is expecting Values from all of its input channels (those with a tail matching the current node's ID). Then it calls the Do method of the operator, sets the own node's Value (thanks to the `Let` function), and sends the Value to the output channel (the channels with a head matching the current node'ID).

Every input *Node, sends its Value to the channel with a tail matching its node ID and head matching a constant negative value.

func NewGoMachine

func NewGoMachine(g *gorgonia.ExprGraph) *GoMachine

NewGoMachine creates a new VM able to run a program in a concurrent way. by now, only forward pass is supported

func (*GoMachine) Close

func (g *GoMachine) Close() error

Close all channels

func (*GoMachine) Reset

func (g *GoMachine) Reset()

Reset close all communication channels and created a new channel dictionary

func (*GoMachine) RunAll

func (g *GoMachine) RunAll() error

RunAll triggers all the goroutines and wait for the all the output channel to be filled with a value.

Caution: there is no safety mechanism, and this method would never return (deadlock) in some circumstances.

Jump to

Keyboard shortcuts

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