zl_graph() calls build(x) once, with x a named list of input
tensors of the declared shapes, and records the tensors build()
returns as the graph's outputs. Inside build(), inputs, parameters
(from zl_param_tensor()) and the results of operations such as
zl_crossprod() are tensors; build() is not called again, and a
different input shape needs another graph.
Usage
zl_graph(build, p, inputs, loss = NULL, outputs = NULL)
zl_int(...)
zl_forward(g, data, outputs = NULL)
zl_graph_info(g)Arguments
- build
A function of one argument, the named list of inputs, returning a tensor or a named list of tensors.
- p
The parameter store whose parameters
build()uses.- inputs
A named list of input dimensions: numeric vectors of one to four positive whole numbers, or
zl_int(...)for an integer input.- loss
The name of a scalar output to train on (see the training functions);
NULLfor none.- outputs
The names of the outputs to keep, of those
build()returns;NULLfor all.- ...
Dimensions, for
zl_int(); or, in themapofzl_arrow_batches(), the names of integer columns.- g
A graph; for
zl_forward(), also a graph cache fromzl_graph_cache().- data
A named list of arrays, one per input, each matching its input's dimensions exactly (a plain vector for a one-dimensional input).
NAis refused. Or an iterator fromzl_arrow_batches(), whose next batch is written straight into the inputs;zl_forward()then returnsNULLonce the stream has ended.
Value
zl_graph() returns a graph of class zl_graph; zl_int() an
input specification; zl_forward() a named list of double arrays;
zl_graph_info() a list describing the graph.
Details
zl_forward() writes data into the inputs, runs the graph and
returns the outputs as double arrays. The inputs are rewritten in place
on every call, so a graph runs any number of times without being
rebuilt.
Inputs are single-precision (f32) unless declared with zl_int(),
which makes them 32-bit integers (i32) for zl_get_rows() and
zl_rope(). Integer indices count from 0, as in 'ggml'.