grapheval

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: Apache-2.0 Imports: 15 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 ElementsFromNode

func ElementsFromNode(expr elements.ExprAt, node *ops.OutputNode) ([]elements.Element, error)

ElementsFromNode returns a slice of element from a graph node.

func ElementsFromTupleNode

func ElementsFromTupleNode(g ops.Graph, file *ir.File, expr ir.Expr, tpl ops.Tuple, elExprs []ir.AssignableExpr, shps []*shape.Shape) ([]elements.Element, error)

ElementsFromTupleNode converts the graph nodes of a tuple node into elements.

func MaterialiseAll

func MaterialiseAll(ao elements.ArrayOps, els []elements.Element) ([]*ops.OutputNode, error)

MaterialiseAll materialises a slice of elements into a slice of output graph nodes.

func NodeFromElement

func NodeFromElement(ao elements.ArrayOps, el elements.Element) (ops.Node, *shape.Shape, error)

NodeFromElement converts an element into a graph node. We unpack the value of *ops.OutputNode to prevent from changing the output of Materialise accidentally. Returns an error if the element is not a numerical 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 ElementFromNode

func ElementFromNode(expr elements.ExprAt, node *ops.OutputNode) (*BackendNode, error)

ElementFromNode 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() elements.Copier

Copy the node by returning itself.

func (*BackendNode) Flatten

func (n *BackendNode) Flatten() ([]elements.Element, error)

Flatten returns the element in a slice.

func (*BackendNode) Kind

func (*BackendNode) Kind() ir.Kind

Kind of the element.

func (*BackendNode) Materialise

func (n *BackendNode) Materialise(elements.ArrayOps) (elements.Node, error)

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

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) UnaryOp

UnaryOp applies a unary operator on x.

func (*BackendNode) Unflatten

func (n *BackendNode) Unflatten(handles *elements.Unflattener) (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 evaluator.Importer, pr *processor.Processor, gr ops.Graph, newFunc elements.NewFunc) *Evaluator

New returns a new evaluator given a elements.

func (*Evaluator) ArgGX

func (ev *Evaluator) ArgGX(field elements.FieldAt, index int, args []proxies.Value) (elements.Element, error)

ArgGX represents a GX argument.

func (*Evaluator) ArrayOps

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

ArrayOps returns the array operators implementation.

func (*Evaluator) CallFuncLit

func (ev *Evaluator) CallFuncLit(ctx evaluator.Context, ref *ir.FuncLit, args []elements.Element) ([]elements.Element, error)

CallFuncLit calls a function literal.

func (*Evaluator) ElementFromAtom

func (ev *Evaluator) ElementFromAtom(src elements.ExprAt, val values.Array) (elements.NumericalElement, error)

ElementFromAtom returns an element from a GX value.

func (*Evaluator) Importer

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

Importer returns the importer used by the evaluator.

func (*Evaluator) NewArrayArgument

func (ev *Evaluator) NewArrayArgument(parent parentArgument, expr elements.ExprAt, pValue *proxies.Array) (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(fn ir.Func, recv *elements.Receiver) elements.Func

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

func (*Evaluator) NewSub

NewSub returns a new evaluator given a new array operator implementations.

func (*Evaluator) Processor

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

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

func (*Evaluator) Receiver

func (ev *Evaluator) Receiver(field elements.FieldAt, recv proxies.Value) (elements.Element, error)

Receiver represents a GX function call receiver.

func (*Evaluator) Trace

func (ev *Evaluator) Trace(call elements.CallAt, fn elements.Func, irFunc *ir.FuncBuiltin, args []elements.Element, fc *elements.InputValues) error

Trace a set of elements.

Jump to

Keyboard shortcuts

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