Skip to content
class

Edge

Edge

A directed edge in the backward computation graph.

An Edge connects a producer node to a specific input slot (input_nr) of a consumer node. The owning shared_ptr keeps the consumer alive while at least one producer references it, forming the ownership chain that mirrors the forward computation. input_nr is the positional index into the consumer's Node::apply output vector where the arriving gradient must land.

See Also

Node — consumes edges as next_edges_ during backward.

Attributes

nodestd::shared_ptr<Node>
The consumer node that should receive a gradient along this edge.
input_nrstd::uint32_t
Positional input index on node that this edge targets. The engine writes the produced gradient into apply's output at this slot.

Notes

An invalid edge (node == nullptr) marks a structural hole — for example an input that does not require grad — and is skipped by the engine without raising.

Constructors

1
ctor

Edge

void Edge()

Default-constructed empty edge with node == nullptr.

Methods

1
fnconst

is_valid

→bool
bool is_valid()

Returns whether this edge points to a live consumer node.

Returns

bool

true when node != nullptr, false for empty edges.