Skip to content

Commit

Permalink
Merge pull request #494 from genn-team/check_event_code_for_den_delay
Browse files Browse the repository at this point in the history
Check event code for den delay
  • Loading branch information
neworderofjamie authored Jan 10, 2022
2 parents 037af10 + f3f87bc commit 4d11fab
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/genn/genn/synapseGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ bool SynapseGroup::isDendriticDelayRequired() const
return true;
}

// If addToInSynDelay function is used in event code, return true
if(getWUModel()->getEventCode().find("$(addToInSynDelay") != std::string::npos) {
return true;
}

// If addToInSynDelay function is used in synapse dynamics, return true
if(getWUModel()->getSynapseDynamicsCode().find("$(addToInSynDelay") != std::string::npos) {
return true;
Expand Down
58 changes: 58 additions & 0 deletions tests/unit/synapseGroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,28 @@ class Continuous : public WeightUpdateModels::Base
};
IMPLEMENT_MODEL(Continuous);

class ContinuousDenDelay : public WeightUpdateModels::Base
{
public:
DECLARE_MODEL(ContinuousDenDelay, 0, 1);

SET_VARS({{"g", "scalar"}});

SET_SYNAPSE_DYNAMICS_CODE("$(addToInSynDelay, $(g) * $(V_pre), 1);\n");
};
IMPLEMENT_MODEL(ContinuousDenDelay);

class GradedDenDelay : public WeightUpdateModels::Base
{
public:
DECLARE_MODEL(GradedDenDelay, 0, 1);

SET_VARS({{"g", "scalar"}});
SET_EVENT_THRESHOLD_CONDITION_CODE("$(V_pre) >= 0.1");
SET_EVENT_CODE("$(addToInSynDelay, $(g)*$(V_pre), 1);");
};
IMPLEMENT_MODEL(GradedDenDelay);

class PostRepeatVal : public InitVarSnippet::Base
{
public:
Expand Down Expand Up @@ -902,6 +924,42 @@ TEST(SynapseGroup, InvalidMatrixTypes)
}
}

TEST(SynapseGroup, IsDendriticDelayRequired)
{
NeuronModels::Izhikevich::ParamValues paramVals(0.02, 0.2, -65.0, 8.0);
NeuronModels::Izhikevich::VarValues varVals(0.0, 0.0);

ModelSpec model;
model.addNeuronPopulation<NeuronModels::Izhikevich>("Pre", 10, paramVals, varVals);
model.addNeuronPopulation<NeuronModels::Izhikevich>("Post", 10, paramVals, varVals);

WeightUpdateModels::StaticPulseDendriticDelay::VarValues staticPulseDendriticVarVals(0.1, 1);
GradedDenDelay::VarValues gradedDenDelayVarVars(0.1);
ContinuousDenDelay::VarValues contDenDelayVarVars(0.1);

auto *syn = model.addSynapsePopulation<WeightUpdateModels::StaticPulseDendriticDelay, PostsynapticModels::DeltaCurr>(
"Syn", SynapseMatrixType::DENSE_GLOBALG, NO_DELAY,
"Pre", "Post",
{}, staticPulseDendriticVarVals,
{}, {});

auto *synGraded = model.addSynapsePopulation<GradedDenDelay, PostsynapticModels::DeltaCurr>(
"SynGraded", SynapseMatrixType::DENSE_GLOBALG, NO_DELAY,
"Pre", "Post",
{}, gradedDenDelayVarVars,
{}, {});

auto *synContinuous = model.addSynapsePopulation<ContinuousDenDelay, PostsynapticModels::DeltaCurr>(
"SynContinuous", SynapseMatrixType::DENSE_GLOBALG, NO_DELAY,
"Pre", "Post",
{}, contDenDelayVarVars,
{}, {});

ASSERT_TRUE(syn->isDendriticDelayRequired());
ASSERT_TRUE(synGraded->isDendriticDelayRequired());
ASSERT_TRUE(synContinuous->isDendriticDelayRequired());
}

TEST(SynapseGroup, InvalidName)
{
NeuronModels::Izhikevich::ParamValues paramVals(0.02, 0.2, -65.0, 8.0);
Expand Down

0 comments on commit 4d11fab

Please sign in to comment.