GeNN  3.3.0
GPU enhanced Neuronal Networks (GeNN)
standardSubstitutions.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Standard includes
4 #include <string>
5 
6 // GeNN includes
7 #include "codeGenUtils.h"
9 #include "newNeuronModels.h"
10 
11 // Forward declarations
12 class NeuronGroup;
13 class SynapseGroup;
14 class CurrentSource;
15 
16 //----------------------------------------------------------------------------
17 // NameIterCtx
18 //----------------------------------------------------------------------------
19 template<typename Container>
21 {
23 
24  NameIterCtx(const Container &c) :
25  container(c), nameBegin(std::begin(container)), nameEnd(std::end(container)){}
26 
27  const Container container;
28  const NameIter nameBegin;
29  const NameIter nameEnd;
30 };
31 
32 //----------------------------------------------------------------------------
33 // Typedefines
34 //----------------------------------------------------------------------------
38 
39 //----------------------------------------------------------------------------
40 // Standard substitution functins
41 //----------------------------------------------------------------------------
43 {
46  std::string &psCode,
47  const SynapseGroup *sg,
48  const NeuronGroup &ng,
49  const VarNameIterCtx &nmVars,
50  const DerivedParamNameIterCtx &nmDerivedParams,
51  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
52  const std::vector<FunctionTemplate> &functions,
53  const std::string &ftype,
54  const std::string &rng);
55 
57 void postSynapseDecay(
58  std::string &pdCode,
59  const SynapseGroup *sg,
60  const NeuronGroup &ng,
61  const VarNameIterCtx &nmVars,
62  const DerivedParamNameIterCtx &nmDerivedParams,
63  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
64  const std::vector<FunctionTemplate> &functions,
65  const std::string &ftype,
66  const std::string &rng);
67 
70  std::string &thCode,
71  const NeuronGroup &ng,
72  const VarNameIterCtx &nmVars,
73  const DerivedParamNameIterCtx &nmDerivedParams,
74  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
75  const std::vector<FunctionTemplate> &functions,
76  const std::string &ftype,
77  const std::string &rng);
78 
79 void neuronSim(
80  std::string &sCode,
81  const NeuronGroup &ng,
82  const VarNameIterCtx &nmVars,
83  const DerivedParamNameIterCtx &nmDerivedParams,
84  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
85  const std::vector<FunctionTemplate> &functions,
86  const std::string &ftype,
87  const std::string &rng);
88 
90  std::string &eCode,
91  const NeuronGroup &ng,
92  const VarNameIterCtx &nmVars,
93  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
94  const std::vector<FunctionTemplate> &functions,
95  const std::string &ftype,
96  const std::string &rng);
97 
98 void neuronReset(
99  std::string &rCode,
100  const NeuronGroup &ng,
101  const VarNameIterCtx &nmVars,
102  const DerivedParamNameIterCtx &nmDerivedParams,
103  const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams,
104  const std::vector<FunctionTemplate> &functions,
105  const std::string &ftype,
106  const std::string &rng);
107 
109  std::string &eCode,
110  const SynapseGroup &sg,
111  const DerivedParamNameIterCtx &wuDerivedParams,
112  const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams,
113  const string &preIdx,
114  const string &postIdx,
115  const string &devPrefix,
116  const std::vector<FunctionTemplate> &functions,
117  const std::string &ftype,
118  double dt);
119 
120 void weightUpdateSim(
121  std::string &wCode,
122  const SynapseGroup &sg,
123  const VarNameIterCtx &wuVars,
124  const VarNameIterCtx &wuPreVars,
125  const VarNameIterCtx &wuPostVars,
126  const DerivedParamNameIterCtx &wuDerivedParams,
127  const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams,
128  const string &preIdx,
129  const string &postIdx,
130  const string &devPrefix,
131  const std::vector<FunctionTemplate> &functions,
132  const std::string &ftype,
133  double dt);
134 
136  std::string &SDcode,
137  const SynapseGroup *sg,
138  const VarNameIterCtx &wuVars,
139  const VarNameIterCtx &wuPreVars,
140  const VarNameIterCtx &wuPostVars,
141  const DerivedParamNameIterCtx &wuDerivedParams,
142  const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams,
143  const string &preIdx,
144  const string &postIdx,
145  const string &devPrefix,
146  const std::vector<FunctionTemplate> &functions,
147  const std::string &ftype,
148  double dt);
149 
151  std::string &code,
152  const SynapseGroup *sg,
153  const VarNameIterCtx &wuPreVars,
154  const VarNameIterCtx &wuPostVars,
155  const DerivedParamNameIterCtx &wuDerivedParams,
156  const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams,
157  const string &preIdx,
158  const string &postIdx,
159  const string &devPrefix,
160  const std::vector<FunctionTemplate> &functions,
161  const std::string &ftype,
162  double dt,
163  const string &preVarPrefix = "",
164  const string &preVarSuffix = "",
165  const string &postVarPrefix = "",
166  const string &postVarSuffix = "");
167 
169  std::string &code,
170  const SynapseGroup *sg,
171  const string &preIdx,
172  const string &devPrefix,
173  const std::vector<FunctionTemplate> &functions,
174  const std::string &ftype);
175 
176 
178  std::string &code,
179  const SynapseGroup *sg,
180  const string &postIdx,
181  const string &devPrefix,
182  const std::vector<FunctionTemplate> &functions,
183  const std::string &ftype);
184 
185 std::string initNeuronVariable(
186  const NewModels::VarInit &varInit,
187  const std::string &varName,
188  const std::vector<FunctionTemplate> &functions,
189  const std::string &idx,
190  const std::string &ftype,
191  const std::string &rng);
192 
193 std::string initWeightUpdateVariable(
194  const NewModels::VarInit &varInit,
195  const std::string &varName,
196  const std::vector<FunctionTemplate> &functions,
197  const std::string &preIdx,
198  const std::string &postIdx,
199  const std::string &ftype,
200  const std::string &rng);
201 
202 std::string initSparseConnectivity(
203  const SynapseGroup &sg,
204  const std::string &addSynapseFunctionTemplate,
205  unsigned int numTrgNeurons,
206  const std::string &preIdx,
207  const std::vector<FunctionTemplate> &functions,
208  const std::string &ftype,
209  const std::string &rng);
210 
212  std::string &code,
213  const CurrentSource *sc,
214  const VarNameIterCtx &scmVars,
215  const DerivedParamNameIterCtx &scmDerivedParams,
216  const ExtraGlobalParamNameIterCtx &scmExtraGlobalParams,
217  const std::vector<FunctionTemplate> &functions,
218  const std::string &ftype,
219  const std::string &rng);
220 } // StandardSubstitions
void weightUpdateDynamics(std::string &SDcode, const SynapseGroup *sg, const VarNameIterCtx &wuVars, const VarNameIterCtx &wuPreVars, const VarNameIterCtx &wuPostVars, const DerivedParamNameIterCtx &wuDerivedParams, const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams, const string &preIdx, const string &postIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype, double dt)
Definition: standardSubstitutions.cc:273
Definition: neuronGroup.h:19
std::string initWeightUpdateVariable(const NewModels::VarInit &varInit, const std::string &varName, const std::vector< FunctionTemplate > &functions, const std::string &preIdx, const std::string &postIdx, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:436
void neuronThresholdCondition(std::string &thCode, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const DerivedParamNameIterCtx &nmDerivedParams, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Applies standard set of variable substitutions to neuron model&#39;s "threshold condition" code...
Definition: standardSubstitutions.cc:117
void weightUpdatePreSpike(std::string &code, const SynapseGroup *sg, const string &preIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype)
Definition: standardSubstitutions.cc:356
NameIterCtx< NewModels::Base::DerivedParamVec > DerivedParamNameIterCtx
Definition: standardSubstitutions.h:36
NameIterCtx< NewModels::Base::StringPairVec > VarNameIterCtx
Definition: standardSubstitutions.h:35
void postSynapseApplyInput(std::string &psCode, const SynapseGroup *sg, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const DerivedParamNameIterCtx &nmDerivedParams, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Applies standard set of variable substitutions to postsynaptic model&#39;s "apply input" code...
Definition: standardSubstitutions.cc:38
void weightUpdateSim(std::string &wCode, const SynapseGroup &sg, const VarNameIterCtx &wuVars, const VarNameIterCtx &wuPreVars, const VarNameIterCtx &wuPostVars, const DerivedParamNameIterCtx &wuDerivedParams, const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams, const string &preIdx, const string &postIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype, double dt)
Definition: standardSubstitutions.cc:233
Definition: newModels.h:36
void neuronSpikeEventCondition(std::string &eCode, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:165
Definition: standardSubstitutions.h:42
Custom iterator for iterating through the keys of containers containing pairs.
Definition: codeGenUtils.h:75
const Container container
Definition: standardSubstitutions.h:27
NameIterCtx(const Container &c)
Definition: standardSubstitutions.h:24
const NameIter nameEnd
Definition: standardSubstitutions.h:29
Definition: standardSubstitutions.h:20
Definition: synapseGroup.h:19
NameIterCtx< NewModels::Base::StringPairVec > ExtraGlobalParamNameIterCtx
Definition: standardSubstitutions.h:37
void weightUpdatePostLearn(std::string &code, const SynapseGroup *sg, const VarNameIterCtx &wuPreVars, const VarNameIterCtx &wuPostVars, const DerivedParamNameIterCtx &wuDerivedParams, const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams, const string &preIdx, const string &postIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype, double dt, const string &preVarPrefix="", const string &preVarSuffix="", const string &postVarPrefix="", const string &postVarSuffix="")
suffix to be used for postsynaptic variable accesses - typically combined with prefix to wrap in func...
Definition: standardSubstitutions.cc:315
const NameIter nameBegin
Definition: standardSubstitutions.h:28
void weightUpdateThresholdCondition(std::string &eCode, const SynapseGroup &sg, const DerivedParamNameIterCtx &wuDerivedParams, const ExtraGlobalParamNameIterCtx &wuExtraGlobalParams, const string &preIdx, const string &postIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype, double dt)
Definition: standardSubstitutions.cc:209
void postSynapseDecay(std::string &pdCode, const SynapseGroup *sg, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const DerivedParamNameIterCtx &nmDerivedParams, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Name of the RNG to use for any probabilistic operations.
Definition: standardSubstitutions.cc:82
void weightUpdatePostSpike(std::string &code, const SynapseGroup *sg, const string &postIdx, const string &devPrefix, const std::vector< FunctionTemplate > &functions, const std::string &ftype)
Definition: standardSubstitutions.cc:386
std::string initNeuronVariable(const NewModels::VarInit &varInit, const std::string &varName, const std::vector< FunctionTemplate > &functions, const std::string &idx, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:417
void currentSourceInjection(std::string &code, const CurrentSource *sc, const VarNameIterCtx &scmVars, const DerivedParamNameIterCtx &scmDerivedParams, const ExtraGlobalParamNameIterCtx &scmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:498
void neuronSim(std::string &sCode, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const DerivedParamNameIterCtx &nmDerivedParams, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:141
PairKeyConstIter< typename Container::const_iterator > NameIter
Definition: standardSubstitutions.h:22
std::string initSparseConnectivity(const SynapseGroup &sg, const std::string &addSynapseFunctionTemplate, unsigned int numTrgNeurons, const std::string &preIdx, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:457
void neuronReset(std::string &rCode, const NeuronGroup &ng, const VarNameIterCtx &nmVars, const DerivedParamNameIterCtx &nmDerivedParams, const ExtraGlobalParamNameIterCtx &nmExtraGlobalParams, const std::vector< FunctionTemplate > &functions, const std::string &ftype, const std::string &rng)
Definition: standardSubstitutions.cc:185
Definition: currentSource.h:17