-
Notifications
You must be signed in to change notification settings - Fork 18
[issue-779] Populate STDP edge recorder output #949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lnanduri2005
wants to merge
4
commits into
LikithaDev
Choose a base branch
from
issue-779-stdp-edge-output
base: LikithaDev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,11 +93,36 @@ void ConnStatic::printParameters() const | |
| void ConnStatic::registerHistoryVariables() | ||
| { | ||
| // Register the following variables to be recorded | ||
| // Note: There may be potential duplicate weight, source, destination vertices | ||
| Recorder &recorder = Simulator::getInstance().getModel().getRecorder(); | ||
| recorder.registerVariable("weight", WCurrentEpoch_, Recorder::UpdatedType::DYNAMIC); | ||
| recorder.registerVariable("sourceVertex", sourceVertexIndexCurrentEpoch_, | ||
| Recorder::UpdatedType::DYNAMIC); | ||
| recorder.registerVariable("destinationVertex", destVertexIndexCurrentEpoch_, | ||
| Recorder::UpdatedType::DYNAMIC); | ||
| } | ||
|
|
||
| bool ConnStatic::updateConnections() | ||
| { | ||
| // GPU STDP is not implemented, so this only uses the CPU edge data. | ||
| WCurrentEpoch_.startNewEpoch(); | ||
| sourceVertexIndexCurrentEpoch_.startNewEpoch(); | ||
| destVertexIndexCurrentEpoch_.startNewEpoch(); | ||
|
|
||
| AllEdges &edges = getEdges(); | ||
| const vector<unsigned char> &inUse = edges.getInUse(); | ||
| const vector<BGFLOAT> &weights = edges.getWeights(); | ||
| const vector<int> &sourceVertices = edges.getSourceVertexIndices(); | ||
| const vector<int> &destVertices = edges.getDestVertexIndices(); | ||
|
|
||
| // Copy one value per active edge into parallel recorder vectors. | ||
| // Entries at the same index describe the same edge. | ||
| for (BGSIZE iEdg = 0; iEdg < inUse.size(); iEdg++) { | ||
| if (inUse[iEdg]) { | ||
| WCurrentEpoch_.push_back(weights[iEdg]); | ||
| sourceVertexIndexCurrentEpoch_.push_back(sourceVertices[iEdg]); | ||
| destVertexIndexCurrentEpoch_.push_back(destVertices[iEdg]); | ||
|
Comment on lines
+121
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two questions:
Use the CoPilot unit test skill to generate unit tests for this. It should catch the case where these aren't cleared and so aren't copies. Actually, can't you just use the assignment operator, |
||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /** | ||
| * @file ConnStaticTests.cpp | ||
| * | ||
| * @brief Unit tests for ConnStatic. | ||
| * | ||
| * @ingroup Testing/UnitTesting | ||
| */ | ||
|
|
||
| #include "AllSTDPSynapses.h" | ||
| #include "ConnStatic.h" | ||
| #include "gtest/gtest.h" | ||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| namespace { | ||
|
|
||
| class TestConnStatic : public ConnStatic { | ||
| public: | ||
| void setEdges(std::unique_ptr<AllEdges> edges) | ||
| { | ||
| edges_ = std::move(edges); | ||
| } | ||
| }; | ||
|
|
||
| TEST(ConnStatic, UpdateConnectionsCopiesActiveEdgesWithoutAccumulating) | ||
| { | ||
| auto edges = std::make_unique<AllSTDPSynapses>(3, 2); | ||
| edges->addEdge(edgeType::EE, 0, 2, 0.001); | ||
| edges->addEdge(edgeType::II, 2, 0, 0.001); | ||
|
|
||
| const std::vector<int> expectedSources {2, 0}; | ||
| const std::vector<int> expectedDestinations {0, 2}; | ||
| const std::vector<BGFLOAT> expectedWeights {-10.0e-9, 10.0e-9}; | ||
|
|
||
| TestConnStatic connections; | ||
| connections.setEdges(std::move(edges)); | ||
|
|
||
| connections.updateConnections(); | ||
|
|
||
| EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); | ||
| EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); | ||
| EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); | ||
|
|
||
| connections.updateConnections(); | ||
|
|
||
| EXPECT_EQ(expectedSources, connections.getSourceVertexIndexCurrentEpoch()); | ||
| EXPECT_EQ(expectedDestinations, connections.getDestVertexIndexCurrentEpoch()); | ||
| EXPECT_EQ(expectedWeights, connections.getWCurrentEpoch()); | ||
| } | ||
|
|
||
| } // namespace |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, see my questions attached to the
UpdateConnections()method. A unit test should be able to verify that theConnStaticdata members are indeed copies of those from the Edge class.