Skip to main content

ClikaRT::graph::Node

class

Header: ClikaRT/graph/node.h

One node of a compiled graph: an operator, or a graph input. The view finds its node again by name after an edit; once no node has that name (it was removed or renamed), the view answers empty and check() says so.

Member functions​

check()​

void check() const

Nothing when the graph still holds a node of this name; Status::InvalidArgument naming it when it no longer does, or when the graph itself no longer exists.

Declared in ClikaRT/graph/node.h, line 247

name()​

std::string name() const

The node's name, unique within its graph: a graph input's declared name, or a name the runtime generates from the operator's type (a compiled ONNX model's own Transpose keeps its ONNX node name).

Declared in ClikaRT/graph/node.h, line 251

kind()​

NodeKind kind() const

Declared in ClikaRT/graph/node.h, line 252

op_code()​

OpCode op_code() const

The operator. OpCode::Placeholder for an Input node, OpCode::Custom for a user-defined operator (see custom_name()).

Declared in ClikaRT/graph/node.h, line 255

custom_name()​

std::string custom_name() const

A user-defined operator's own name; empty unless op_code() is OpCode::Custom.

Declared in ClikaRT/graph/node.h, line 258

inputs()​

std::vector<Value> inputs() const

The values this node consumes, in input-port order; an omitted optional operand has no entry. A constant operand of a compiled ONNX graph (an initializer) is an input (Value::is_constant()) and also the operator's bound tensor, the same bytes read two ways; a traced module's weights are bound into the operator alone, see bound_tensors().

Declared in ClikaRT/graph/node.h, line 265

outputs()​

std::vector<Value> outputs() const

The values this node produces, one per output port in port order. An output that no operator and no graph output reads has no entry.

Declared in ClikaRT/graph/node.h, line 268

input()​

std::optional<Value> input(int port) const

The value on input port port, a constant or state operand included; empty when nothing feeds the port (an omitted optional operand, a port the node lacks, any port of an Input node).

Declared in ClikaRT/graph/node.h, line 272

output()​

std::optional<Value> output(int port) const

The value on output port port; empty when no operator and no graph output reads it, and for a port the node lacks.

Declared in ClikaRT/graph/node.h, line 275

in_edges()​

std::vector<Edge> in_edges() const

The edges entering this node in input-port order, one per port another node feeds (Mul(x, x) has two); a constant or state operand is an input but no edge.

Declared in ClikaRT/graph/node.h, line 279

out_edges()​

std::vector<Edge> out_edges() const

The edges leaving this node, one per read, in (output port, consumer name, consumer input port) order.

Declared in ClikaRT/graph/node.h, line 282

in_degree()​

std::size_t in_degree() const

in_edges().size(), parallel edges counted.

Declared in ClikaRT/graph/node.h, line 284

out_degree()​

std::size_t out_degree() const

out_edges().size(), parallel edges counted.

Declared in ClikaRT/graph/node.h, line 286

predecessors()​

std::vector<Node> predecessors() const

The nodes producing this node's inputs, in first-use order, each once. A constant or state operand has no producing node and contributes none.

Declared in ClikaRT/graph/node.h, line 289

successors()​

std::vector<Node> successors() const

The nodes consuming this node's outputs, in first-use order, each once.

Declared in ClikaRT/graph/node.h, line 291

attributes()​

std::vector<Attr> attributes() const

The operator's configuration, one entry per setting in the operator's own order. Tensors are not attributes: an operand arrives through inputs(), a bound weight through bound_tensors().

Declared in ClikaRT/graph/node.h, line 295

attribute()​

std::optional<Attr> attribute(std::string_view name) const

The attribute named name, or std::nullopt.

Declared in ClikaRT/graph/node.h, line 297

fused_activation()​

std::optional<ops::Activation> fused_activation() const

The activation the operator applies to its result in the same pass (a projection with a fused activation): Activation::Identity when the operator carries the setting but applies none, empty when the operator has no such setting.

Declared in ClikaRT/graph/node.h, line 302

bound_tensors()​

std::vector<BoundTensor> bound_tensors() const

The tensors bound into the operator itself, in the operator's own order, one entry per slot that holds a tensor: a traced module's weights. The names are the OPERATOR's slots, not the module's parameter names: an nn::Linear binds its [out, in] weight as its matmul's second operand, slot "b", and its bias as "bias". Each tensor is a shared handle to the bound bytes, no copy. A compiled ONNX initializer appears both as a constant input (Value::is_constant()) and as the operator's bound tensor; the two read the same bytes. Empty for an Input node and for an operator that binds nothing.

A weight the module has already packed into its kernel layout is released from the operator and is not reported: the pack runs at the module's first forward (or at load with nn::LoadOptions::pack_on_load), and again when the traced graph is finalized (ModelGraph::finalize), so on a finalized graph the packed operators report no weight. A packed weight is read from its owning module: nn::Module::named_parameters() / state_dict() reconstruct it value-exact. To read a module's weights here, load it with nn::LoadOptions::weight_residency set to nn::WeightResidency::Borrowed (or PerCall) and read the graph before finalize().

Declared in ClikaRT/graph/node.h, line 323

Friends​

operator==​

friend bool operator==(const Node& a, const Node& b) noexcept

Two views of the same node (the same graph and name) compare equal.

Declared in ClikaRT/graph/node.h, line 326