materialise

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: 6 Imported by: 1

Documentation

Overview

Package materialise defines interfaces and helper functions to transform elements into graph nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(am Materialiser, els []ir.Element) ([]ops.Node, error)

All materialises a slice of elements into a slice of graph nodes.

func AllWithShapes

func AllWithShapes(am Materialiser, els []ir.Element) ([]*ops.OutputNode, error)

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

func Element

func Element(am Materialiser, el ir.Element) (ops.Node, *shape.Shape, error)

Element 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.

func Flatten

func Flatten(mat Materialiser, elts ...ir.Element) ([]ops.Node, []*shape.Shape, error)

Flatten first flatten all the elements, then materialise them all.

Types

type ElementMaterialiser

type ElementMaterialiser interface {
	ir.Element

	// Materialise returns the element with all its values from the graph.
	Materialise(Materialiser) (Node, error)
}

ElementMaterialiser is an element that can return an instance of itself composed only of elements from the backend ops.

type Materialiser

type Materialiser interface {
	// Graph returns the graph to which new nodes are being added.
	Graph() ops.Graph

	// Materialise returns the element with all its values from the graph.
	NodeFromArray(file *ir.File, expr ir.AssignableExpr, val values.Array) (Node, error)

	// ElementsFromNodes returns a slice of elements from nodes
	ElementsFromNodes(file *ir.File, expr ir.AssignableExpr, nodes ...*ops.OutputNode) ([]ir.Element, error)
}

Materialiser materialises an array.

type Node

type Node interface {
	ir.Element
	OutNode() *ops.OutputNode
}

Node is an element representing a numerical node in a compute graph.

Jump to

Keyboard shortcuts

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