|
| | SequentialModule (std::vector< Module * > layers) |
| | Constructs a container over an ordered sequence of layers.
|
| |
| Tensor | backward (const Tensor &grad_output) override |
| | Chains backward() across layers_ in reverse order.
|
| |
| OpType | op_type () const override |
| | Composite per charter's closed OpType set – a container wrapping several ops is genuinely not any single existing category.
|
| |
| Tensor | propagate_relevance (const Tensor &relevance_out, const LRPRuleConfig &config) override |
| | Chains propagate_relevance() across layers_ in reverse order.
|
| |
| bool | supports_lrp_rule (LRPRule rule) const override |
| | A rule is supported iff every contained layer supports it (the config is forwarded to all).
|
| |
| std::vector< NamedParamRef > | named_parameters () override |
| | Every contained layer's named_parameters(), prefixed with its index (0.weight).
|
| |
| void | set_training (bool training) override |
| | Sets this container's own training flag and cascades to every contained layer.
|
| |
| const std::vector< Module * > & | layers () const |
| | The contained layers, in forward-execution order.
|
| |
| virtual | ~Module ()=default |
| |
| Tensor | forward (const Tensor &input) |
| | Runs this module's forward computation.
|
| |
| virtual std::optional< DeviceType > | compute_device () const |
| | The device this module computes on, so forward() can reject an input on another device before any kernel sees it (roadmap FND-8).
|
| |
| std::pair< Tensor, NodeId > | forward_traced (const Tensor &input, NodeId input_node, ComputationGraph &graph, Autograd &autograd) |
| | Runs forward() while also registering a ComputationGraph node (tagged with this module's op_type(), parented to input_node) and wiring an Autograd backward function that reuses this module's own backward() – the opt-in traced/explainable path, per Phase 2 Mission 0.
|
| |
| virtual std::vector< ParamRef > | parameters () |
| | This module's trainable parameters and their gradients, for an optimizer to update uniformly across module types.
|
| |
| void | set_requires_grad (bool requires_grad, const std::string &prefix="") |
| | Freezes (false) or unfreezes (true) parameters by name (roadmap FND-2).
|
| |
| bool | is_training () const |
| | Whether this module is currently in training mode.
|
| |
Composes layers_[0..n-1] in forward() order; backward()/propagate_relevance() chain layers_[n-1..0] in reverse – correct reverse-mode composition order.
- Note
- layers_ is not owned – "not owned; must outlive this object", the same convention as every DeviceBackend* member in this codebase. A caller constructing a SequentialModule keeps its constituent modules alive independently.
-
propagate_relevance needs no new LRP theory – pure delegation to each contained layer's own already-cited rule. Conservation holds end-to-end because composing conserving functions conserves; this is verified numerically by an LRPConservationTest TEST_P case, not just asserted in prose.
-
set_training() overrides the (now virtual, since this mission) base method: sets its own flag and cascades to every contained layer – correct even when accessed through a Module* base pointer, not just SequentialModule's own concrete type.