pulsatrix
Loading...
Searching...
No Matches
disjunction_module.hpp
Go to the documentation of this file.
1
7#pragma once
8
9#include <optional>
10#include "pulsatrix/module.hpp"
11
12namespace pulsatrix {
13
22class DisjunctionModule : public Module {
23public:
25 enum class TConorm {
26 Product,
28 Godel
29 };
30
37
38 using Module::forward;
39
44 [[nodiscard]] Tensor forward(const Tensor& a, const Tensor& b);
45
47 [[nodiscard]] static Tensor stack_operands(const Tensor& a, const Tensor& b, DeviceBackend* backend);
48
56 [[nodiscard]] Tensor backward(const Tensor& grad_output) override;
57
59 [[nodiscard]] OpType op_type() const override { return OpType::Elementwise; }
60
94 [[nodiscard]] Tensor propagate_relevance(const Tensor& relevance_out, const LRPRuleConfig& config) override;
95
96
98 [[nodiscard]] std::optional<DeviceType> compute_device() const override { return backend_->device(); }
99
100protected:
106 [[nodiscard]] Tensor forward_impl(const Tensor& input) override;
107
108private:
109 DeviceBackend* backend_;
110 TConorm t_conorm_;
111 Tensor last_input_;
112 Tensor last_output_;
113 bool has_forwarded_ = false;
114};
115
116} // namespace pulsatrix
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.
y = a S b for a selected t-conorm S, over two independent fuzzy-truth-valued operand tensors (values ...
Definition disjunction_module.hpp:22
Tensor forward_impl(const Tensor &input) override
Splits input (leading dim 2) into the two operands and computes the selected t-conorm elementwise.
OpType op_type() const override
Elementwise per this module's own op_type() convention.
Definition disjunction_module.hpp:59
DisjunctionModule(DeviceBackend *backend, TConorm t_conorm=TConorm::Product)
Constructs a disjunction module.
Tensor propagate_relevance(const Tensor &relevance_out, const LRPRuleConfig &config) override
LRP relevance propagation for the selected t-conorm – genuinely novel, no prior art (research_2026_ne...
static Tensor stack_operands(const Tensor &a, const Tensor &b, DeviceBackend *backend)
See ConjunctionModule::stack_operands()'s identical convention.
Tensor backward(const Tensor &grad_output) override
Gradient w.r.t. this module's (stacked) input.
TConorm
Which t-conorm this instance computes. Product is the campaign's primary case.
Definition disjunction_module.hpp:25
std::optional< DeviceType > compute_device() const override
Where this layer computes, so forward() rejects an input on another device (FND-8).
Definition disjunction_module.hpp:98
Tensor forward(const Tensor &a, const Tensor &b)
Convenience two-operand entry point – see ConjunctionModule::forward(a, b)'s identical convention.
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:58
Tensor forward(const Tensor &input)
Runs this module's forward computation.
Definition module.hpp:73
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