diff --git a/src/genn/genn/synapseGroup.cc b/src/genn/genn/synapseGroup.cc index b70dd97b13..01a4446700 100644 --- a/src/genn/genn/synapseGroup.cc +++ b/src/genn/genn/synapseGroup.cc @@ -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; diff --git a/tests/unit/synapseGroup.cc b/tests/unit/synapseGroup.cc index 2076384bc4..59b15c392c 100644 --- a/tests/unit/synapseGroup.cc +++ b/tests/unit/synapseGroup.cc @@ -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: @@ -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("Pre", 10, paramVals, varVals); + model.addNeuronPopulation("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( + "Syn", SynapseMatrixType::DENSE_GLOBALG, NO_DELAY, + "Pre", "Post", + {}, staticPulseDendriticVarVals, + {}, {}); + + auto *synGraded = model.addSynapsePopulation( + "SynGraded", SynapseMatrixType::DENSE_GLOBALG, NO_DELAY, + "Pre", "Post", + {}, gradedDenDelayVarVars, + {}, {}); + + auto *synContinuous = model.addSynapsePopulation( + "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);