Value

struct Value

A node in a compute graph: a typed tensor that is either a literal constant or a reference to a graph local.

FunctionBuilder methods take and return Values. A value with local_index >= 0 refers to the output of an earlier instruction. Otherwise literal_value holds an inline scalar or dense tensor constant. Scalars and nested std::vectors convert to a Value implicitly.

Public Functions

inline Value()

Empty value (no literal, no local); tests as false.

inline Value(me_int_t value)

Scalar integer constant.

inline Value(double value)

Scalar floating-point constant.

template<ScalarType T>
inline Value(const std::vector<std::vector<T>> &values)
template<ScalarType T>
inline Value(const std::vector<T> &values, const std::vector<int> &shape = {})
inline Value(Type _type, int _local_index)
inline Value(Type _type, LiteralValue _literal_value, int _local_index = -1)
inline operator bool()

Public Members

Type type

Type of the value.

LiteralValue literal_value

Inline constant, or std::monostate for a graph local.

int local_index

Index of the referenced graph local, or -1 for a literal.