eazygrad.grad.computation_graph.ComputationGraph¶
- class eazygrad.grad.computation_graph.ComputationGraph[source]¶
Bases:
objectGlobal dynamic computation graph used by EaZyGrad.
The graph stores every differentiable operation as a node together with:
the parent node ids,
the operation object that knows how to backpropagate locally,
the result tensor produced at that node.
Notes
EaZyGrad currently uses a single global graph instance (dag) rather than per-tensor graph ownership. This keeps the implementation small and easy to trace, but it also means graph lifetime management is more manual than in PyTorch.
See also
- backward(root_node_id: int, debug: bool = False, retain_graph: bool = False) None[source]¶
Backpropagate gradients through the computation graph.
- Parameters:
root_node_id (int) – Identifier of the root node from which backpropagation starts.
debug (bool, default=False) – Reserved debug flag. Currently unused.
retain_graph (bool, default=False) – If
True, keep traversed non-leaf nodes in the graph after the backward pass. IfFalse, traversed non-leaf nodes are removed as they are processed.
- Returns:
None
Notes
The method consumes the accumulated gradient stored in each visited node’s
result.acc_gradfield and distributes gradients to parent nodes using the local backward rule of each recorded operation. Broadcasted gradients are reduced to match parent tensor shapes before being accumulated.See also