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

y = max(x, 0), elementwise. No parameters, no parameter gradients. More...

#include <relu_module.hpp>

Inheritance diagram for pulsatrix::ReluModule:
Collaboration diagram for pulsatrix::ReluModule:

Public Member Functions

 ReluModule (DeviceBackend *backend, DeviceType device)
 Constructs a ReLU module.
 
 ReluModule (DeviceBackend *backend)
 As above, on backend's own device (backend->device()).
 
Tensor backward (const Tensor &grad_output) override
 Computes the gradient w.r.t. this module's input.
 
OpType op_type () const override
 Activation per charter's closed OpType set.
 
Tensor propagate_relevance (const Tensor &relevance_out, const LRPRuleConfig &config) override
 Pass-through LRP relevance propagation.
 
bool supports_lrp_rule (LRPRule) const override
 Pass-through relevance is the same under every rule: supports all of them.
 
std::optional< DeviceType > compute_device () const override
 Where this layer computes, so forward() rejects an input on another device (FND-8).
 
- Public Member Functions inherited from pulsatrix::Module
virtual ~Module ()=default
 
Tensor forward (const Tensor &input)
 Runs this module's forward computation.
 
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< NamedParamRef > named_parameters ()
 This module's trainable parameters, each with its hierarchical name – the one place a module declares its parameters (roadmap FND-1).
 
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).
 
virtual void set_training (bool training)
 Sets this module's training/eval mode. Defaults to training (matches every mainstream framework's Module default).
 
bool is_training () const
 Whether this module is currently in training mode.
 

Protected Member Functions

Tensor forward_impl (const Tensor &input) override
 The actual forward computation. Called by forward() after precondition checks.
 

Detailed Description

y = max(x, 0), elementwise. No parameters, no parameter gradients.

Constructor & Destructor Documentation

◆ ReluModule() [1/2]

pulsatrix::ReluModule::ReluModule ( DeviceBackend *  backend,
DeviceType  device 
)

Constructs a ReLU module.

Parameters
backendBackend to compute through. Not owned; must outlive this module.
deviceWhich device last_input_ is initially tagged as. forward_impl()'s output is tagged with the actual input tensor's device on every call (not this constructor argument), since ReLU has no parameters of its own to anchor a fixed "module device" the way LinearModule's weight_ does – see campaign_exai_dl_library_phase1_5_cuda_backend.md's Mission 3.

◆ ReluModule() [2/2]

pulsatrix::ReluModule::ReluModule ( DeviceBackend *  backend)
explicit

As above, on backend's own device (backend->device()).

Member Function Documentation

◆ backward()

Tensor pulsatrix::ReluModule::backward ( const Tensor &  grad_output)
overridevirtual

Computes the gradient w.r.t. this module's input.

Parameters
grad_outputGradient w.r.t. this module's output. Must match the shape of the most recent forward() call's output.
Returns
Gradient w.r.t. this module's input: grad_output where input > 0, else 0.
Note
x == 0 is treated as blocked (project convention – ReLU's subgradient at 0 is technically any value in [0,1]; this codebase picks 0, matching forward's own x > 0 threshold for max(x, 0)).
Must be called after forward() – uses the input cached from that call.
Device-generic: runs on Cpu, Cuda or Hip tensors (GPU-native-kernels Mission 1).

Implements pulsatrix::Module.

◆ compute_device()

std::optional< DeviceType > pulsatrix::ReluModule::compute_device ( ) const
inlineoverridevirtual

Where this layer computes, so forward() rejects an input on another device (FND-8).

Reimplemented from pulsatrix::Module.

◆ forward_impl()

Tensor pulsatrix::ReluModule::forward_impl ( const Tensor &  input)
overrideprotectedvirtual

The actual forward computation. Called by forward() after precondition checks.

Implements pulsatrix::Module.

◆ op_type()

OpType pulsatrix::ReluModule::op_type ( ) const
inlineoverridevirtual

Activation per charter's closed OpType set.

Implements pulsatrix::Module.

◆ propagate_relevance()

Tensor pulsatrix::ReluModule::propagate_relevance ( const Tensor &  relevance_out,
const LRPRuleConfig &  config 
)
overridevirtual

Pass-through LRP relevance propagation.

Note
Not a placeholder – this IS the correct, standard rule for a pointwise nonlinearity. LRP rules are defined across weighted (Linear/Conv) connections; activation functions pass relevance through unchanged (Montavon et al. 2019; cross-checked against xai_context.aDNA's technique_lrp.md, whose own LRP-0/eps formulation operates on post-nonlinearity activations without giving the nonlinearity itself a separate redistribution rule).

Implements pulsatrix::Module.

◆ supports_lrp_rule()

bool pulsatrix::ReluModule::supports_lrp_rule ( LRPRule  ) const
inlineoverridevirtual

Pass-through relevance is the same under every rule: supports all of them.

Reimplemented from pulsatrix::Module.


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