Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseTracing ¶ added in v0.9.14
CloseTracing the tracing channel to avoid context leak. it is a nil op if context does not carry tracing information
func WithTracing ¶ added in v0.9.14
WithTracing initializes a tracing channel and adds it to the context
Example ¶
ctx, tracingC := WithTracing(context.Background()) defer CloseTracing(ctx) go func() { for t := range tracingC { fmt.Println(t) } }() g := gorgonia.NewGraph() // add operations etc... machine := NewMachine(g) defer machine.Close() machine.Run(ctx)
Output:
Types ¶
type Machine ¶ added in v0.9.13
type Machine struct {
// contains filtered or unexported fields
}
Machine is a top-level struture that will coordinate the execution of a graph
func NewMachine ¶ added in v0.9.13
NewMachine creates an exeuction machine from an exprgraph
func (*Machine) Close ¶ added in v0.9.13
func (m *Machine) Close()
Close all the plumbing to avoid leaking
func (*Machine) Run ¶ added in v0.9.13
Run the computation
Example ¶
g := gorgonia.NewGraph() forty := gorgonia.F32(40.0) //fortyTwo := gorgonia.F32(42.0) two := gorgonia.F32(2.0) n1 := gorgonia.NewScalar(g, gorgonia.Float32, gorgonia.WithValue(&forty), gorgonia.WithName("n1")) n2 := gorgonia.NewScalar(g, gorgonia.Float32, gorgonia.WithValue(&two), gorgonia.WithName("n2")) added, err := gorgonia.Add(n1, n2) if err != nil { log.Fatal(err) } machine := NewMachine(g) ctx, cancel := context.WithTimeout(context.Background(), 1000*time.Millisecond) defer cancel() defer machine.Close() err = machine.Run(ctx) if err != nil { log.Fatal(err) } fmt.Println(machine.GetResult(added.ID()))
Output: 42
Click to show internal directories.
Click to hide internal directories.