grapheval

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Package grapheval implements the evaluation of core GX functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncInputsToElements added in v0.3.0

func FuncInputsToElements(file *ir.File, processor *processor.Processor, fType *ir.FuncType, receiver ir.Element, args []ir.Element) (*elements.InputElements, error)

FuncInputsToElements converts values to a function input.

func GraphFromElement added in v0.3.0

func GraphFromElement(name string, el ir.Element) (*ops.Subgraph, error)

GraphFromElement returns a graph given an element.

Types

type BackendNode

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

BackendNode is a state element owning a node in the backend graph.

func NewBackendNode added in v0.3.0

func NewBackendNode(ev *Evaluator, expr elements.ExprAt, node *ops.OutputNode) (*BackendNode, error)

NewBackendNode returns an element representing a node in the backend graph.

func (*BackendNode) BinaryOp

BinaryOp applies a binary operator to x and y.

func (*BackendNode) Cast

Cast an element into a given data type.

func (*BackendNode) Copy

func (n *BackendNode) Copy() interp.Copier

Copy the node by returning itself.

func (*BackendNode) Materialise

Materialise returns itself.

func (*BackendNode) OutNode

func (n *BackendNode) OutNode() *ops.OutputNode

OutNode returns the graph node.

func (*BackendNode) Reshape

Reshape an element into a given shape.

func (*BackendNode) Shape

func (n *BackendNode) Shape() *shape.Shape

Shape returns the shape of the element.

func (*BackendNode) Slice

func (n *BackendNode) Slice(fitp *interp.FileScope, expr *ir.IndexExpr, index evaluator.NumericalElement) (ir.Element, error)

Slice of the value on the first axis given an index.

func (*BackendNode) SliceArray

SliceArray of the value on the first axis given an index.

func (*BackendNode) String

func (n *BackendNode) String() string

String representation of the backend node.

func (*BackendNode) Type added in v0.3.0

func (n *BackendNode) Type() ir.Type

Type of the element.

func (*BackendNode) UnaryOp

func (n *BackendNode) UnaryOp(ctx ir.Evaluator, expr *ir.UnaryExpr) (evaluator.NumericalElement, error)

UnaryOp applies a unary operator on x.

func (*BackendNode) Unflatten

func (n *BackendNode) Unflatten(handles *flatten.Parser) (values.Value, error)

Unflatten consumes the next handles to return a GX value.

type Evaluator

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

Evaluator evaluates GX operations by adding the corresponding node in the backend graph.

func New

func New(importer ir.Importer, pr *processor.Processor, gr ops.Graph) *Evaluator

New returns a new evaluator given a elements.

func (*Evaluator) ArrayOps

func (ev *Evaluator) ArrayOps() evaluator.ArrayOps

ArrayOps returns the array operators implementation.

func (*Evaluator) ElementFromAtom

func (ev *Evaluator) ElementFromAtom(ctx ir.Evaluator, src ir.AssignableExpr, val values.Array) (evaluator.NumericalElement, error)

ElementFromAtom returns an element from a GX value.

func (*Evaluator) ElementFromTuple added in v0.3.0

func (ev *Evaluator) ElementFromTuple(file *ir.File, expr ir.AssignableExpr, tpl ops.Tuple, shapes []*shape.Shape, targetType ir.Type) (ir.Element, error)

ElementFromTuple creates an interpreter element of a given type from a graph tuple.

func (*Evaluator) Importer

func (ev *Evaluator) Importer() ir.Importer

Importer returns the importer used by the evaluator.

func (*Evaluator) Materialiser added in v0.3.0

func (ev *Evaluator) Materialiser() materialise.Materialiser

Materialiser returns an array materialiser.

func (*Evaluator) NewArrayArgument

func (ev *Evaluator) NewArrayArgument(file *ir.File, parent parentArgument, typ ir.ArrayType, proxy ir.Element) (elements.ElementWithArrayFromContext, error)

NewArrayArgument creates a new argument element that the graph can also use as an argument.

func (*Evaluator) NewFunc

func (ev *Evaluator) NewFunc(itp *interp.Interpreter, fn ir.PkgFunc, recv *interp.Receiver) interp.Func

NewFunc creates a new function given its definition and a receiver.

func (*Evaluator) NewFuncLit added in v0.3.0

func (ev *Evaluator) NewFuncLit(fitp *interp.FileScope, lit *ir.FuncLit) (interp.Func, error)

NewFuncLit creates a new function literal.

func (*Evaluator) Processor

func (ev *Evaluator) Processor() *processor.Processor

Processor returns the processor where init and debug traces are registered.

func (*Evaluator) Trace

func (ev *Evaluator) Trace(ctx ir.Evaluator, call *ir.CallExpr, args []ir.Element) error

Trace a set of elements.

type SubGrapher added in v0.3.0

type SubGrapher interface {
	SubGraph(name string) (*ops.Subgraph, error)
}

SubGrapher is an element (e.g. a function) that can be represented by a sub-graph.

Jump to

Keyboard shortcuts

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