pulsatrix
Loading...
Searching...
No Matches
pulsatrix::Node Class Reference

A single computation graph node. Owned exclusively by its ComputationGraph (see computation_graph.hpp); parent/child edges here are non-owning raw pointers into nodes the same graph owns. More...

#include <node.hpp>

Public Member Functions

 Node (NodeId id, OpType op_type, Shape shape, std::optional< std::string > label=std::nullopt)
 Constructs a node.
 
NodeId id () const
 
OpType op_type () const
 
const Shape & shape () const
 
const std::optional< std::string > & label () const
 
const std::vector< Node * > & parents () const
 This node's parent nodes (edges point from parent to this node).
 
const std::vector< Node * > & children () const
 This node's child nodes.
 
void add_parent (Node *parent)
 Registers parent as a parent of this node. Non-owning; parent must outlive this node.
 
void add_child (Node *child)
 Registers child as a child of this node. Non-owning; child must outlive this node.
 

Detailed Description

A single computation graph node. Owned exclusively by its ComputationGraph (see computation_graph.hpp); parent/child edges here are non-owning raw pointers into nodes the same graph owns.

Note
Nodes never expose a way to remove an edge or reset parents/children to empty – this is deliberate. ComputationGraph's persistence guarantee (graph survives past the backward pass, Mission 3) depends on nothing anywhere in this codebase being able to silently discard graph structure.

Constructor & Destructor Documentation

◆ Node()

pulsatrix::Node::Node ( NodeId  id,
OpType  op_type,
Shape  shape,
std::optional< std::string >  label = std::nullopt 
)
inline

Constructs a node.

Parameters
idThis node's stable identifier, assigned by the owning ComputationGraph.
op_typeThe operation category this node represents.
shapeThis node's output shape.
labelOptional human-readable label (e.g. a layer name), for debugging/display.

Member Function Documentation

◆ add_child()

void pulsatrix::Node::add_child ( Node *  child)
inline

Registers child as a child of this node. Non-owning; child must outlive this node.

◆ add_parent()

void pulsatrix::Node::add_parent ( Node *  parent)
inline

Registers parent as a parent of this node. Non-owning; parent must outlive this node.

◆ children()

const std::vector< Node * > & pulsatrix::Node::children ( ) const
inline

This node's child nodes.

◆ id()

NodeId pulsatrix::Node::id ( ) const
inline

◆ label()

const std::optional< std::string > & pulsatrix::Node::label ( ) const
inline

◆ op_type()

OpType pulsatrix::Node::op_type ( ) const
inline

◆ parents()

const std::vector< Node * > & pulsatrix::Node::parents ( ) const
inline

This node's parent nodes (edges point from parent to this node).

◆ shape()

const Shape & pulsatrix::Node::shape ( ) const
inline

The documentation for this class was generated from the following file: