Step 4 - Replace implicit neuron variable references with explicit ones#604
Merged
neworderofjamie merged 85 commits intogenn_5from Jan 9, 2024
Merged
Step 4 - Replace implicit neuron variable references with explicit ones#604neworderofjamie merged 85 commits intogenn_5from
neworderofjamie merged 85 commits intogenn_5from
Conversation
* Options to hide (i.e. prefix with _) variables and variable references * Function to add local variable references i.e. to variables already exposed with _ prefixes
* Add fields to pointers to in backend (moved functionality out of custom connectivity update into environment to do this) * Add new sort of caching environment that reads existing (pointer) fields into local variables if referenced and use this around neuron code
…synapse update groups
…x of addSynapsePopulation
…omConnectivityUpdate`` direct from wrapper (and delay neuron group) * remove python-layer implementation of ``synapse_group`` properties
…cessible from PyGeNN so delays don't need to be wrangled
This reverts commit 16f171f.
* No weird _space in names of parameter and variable arguments to make kwarging easier
* All parameter and variable arguments default to {}
tnowotny
approved these changes
Jan 8, 2024
Member
tnowotny
left a comment
There was a problem hiding this comment.
Approving based on our general discussion of the aims and design decisions.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In the previous 3 stages of the great GeNN 5 updating, the ability to reference neuron variables in postsynaptic models, weight update models and current sources implicitly via
$(X_post)syntax was entirely disabled but this PR adds new functionality to do this explicitly via variable references. This means models are not tied together by the names of variables so e.g. you can use the standardExpCondmodel even if you have the gall to call your neuron model's voltageuor (lower-case)v.However, this was the straw that broke the camel's back of the addSynapsePopulation function as it ended up with 17 arguments. This is annoying even when using Python where there's keyword arguments so, continuing the approach used to setup connectivity, I added weight update and postsynaptic model inititialisation functions:
becomes something like:
which I think it actually a lot nicer and lets you reuse fully-configured models much easily. To further ease the pain I have shortened and unified all of the names of the keyword arguments on the
GeNNModel.add_XXXmethods and given them defaults of{}so you can more complex configurations with less{}, {}, {}nonsense! Clearly this breaks backward compatibility but updating is pretty painless, to the point I was able to update all of the unit tests and feature tests with an (admittedly absolutely nightmarish) regular expression.With that out of the way, the syntax to connect an ExpCond model back to the presynaptic neuron is simple:
Most of the bits and pieces to implement this internally were already there but some tweaks of environment classes were required to correctly setup the lazy substitutions (e.g. references to neuron variables in per-neuron weight update model code may just be aliases to local variables in the dynamics bit but, on SIMD backends, in the spike-driven bit the indices are different).
This PR also adds the ability to change which neuron input variable a current source targets (in line with postsynaptic model). Finally, this enables a whole swathe of feature tests that rely on delays (which only get applied to neuron variables if they're referenced in synaptic code) to be re-implemented in PyGeNN which led to a further wave of bug-fixing.