ATLAS Offline Software
Loading...
Searching...
No Matches
lwtDev::LightweightGraph Class Reference

#include <LightweightGraph.h>

Collaboration diagram for lwtDev::LightweightGraph:

Public Types

typedef std::map< std::string, ValueMapNodeMap
typedef std::map< std::string, VectorMapSeqNodeMap

Public Member Functions

 LightweightGraph (const GraphConfig &config, const std::string &default_output="")
 ~LightweightGraph ()
 LightweightGraph (LightweightGraph &)=delete
LightweightGraphoperator= (LightweightGraph &)=delete
ValueMap compute (const NodeMap &, const SeqNodeMap &={}) const
ValueMap compute (const NodeMap &, const SeqNodeMap &, const std::string &output) const
VectorMap scan (const NodeMap &, const SeqNodeMap &={}) const
VectorMap scan (const NodeMap &, const SeqNodeMap &, const std::string &output) const

Private Types

typedef InputPreprocessor IP
typedef InputVectorPreprocessor IVP
typedef std::vector< std::pair< std::string, IP * > > Preprocs
typedef std::vector< std::pair< std::string, IVP * > > VecPreprocs

Private Member Functions

ValueMap compute (const NodeMap &, const SeqNodeMap &, size_t) const
VectorMap scan (const NodeMap &, const SeqNodeMap &, size_t) const

Private Attributes

Graphm_graph
Preprocs m_preprocs
VecPreprocs m_vec_preprocs
std::vector< std::pair< size_t, std::vector< std::string > > > m_outputs
std::map< std::string, size_t > m_output_indices
size_t m_default_output

Detailed Description

Definition at line 64 of file LightweightGraph.h.

Member Typedef Documentation

◆ IP

Definition at line 98 of file LightweightGraph.h.

◆ IVP

Definition at line 99 of file LightweightGraph.h.

◆ NodeMap

typedef std::map<std::string, ValueMap> lwtDev::LightweightGraph::NodeMap

Definition at line 68 of file LightweightGraph.h.

◆ Preprocs

typedef std::vector<std::pair<std::string, IP*> > lwtDev::LightweightGraph::Preprocs
private

Definition at line 100 of file LightweightGraph.h.

◆ SeqNodeMap

typedef std::map<std::string, VectorMap> lwtDev::LightweightGraph::SeqNodeMap

Definition at line 69 of file LightweightGraph.h.

◆ VecPreprocs

typedef std::vector<std::pair<std::string, IVP*> > lwtDev::LightweightGraph::VecPreprocs
private

Definition at line 101 of file LightweightGraph.h.

Constructor & Destructor Documentation

◆ LightweightGraph() [1/2]

lwtDev::LightweightGraph::LightweightGraph ( const GraphConfig & config,
const std::string & default_output = "" )

Definition at line 68 of file LightweightGraph.cxx.

69 :
70 m_graph(new Graph(config.nodes, config.layers))
71 {
72 for (const auto& node: config.inputs) {
73 m_preprocs.emplace_back(
74 node.name, new InputPreprocessor(node.variables));
75 }
76 for (const auto& node: config.input_sequences) {
77 m_vec_preprocs.emplace_back(
78 node.name, new InputVectorPreprocessor(node.variables));
79 }
80 size_t output_n = 0;
81 for (const auto& node: config.outputs) {
82 m_outputs.emplace_back(node.second.node_index, node.second.labels);
83 m_output_indices.emplace(node.first, output_n);
84 output_n++;
85 }
86 if (default_output.size() > 0) {
87 if (!m_output_indices.count(default_output)) {
88 throw NNConfigurationException("no output node" + default_output);
89 }
90 m_default_output = m_output_indices.at(default_output);
91 } else if (output_n == 1) {
93 } else {
94 throw NNConfigurationException("you must specify a default output");
95 }
96 }
std::map< std::string, size_t > m_output_indices
std::vector< std::pair< size_t, std::vector< std::string > > > m_outputs

◆ ~LightweightGraph()

lwtDev::LightweightGraph::~LightweightGraph ( )

Definition at line 98 of file LightweightGraph.cxx.

98 {
99 delete m_graph;
100 for (auto& preproc: m_preprocs) {
101 delete preproc.second;
102 preproc.second = 0;
103 }
104 for (auto& preproc: m_vec_preprocs) {
105 delete preproc.second;
106 preproc.second = 0;
107 }
108 }

