Function

class Function

An immutable compute graph produced by FunctionBuilder.

A function has named inputs and outputs, a list of intermediate locals, named globals for trainable or externally supplied tensors, and the ordered list of InstructionCall that computes the outputs from the inputs. Run one with a FunctionRuntime, or save it to disk and load it back.

Public Functions

Function() = default
inline const NamedVector<Value> &inputs() const

Named graph inputs.

inline const NamedVector<Value> &outputs() const

Named graph outputs.

inline const ValueVec &locals() const

Intermediate values, one per instruction output.

inline const std::vector<std::pair<std::string, Value>> &globals() const

Named global tensors: trainable parameters and external inputs.

inline const std::vector<InstructionCall> &instructions() const

The instruction calls in execution order.

void save(const std::string &file) const

Serialize the function to file.

Public Static Functions

static Function load(const std::string &file)

Load a function previously written by save.

Friends

friend class FunctionBuilder