Skip to contents

The in-progress representation of an AnvlGraph during tracing. This is a mutable class.

While trace_fn() runs a function, every primitive call is recorded as a GraphStatement into the current descriptor (see graph_desc_add() and current_descriptor()). The descriptor also does the book-keeping the trace needs: which GraphValue an AnvlArray or GraphBox stands for, the constants and devices encountered, and the default data types the trace is pinned to. Once tracing finishes, it is converted to an AnvlGraph, which only keeps what is needed to lower and run the program.

Usage

GraphDescriptor(
  statements = list(),
  array_to_gval = NULL,
  gval_to_box = NULL,
  constants = list(),
  in_tree = NULL,
  out_tree = NULL,
  inputs = list(),
  outputs = list(),
  is_static_flat = NULL,
  static_args_flat = NULL,
  devices = character(),
  default_dtypes = NULL,
  backend
)

Arguments

statements

(list(GraphStatement))
The statements that make up the graph.

array_to_gval

(hashtab)
Mapping: AnvlArray -> GraphValue

gval_to_box

(hashtab)
Mapping: GraphValue -> GraphBox

constants

(list(GraphValue))
The constants of the graph.

in_tree

(NULL | RTree)
The tree of inputs. May contain leaves for both array inputs and static (non-array) arguments. Only the array leaves correspond to entries in inputs; use is_static_flat to distinguish them.

out_tree

(NULL | RTree)
The tree of outputs.

inputs

(list(GraphValue))
The inputs to the graph (array arguments only).

outputs

(list(GraphValue))
The outputs of the graph.

is_static_flat

(NULL | logical())
Boolean mask indicating which flat positions in in_tree are static (non-array) args. NULL when all args are array inputs.

static_args_flat

(NULL | list())
Flattened traced values for the static arguments indicated by is_static_flat.

devices

(list())
Devices encountered during tracing: the device of every concrete array registered in the graph, plus the ones declared by graph_desc_add().

default_dtypes

(NULL | list(float, int))
The data types every R value in this trace materializes at when nothing else decides one (see default_dtypes()).

backend

(character(1))
The backend this trace is compiled for. Required: it decides which entry of the anvl.default_dtypes option applies to the trace, so switching the active backend inside a traced body changes nothing. local_descriptor() fills it in from active_backend(), so only a direct call has to name it.

Value

(GraphDescriptor)