pulsatrix
Loading...
Searching...
No Matches
aggregator_module.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <optional>
11#include "pulsatrix/module.hpp"
12
13namespace pulsatrix {
14
56class AggregatorModule : public Module {
57public:
67 explicit AggregatorModule(DeviceBackend* backend, float p = 2.0f);
68
88 [[nodiscard]] Tensor backward(const Tensor& grad_output) override;
89
92 [[nodiscard]] OpType op_type() const override { return OpType::Reduction; }
93
135 [[nodiscard]] Tensor propagate_relevance(const Tensor& relevance_out, const LRPRuleConfig& config) override;
136
138 [[nodiscard]] float p() const { return p_; }
139
140
142 [[nodiscard]] std::optional<DeviceType> compute_device() const override { return backend_->device(); }
143
144protected:
155 [[nodiscard]] Tensor forward_impl(const Tensor& input) override;
156
157private:
158 DeviceBackend* backend_;
159 float p_;
160 Tensor last_input_;
161 Tensor last_mean_;
162 Tensor last_output_;
163 bool has_forwarded_ = false;
164};
165
166} // namespace pulsatrix
y = (mean(x^p))^(1/p), reduced over the leading (batch/grounding) axis – not the last axis....
Definition aggregator_module.hpp:56
Tensor propagate_relevance(const Tensor &relevance_out, const LRPRuleConfig &config) override
LRP relevance propagation – genuinely novel, no prior art (research_2026_neuro_symbolic_ai....
std::optional< DeviceType > compute_device() const override
Where this layer computes, so forward() rejects an input on another device (FND-8).
Definition aggregator_module.hpp:142
Tensor backward(const Tensor &grad_output) override
Gradient w.r.t. this module's input, via agg_p's closed-form partial derivative.
OpType op_type() const override
Reduction, per charter's closed OpType set – this is the campaign's first reduction-shaped (rather th...
Definition aggregator_module.hpp:92
Tensor forward_impl(const Tensor &input) override
Computes agg_p over the leading (batch) axis, per remaining "column" (every fixed combination of the ...
AggregatorModule(DeviceBackend *backend, float p=2.0f)
Constructs a p-mean aggregator.
float p() const
This aggregator's configured exponent.
Definition aggregator_module.hpp:138
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:219
virtual DeviceType device() const noexcept=0
Which device this backend's buffers reside on.
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:58
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
OpType
The op-type tag a Node carries. Charter Part 2 §3: nodes are tagged by a small closed set of op types...
Definition op_type.hpp:19
Configuration for LRP relevance propagation: which rule a module applies and its hyperparameters....
Definition lrp_rule_config.hpp:57