◆ LightweightGraph() [2/2]

lwtDev::LightweightGraph::LightweightGraph ( LightweightGraph & )
delete

Member Function Documentation

◆ compute() [1/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap & nodes,
const SeqNodeMap & seq,
const std::string & output ) const

Definition at line 114 of file LightweightGraph.cxx.

116 {
117 if (!m_output_indices.count(output)) {
118 throw NNEvaluationException("no output node " + output);
119 }
120 return compute(nodes, seq, m_output_indices.at(output));
121 }
ValueMap compute(const NodeMap &, const SeqNodeMap &={}) const

◆ compute() [2/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap & nodes,
const SeqNodeMap & seq,
size_t idx ) const
private

Definition at line 122 of file LightweightGraph.cxx.

124 {
125 LazySource source(nodes, seq, m_preprocs, m_vec_preprocs);
126 VectorXd result = m_graph->compute(source, m_outputs.at(idx).first);
127 const std::vector<std::string>& labels = m_outputs.at(idx).second;
128 std::map<std::string, double> output;
129 for (size_t iii = 0; iii < labels.size(); iii++) {
130 output[labels.at(iii)] = result(iii);
131 }
132 return output;
133 }
output
Definition merge.py:16

◆ compute() [3/3]

ValueMap lwtDev::LightweightGraph::compute ( const NodeMap & nodes,
const SeqNodeMap & seq = {} ) const

Definition at line 110 of file LightweightGraph.cxx.

111 {
112 return compute(nodes, seq, m_default_output);
113 }

◆ operator=()

LightweightGraph & lwtDev::LightweightGraph::operator= ( LightweightGraph & )
delete

◆ scan() [1/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap & nodes,
const SeqNodeMap & seq,
const std::string & output ) const

Definition at line 139 of file LightweightGraph.cxx.

141 {
142 if (!m_output_indices.count(output)) {
143 throw NNEvaluationException("no output node " + output);
144 }
145 return scan(nodes, seq, m_output_indices.at(output));
146 }
VectorMap scan(const NodeMap &, const SeqNodeMap &={}) const

◆ scan() [2/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap & nodes,
const SeqNodeMap & seq,
size_t idx ) const
private

Definition at line 147 of file LightweightGraph.cxx.

149 {
150 LazySource source(nodes, seq, m_preprocs, m_vec_preprocs);
151 MatrixXd result = m_graph->scan(source, m_outputs.at(idx).first);
152 const std::vector<std::string>& labels = m_outputs.at(idx).second;
153 std::map<std::string, std::vector<double> > output;
154 for (size_t iii = 0; iii < labels.size(); iii++) {
155 VectorXd row = result.row(iii);
156 std::vector<double> out_vector(row.data(), row.data() + row.size());
157 output[labels.at(iii)] = std::move(out_vector);
158 }
159 return output;
160 }
row
Appending html table to final .html summary file.

◆ scan() [3/3]

VectorMap lwtDev::LightweightGraph::scan ( const NodeMap & nodes,
const SeqNodeMap & seq = {} ) const

Definition at line 135 of file LightweightGraph.cxx.

136 {
137 return scan(nodes, seq, m_default_output);
138 }

Member Data Documentation

◆ m_default_output

size_t lwtDev::LightweightGraph::m_default_output
private

Definition at line 110 of file LightweightGraph.h.

◆ m_graph

Graph* lwtDev::LightweightGraph::m_graph
private

Definition at line 105 of file LightweightGraph.h.

◆ m_output_indices

std::map<std::string, size_t> lwtDev::LightweightGraph::m_output_indices
private

Definition at line 109 of file LightweightGraph.h.

◆ m_outputs

std::vector<std::pair<size_t, std::vector<std::string> > > lwtDev::LightweightGraph::m_outputs
private

Definition at line 108 of file LightweightGraph.h.

◆ m_preprocs

Preprocs lwtDev::LightweightGraph::m_preprocs
private

Definition at line 106 of file LightweightGraph.h.

◆ m_vec_preprocs

VecPreprocs lwtDev::LightweightGraph::m_vec_preprocs
private

Definition at line 107 of file LightweightGraph.h.


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