pulsatrix
Loading...
Searching...
No Matches
circuit_graph.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <optional>
8#include <string>
9#include <utility>
10#include <vector>
11
12#include "pulsatrix/node.hpp"
13#include "pulsatrix/op_type.hpp"
14
15namespace pulsatrix {
16
23
26
28 std::optional<std::string> label;
29
38};
39
46
49
61 float weight;
62};
63
82public:
95 CircuitGraph(std::vector<CircuitNode> nodes, std::vector<CircuitEdge> edges)
96 : nodes_(std::move(nodes)), edges_(std::move(edges)) {}
97
99 [[nodiscard]] const std::vector<CircuitNode>& nodes() const { return nodes_; }
100
102 [[nodiscard]] const std::vector<CircuitEdge>& edges() const { return edges_; }
103
104private:
105 std::vector<CircuitNode> nodes_;
106 std::vector<CircuitEdge> edges_;
107};
108
109} // namespace pulsatrix
A copyable, self-contained circuit graph: every node of one forward pass with an ablation importance ...
Definition circuit_graph.hpp:81
CircuitGraph(std::vector< CircuitNode > nodes, std::vector< CircuitEdge > edges)
Constructs a circuit graph from already-computed nodes and edges.
Definition circuit_graph.hpp:95
const std::vector< CircuitNode > & nodes() const
Every scored node, in topological order as of build time.
Definition circuit_graph.hpp:99
const std::vector< CircuitEdge > & edges() const
Every weighted edge, in source-node order as of build time.
Definition circuit_graph.hpp:102
Definition acquisition_functions.hpp:16
size_t NodeId
Stable identifier for a Node within its owning ComputationGraph.
Definition node.hpp:18
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
Computation graph node – op type, shape, optional label, parent/child edges.
Closed set of operation categories every graph Node is tagged with.
One directed edge of a CircuitGraph, carrying a scalar weight.
Definition circuit_graph.hpp:43
NodeId to
Destination node id.
Definition circuit_graph.hpp:48
NodeId from
Source node id.
Definition circuit_graph.hpp:45
float weight
The edge's importance weight.
Definition circuit_graph.hpp:61
One node of a CircuitGraph: a computation-graph node plus its importance score.
Definition circuit_graph.hpp:20
float ablation_effect
Ablation importance: the L2 distance between the network's real output and the output it produces whe...
Definition circuit_graph.hpp:37
OpType op_type
The node's op-type tag, copied at build time.
Definition circuit_graph.hpp:25
NodeId id
The node's id in the ComputationGraph this circuit was built from.
Definition circuit_graph.hpp:22
std::optional< std::string > label
The node's optional human-readable label (e.g. a layer name).
Definition circuit_graph.hpp:28