Skip to content
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

Step 2 - Variable dimensions #598

Merged
merged 60 commits into from
Jan 9, 2024
Merged

Step 2 - Variable dimensions #598

merged 60 commits into from
Jan 9, 2024

Conversation

neworderofjamie
Copy link
Contributor

@neworderofjamie neworderofjamie commented Sep 26, 2023

This is a bit of a boring internal one that was originally going to wider reaching but got de-scoped. Basically the VarAccessDuplication enumeration evolved a bit organically with GeNN 4 as I started adding reductions and custom updates and, in its previous form, didn't really make sense for custom update variables as the meaning of the various dimension flags can get ignored depending on what it's attached to.

This PR replaces VarAccessDuplication with the VarAccessDim bitfield enumeration specifying what dimensions variables have so e.g. 'normal' neuron or synapse variable now have VarAccessDim::ELEMENT| VarAccessDim::BATCH. However, specifying these at this level is really annoying and lots of permutations aren't valid in various locations. This PR redefines VarAccess in terms of valid combinations of VarAccessMode and VarAccessDim and adds CustomUpdateVarAccess which defines dimensions subtractively , starting with ORing together the dimensions of all the variables your custom update is referencing and then determine what shape each variable should be e.g. the standard custom update variable access is CustomUpdateVarAccess::READ_WRITE which is defined as VarAccessMode::READ_WRITE meaning it inherits the OR'd together dimensionality. However, CustomUpdateVarAccess::READ_ONLY_SHARED_ELEMENT is defined as VarAccessMode::READ_ONLY | VarAccessDim::ELEMENT meaning that it's dimensionality is the result of clearing the ELEMENT bit from the OR'd together dimensionality.

…s`` a ``std::optional<unsigned int>`` so ``VarAccess`` enum is only for API purposesand started inserting default access types at callsites
* Replace queries with VarAccessDim
* VarAccess is now a wrapper class around a std::variant holding NeuronVarAccess, SynapseVarAccess and std::monostate (for the defaults)
* Mostly functional aside from custom updates
* Variables always have ``CustomUpdateVarAccess`` access type
* ``getDims`` should be called on variable reference not directly on underlying variable
* moved resolution of variable dimensions into adaptor classes
* used this in generic initialisation and runner code
* tidied up variable size calculation in runner
@neworderofjamie neworderofjamie added this to the GeNN 5.0.0 milestone Sep 26, 2023
@neworderofjamie neworderofjamie removed the request for review from tnowotny October 13, 2023 16:12
@neworderofjamie neworderofjamie marked this pull request as draft October 27, 2023 08:29
* ELEMENT and BATCH dimensions
* VarAccess and CustomUpdateVarAccess
* Var and CustomUpdateVar
@codecov
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (ca12c31) 85.76% compared to head (14dca3a) 79.66%.

❗ Current head 14dca3a differs from pull request most recent head d3d12c9. Consider uploading reports for the commit d3d12c9 to get more accurate results

Additional details and impacted files
@@              Coverage Diff               @@
##           transpiler     #598      +/-   ##
==============================================
- Coverage       85.76%   79.66%   -6.11%     
==============================================
  Files              99        4      -95     
  Lines           13525      954   -12571     
==============================================
- Hits            11600      760   -10840     
+ Misses           1925      194    -1731     
Files Coverage Δ
pygenn/__init__.py 85.71% <ø> (ø)
pygenn/genn_groups.py 79.86% <97.87%> (-0.33%) ⬇️
pygenn/genn_model.py 77.98% <92.00%> (+0.51%) ⬆️

... and 95 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@neworderofjamie neworderofjamie marked this pull request as ready for review December 5, 2023 13:41
Copy link
Member

@tnowotny tnowotny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving based on our general discussion of the aims and design decisions.

Base automatically changed from transpiler to genn_5 January 9, 2024 09:07
@neworderofjamie neworderofjamie merged commit 5a18045 into genn_5 Jan 9, 2024
@neworderofjamie neworderofjamie deleted the variable_dimensions branch January 9, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants