Skip to content

Commit 6428101

Browse files
authored
Merge pull request #866 from UWB-Biocomputing/VanessaDevelopment
Output weight matrix
2 parents 945ccda + 6747131 commit 6428101

File tree

17 files changed

+269
-15
lines changed

17 files changed

+269
-15
lines changed

Simulator/Connections/Connections.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ void Connections::createEdgeIndexMap()
8181

8282
/// Update the connections status in every epoch.
8383
///
84-
/// @param vertices The vertex list to search from.
8584
/// @return true if successful, false otherwise.
86-
bool Connections::updateConnections(AllVertices &vertices)
85+
bool Connections::updateConnections()
8786
{
8887
return false;
8988
}

Simulator/Connections/Connections.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class Connections {
6767

6868
/// Update the connections status in every epoch.
6969
///
70-
/// @param vertices The vertex list to search from.
7170
/// @return true if successful, false otherwise.
72-
virtual bool updateConnections(AllVertices &vertices);
71+
virtual bool updateConnections();
7372

7473
/// Cereal serialization method
7574
template <class Archive> void serialize(Archive &archive);

Simulator/Connections/NG911/Connections911.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void Connections911::printParameters() const
6363

6464
#if !defined(USE_GPU)
6565
/// Update the connections status in every epoch.
66-
bool Connections911::updateConnections(AllVertices &vertices)
66+
bool Connections911::updateConnections()
6767
{
6868
// Only run on the first epoch
6969
if (Simulator::getInstance().getCurrentStep() != 1) {
@@ -73,6 +73,7 @@ bool Connections911::updateConnections(AllVertices &vertices)
7373
// Record old type map
7474
int numVertices = Simulator::getInstance().getTotalVertices();
7575
Layout &layout = Simulator::getInstance().getModel().getLayout();
76+
AllVertices &vertices = layout.getVertices();
7677
oldTypeMap_ = layout.vertexTypeMap_;
7778

7879
// Erase PSAPs

Simulator/Connections/NG911/Connections911.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ class Connections911 : public Connections {
7272
/// Update the connections status in every epoch.
7373
/// Uses the parent definition for USE_GPU
7474
///
75-
/// @param vertices The Vertex list to search from.
7675
/// @return true if successful, false otherwise.
77-
virtual bool updateConnections(AllVertices &vertices) override;
76+
virtual bool updateConnections() override;
7877

7978
/// Finds the outgoing edge from the given vertex to the Responder closest to
8079
/// the emergency call location

Simulator/Connections/Neuro/ConnGrowth.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ void ConnGrowth::printParameters() const
126126

127127
/// Update the connections status in every epoch.
128128
///
129-
/// @param vertices The vertex list to search from.
130129
/// @return true if successful, false otherwise.
131-
bool ConnGrowth::updateConnections(AllVertices &vertices)
130+
bool ConnGrowth::updateConnections()
132131
{
132+
Layout &layout = Simulator::getInstance().getModel().getLayout();
133+
AllVertices &vertices = layout.getVertices();
134+
133135
// Update Connections data
134136
updateConns(vertices);
135137

Simulator/Connections/Neuro/ConnGrowth.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ class ConnGrowth : public Connections {
103103

104104
/// Update the connections status in every epoch.
105105
///
106-
/// @param vertices The vertex list to search from.
107106
/// @return true if successful, false otherwise.
108-
virtual bool updateConnections(AllVertices &vertices) override;
107+
virtual bool updateConnections() override;
109108

110109
/// Cereal serialization method
111110
template <class Archive> void serialize(Archive &archive);

Simulator/Connections/Neuro/ConnGrowth_d.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ void ConnGrowth::updateEdgesWeights(int numVertices, AllVertices &vertices, AllE
7777

7878
// copy device synapse count to host memory
7979
edges.copyDeviceEdgeCountsToHost(allEdgesDevice);
80-
// copy device synapse summation coordinate to host memory
81-
dynamic_cast<AllSpikingSynapses &>(edges).copyDeviceEdgeSumIdxToHost(allEdgesDevice);
80+
81+
// copy device synapse summation coordinate and weights to host memory
82+
AllSpikingSynapses &synapses = dynamic_cast<AllSpikingSynapses &>(edges);
83+
synapses.copyDeviceEdgeSumIdxToHost(allEdgesDevice);
84+
synapses.copyDeviceEdgeWeightsToHost(allEdgesDevice);
85+
86+
// output weight matrix every epoch
87+
synapses.outputWeights(simulator.getCurrentStep());
8288
}

Simulator/Connections/Neuro/ConnStatic.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,14 @@ void ConnStatic::loadParameters()
8989
void ConnStatic::printParameters() const
9090
{
9191
}
92+
93+
/// Output the weights matrix after every epoch.
94+
///
95+
/// @return true if successful, false otherwise.
96+
bool ConnStatic::updateConnections()
97+
{
98+
AllNeuroEdges &synapses = dynamic_cast<AllNeuroEdges &>(*edges_);
99+
synapses.outputWeights(Simulator::getInstance().getCurrentStep());
100+
101+
return true;
102+
}

Simulator/Connections/Neuro/ConnStatic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class ConnStatic : public Connections {
8080
return destVertexIndexCurrentEpoch_;
8181
}
8282

83+
/// Output the weights matrix after every epoch.
84+
///
85+
/// @return true if successful, false otherwise.
86+
virtual bool updateConnections() override;
87+
8388
/// Cereal serialization method
8489
template <class Archive> void serialize(Archive &archive);
8590

Simulator/Core/CPUModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void CPUModel::advance()
3535
void CPUModel::updateConnections()
3636
{
3737
// Update Connections data
38-
if (connections_->updateConnections(layout_->getVertices())) {
38+
if (connections_->updateConnections()) {
3939
connections_->updateEdgesWeights();
4040
// create edge inverse map
4141
connections_->createEdgeIndexMap();

0 commit comments

Comments
 (0)