graph

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package graph implements a computational graph in GX.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

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

Graph of the Go native backend.

func New

func New(plat platform.Platform, funcName string) *Graph

New graph running operations implemented in Go.

func (*Graph) Argument

func (g *Graph) Argument(name string, sh *shape.Shape, index int) (ops.Node, error)

Argument returns a node set by a caller when calling the function.

func (*Graph) Binary

func (g *Graph) Binary(op *ast.BinaryExpr, x, y ops.Node) (ops.Node, error)

Binary returns a node applying a binary operator between two nodes.

func (*Graph) BroadcastInDim

func (g *Graph) BroadcastInDim(x ops.Node, shape *shape.Shape, broadcastAxes []int) (ops.Node, error)

BroadcastInDim broadcasts data across a given set of axis.

func (*Graph) Call

func (g *Graph) Call(sg *ops.Subgraph, args ...ops.Node) (ops.Node, error)

Call returns a node that invokes a subgraph.

func (*Graph) Cast

func (g *Graph) Cast(x ops.Node, dt dtype.DataType) (ops.Node, error)

Cast returns a cast/convert operator node.

func (*Graph) Compile

func (g *Graph) Compile(dev platform.Device, output, traced []*ops.OutputNode, params []*shape.Shape) (ops.Runner, error)

Compile the graph for a given device. The graph is not supposed to be modified once it has been compiled.

func (*Graph) Concat

func (g *Graph) Concat(axis int, nodes []ops.Node) (ops.Node, error)

Concat concatenates multiple arrays into a single array.

func (*Graph) Constant

func (g *Graph) Constant(value platform.HostBuffer) (ops.Node, error)

Constant returns a node representing a numerical constant value in the graph.

func (*Graph) Core

func (g *Graph) Core() ops.CoreBuilder

Core returns the builder to build core operations.

func (*Graph) Cos

func (g *Graph) Cos(x ops.Node) (ops.Node, error)

Cos returns a node computing the cosine.

func (*Graph) DotGeneral

func (g *Graph) DotGeneral(x, y ops.Node, batchAxes, reduceAxes [2][]int) (ops.Node, error)

DotGeneral returns a general dot operator node.

func (*Graph) Graph

func (g *Graph) Graph() ops.Graph

Graph returns the graph in which the nodes are created into.

func (*Graph) Iota

func (g *Graph) Iota(sh *shape.Shape, iotaAxis int) (ops.Node, error)

Iota returns a node filling an array with values from 0 to number of elements-1.

func (*Graph) Math

func (g *Graph) Math() ops.MathBuilder

Math returns the builder for the math package.

func (*Graph) Num

func (g *Graph) Num() ops.NumBuilder

Num returns the builder for the num package.

func (*Graph) Platform

func (g *Graph) Platform() platform.Platform

Platform owning the graph.

func (*Graph) Reshape

func (g *Graph) Reshape(x ops.Node, axisLengths []int) (ops.Node, error)

Reshape returns a reshape operator node.

func (*Graph) Set

func (g *Graph) Set(x, updates, index ops.Node) (ops.Node, error)

Set returns a node to set a slice in an array.

func (*Graph) Sin

func (g *Graph) Sin(x ops.Node) (ops.Node, error)

Sin returns a node computing the sine.

func (*Graph) Slice

func (g *Graph) Slice(x ops.Node, index int) (ops.Node, error)

Slice returns a slice on a node.

func (*Graph) Subgraph

func (g *Graph) Subgraph(name string, args []*shape.Shape) (ops.Graph, error)

Subgraph returns a Graph instance that maps to a new subgraph.

func (*Graph) Tanh

func (g *Graph) Tanh(x ops.Node) (ops.Node, error)

Tanh returns a node computing the hyperbolic tangent.

func (*Graph) Tuple

func (g *Graph) Tuple(nodes []ops.Node) (ops.Tuple, error)

Tuple returns a node grouping multiple nodes together.

func (*Graph) Unary

func (g *Graph) Unary(op *ast.UnaryExpr, x ops.Node) (ops.Node, error)

Unary returns a node applying a unary operator to a node.

func (*Graph) While

func (g *Graph) While(cond, body *ops.Subgraph, state ops.Node) (ops.Node, error)

While returns a while loop node.

Jump to

Keyboard shortcuts

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