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

Weight scale #852

Open
wants to merge 207 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 130 commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
5391c7d
Change the C code to take a minimum weight rather than a shift
rowleya Apr 8, 2020
14d97fb
First go at Python code (runs through)
rowleya Apr 8, 2020
4457b0d
Merge branch 'master' into weight_scale
rowleya Apr 30, 2020
ddb6380
Add required argument
rowleya Apr 30, 2020
76c9ffa
Min weight could be 0
rowleya Apr 30, 2020
781a86c
Use closest representable value for minimum weight to avoid issues
rowleya May 1, 2020
e72e0b1
Be careful if the minimum representable rounds to 0!
rowleya May 1, 2020
bc6fecd
Return the minimum
rowleya May 1, 2020
46352b6
Support empty from-list again
rowleya May 1, 2020
f49bff3
Push get_weight_minimum down to the connector
rowleya May 1, 2020
15827e0
Fix missing arguments
rowleya May 1, 2020
ad425fc
Add new option
rowleya May 1, 2020
8a19139
Fix super call
rowleya May 1, 2020
008e07c
Use to remove warning
rowleya May 1, 2020
38b21b0
flake8
rowleya May 1, 2020
9ddc30b
Call super
rowleya May 1, 2020
359fe5f
Ignore unused
rowleya May 1, 2020
a144390
Remove unused method
rowleya May 1, 2020
deec0db
Ignore unused
rowleya May 1, 2020
0c3b83c
We also need representable values for 1/w
rowleya May 1, 2020
5c6c852
Get minimum weight from Kernel connector
rowleya May 1, 2020
0aaeef1
Make sure the min weight and the scale stay related
rowleya May 1, 2020
1b8782b
It looks like we can't avoid updating all the connectors
rowleya May 4, 2020
873d267
Split the minimum weight and minimum weight change
rowleya May 4, 2020
c85667d
Add new config options
rowleya May 12, 2020
c6eb630
Flake8 fix
rowleya May 12, 2020
f1234c7
Different way of doing minimum weights
rowleya May 12, 2020
f11099a
Merge branch 'master' into weight_scale
rowleya May 18, 2020
4a93898
Support better minimum weight calculation and provenance gathering
rowleya May 19, 2020
3df29fd
Fix provenance
rowleya May 19, 2020
b944223
Return the provenance
rowleya May 19, 2020
1284951
Fix unit tests
rowleya May 20, 2020
ad128f8
Need to pass the parameters!
rowleya May 20, 2020
25cd5ca
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 28, 2020
d4132ff
flake8 line lengths, unused imports
andrewgait Jul 28, 2020
20d210a
Updates to fix integration tests, particularly for kernel connectors
andrewgait Jul 30, 2020
be89efd
Deal with array length of 1
andrewgait Jul 30, 2020
979891a
flake8 whitespaces
andrewgait Jul 30, 2020
459ff56
Check representable weights properly when weight_scale isn't 1
andrewgait Jul 31, 2020
780d513
Also need to use (float) gcd in STDP cases for better representation
andrewgait Jul 31, 2020
8a4991d
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Aug 20, 2020
01a55b4
Again Python 2 appears to be doing something weird
andrewgait Aug 20, 2020
9851271
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 1, 2020
b3da07b
Got the merge slightly wrong...
andrewgait Sep 1, 2020
16bad5d
Wrong argument again...
andrewgait Sep 1, 2020
611148f
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 10, 2020
fb027ec
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 15, 2020
5db07d9
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 17, 2020
baf36a1
Use a better tolerance for float gcd, and give constant a name
andrewgait Sep 17, 2020
4627b95
flake8 unused import
andrewgait Sep 17, 2020
687f791
Get closest representable weight before doing gcd, edit tolerance
andrewgait Sep 18, 2020
b817ead
Fiddle with tolerance again
andrewgait Sep 18, 2020
e764529
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Oct 6, 2020
9e5ac2a
Avoid dividing by zero...
andrewgait Oct 6, 2020
d42a790
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Oct 15, 2020
15be8d3
flake8 sort imports out
andrewgait Oct 15, 2020
4547624
Missing arguments in unittest functions
andrewgait Oct 15, 2020
0b67f24
Update to work properly for cases with multiple edges into same vertex
andrewgait Oct 16, 2020
ce0f603
Smarter multiplication needed...
andrewgait Oct 20, 2020
7f8098a
Update to fix STDP examples
andrewgait Oct 20, 2020
04782bc
Seriously...
andrewgait Oct 20, 2020
156a8e0
Another one to stop python 2.7 complaining
andrewgait Oct 20, 2020
4397eef
Calculation should happen after checking None / zero
andrewgait Oct 21, 2020
b6f2734
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jan 15, 2021
4dc0659
flake8 unused import
andrewgait Jan 15, 2021
e182a42
missing argument
andrewgait Jan 15, 2021
2a39154
Attempt to bypass python2 issue
andrewgait Jan 15, 2021
7501669
Helps if you actually write what you meant to... and, not or...
andrewgait Jan 15, 2021
898651e
Fix multiplicative STDP rule
andrewgait Jan 19, 2021
d44b9e7
Try this tolerance instead... ?
andrewgait Jan 19, 2021
9a642f2
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 5, 2021
87f4900
missed these when merging
andrewgait Feb 5, 2021
f9008a5
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 26, 2021
18d3268
flake8 imports
andrewgait Mar 1, 2021
cb2a3ce
Further tidying up
andrewgait Mar 1, 2021
0964a1e
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Mar 30, 2021
dda8431
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Apr 13, 2021
68fd70d
Don't need to check weight if using distance-dependent; fix test
andrewgait Apr 13, 2021
3f1ab5d
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Apr 29, 2021
3aa4ef5
Missed a removed config
andrewgait Apr 29, 2021
03c2d34
Actually import function
andrewgait Apr 29, 2021
f16aee3
Use get_config_str instead?
andrewgait Apr 29, 2021
d57a79f
Switch to get_config_float for these parameters
andrewgait Apr 29, 2021
3ac340c
Merge branch 'master' into weight_scale
andrewgait Apr 29, 2021
e2b5475
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jun 10, 2021
40e3610
Unneeded argument
andrewgait Jun 10, 2021
e641aef
Argument left in here too somehow; removed
andrewgait Jun 10, 2021
9c6d00a
flake8 unused imports; replace get_simulator
andrewgait Jun 10, 2021
426b944
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 9, 2021
6f4f681
Use correct arguments in create_vertex
andrewgait Jul 9, 2021
d00063f
doc fix
andrewgait Jul 9, 2021
dcfa118
try this doc fix instead
andrewgait Jul 9, 2021
3728d61
It might be these docs that are wrong instead
andrewgait Jul 9, 2021
4cd4d9f
I guess this doc isn't actually necessary...
andrewgait Jul 9, 2021
44b05c8
Merge branch 'master' into weight_scale
andrewgait Jul 9, 2021
1f5f197
These tolerances / constants seem to strike the right balance for now
andrewgait Jul 29, 2021
6a579ca
Reset min_weights after connection cache is cleared
andrewgait Jul 29, 2021
27736f8
Only reset min_weights if requried to do so
andrewgait Jul 30, 2021
c976494
Merge branch 'master' into weight_scale
andrewgait Aug 24, 2021
f16511d
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Oct 7, 2021
1421414
Do the minimum weight calculation for RandomDistributions better
andrewgait Oct 11, 2021
130f2b8
Use the maximum weight if necessary in the minimum weight calculation
andrewgait Oct 12, 2021
f4d2bcd
Better choice of tolerance for microcircuit that still works with STDP
andrewgait Oct 18, 2021
5205b70
Merge branch 'master' into weight_scale
andrewgait Oct 18, 2021
587b489
Tolerance shouldn't be lower than smallest representable value
andrewgait Oct 18, 2021
368951b
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Oct 27, 2021
b8a6581
Remove print statement
andrewgait Oct 28, 2021
abb3b13
Merge branch 'master' into weight_scale
andrewgait Nov 2, 2021
cf89bbe
Merge branch 'master' into weight_scale
andrewgait Nov 2, 2021
a1deebc
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
5cae4e2
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
960b452
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 8, 2021
fa1e909
Fix STDP weight rules; works for current-based neurons...
andrewgait Nov 10, 2021
2e8179c
Merge branch 'master' into weight_scale
andrewgait Nov 10, 2021
2e2428d
Merge branch 'master' into weight_scale
andrewgait Nov 11, 2021
dd9f02d
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 25, 2021
8751d8d
Merge branch 'master' into weight_scale
andrewgait Jan 10, 2022
efa4d56
Merge branch 'master' into weight_scale
andrewgait Feb 25, 2022
29e72f8
Merge branch 'master' into weight_scale
andrewgait Mar 11, 2022
2299939
Merge branch 'master' into weight_scale
andrewgait Mar 28, 2022
cb19247
Merge branch 'master' into weight_scale
andrewgait Apr 14, 2022
af03b49
Merge branch 'master' into weight_scale
andrewgait Apr 20, 2022
5c17e82
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Apr 21, 2022
3c4430a
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait May 9, 2022
2f9a312
Merge branch 'master' into weight_scale
andrewgait May 19, 2022
97bff12
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait May 20, 2022
20130b5
Switch to using less current source ITCM in larger binary cases
andrewgait May 20, 2022
d6a0cfb
Merge branch 'master' into weight_scale
andrewgait May 20, 2022
d841462
Switch some makefiles to step-only CS since DC is a subset of Step
andrewgait May 23, 2022
6d1f472
Oops, too big
andrewgait May 23, 2022
d194eb7
Don't use config for min_weight; move to (pop) additional_parameters
andrewgait May 25, 2022
ab813da
remove unused import
andrewgait May 25, 2022
7829121
Add doc back in
andrewgait May 25, 2022
5d781fe
Merge branch 'master' into weight_scale
andrewgait May 25, 2022
bf997b6
Simplify
andrewgait May 25, 2022
6d99601
Move specific min weight calculations from vertex to synapse dynamics
andrewgait May 26, 2022
c5f7a75
Remove no longer used imports and add missing line at end of file
andrewgait May 26, 2022
6be8bb6
Remove commented out code
andrewgait May 26, 2022
c17a073
Test via tolerance rather than using adjustment from code function
andrewgait May 26, 2022
a599cbe
Remove unused import
andrewgait May 26, 2022
9a75735
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jun 16, 2022
30f7c1a
Merge branch 'master' into weight_scale
andrewgait Jun 17, 2022
c53f6f6
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 11, 2022
bad2c1a
Missed in merge
andrewgait Jul 11, 2022
471251b
reduce binary size
andrewgait Jul 11, 2022
7f65411
w_max no longer needed here
andrewgait Jul 11, 2022
32ca82c
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 22, 2022
8d63c76
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Aug 3, 2022
e279e00
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Aug 4, 2022
9684999
Merge branch 'master' into weight_scale
andrewgait Aug 4, 2022
021bffb
Merge branch 'master' into weight_scale
andrewgait Aug 22, 2022
7809948
Merge branch 'master' into weight_scale
andrewgait Aug 31, 2022
f696f04
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 9, 2022
4fc7cf8
flake8
andrewgait Sep 9, 2022
3848c81
more linting
andrewgait Sep 9, 2022
1523ae8
Override get_weight_minimum for new kernel-based connectors
andrewgait Sep 12, 2022
7cb9898
Update comment
andrewgait Sep 12, 2022
d197122
Fix min_weight calculation for local-only case
andrewgait Sep 14, 2022
0f62aa8
Merge branch 'master' into weight_scale
andrewgait Sep 14, 2022
65eae83
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 15, 2022
040382f
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 16, 2022
0d78f41
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 27, 2022
ed4912c
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 27, 2022
d855623
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 18, 2022
6b23dbe
Comment out unnecessary printing
andrewgait Nov 18, 2022
6261369
flake8 sort out imports
andrewgait Nov 18, 2022
b205190
Reduce ITCM further...
andrewgait Nov 18, 2022
7ecb575
See if this helps with ITCM
andrewgait Nov 18, 2022
2022748
Reduce ITCM by using min_weight reciprocal
andrewgait Nov 22, 2022
2c4bfcd
vera line length, and change info to debug
andrewgait Nov 22, 2022
16ccb43
Vera line length and tidy up
andrewgait Nov 22, 2022
a624e57
More tidying up
andrewgait Nov 22, 2022
f6754fe
Remove unneeded check in alpha synapse
andrewgait Nov 22, 2022
a8d864b
Trying to save more ITCM
andrewgait Nov 22, 2022
d3d745d
Yet more ITCM savings...
andrewgait Nov 22, 2022
514c8c8
Saving more ITCM...
andrewgait Nov 22, 2022
aab7916
Simplify code on machine to only split array when needed
andrewgait Nov 23, 2022
de09312
Add missing check to _get_weight_maximum
andrewgait Nov 24, 2022
e874b99
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 24, 2022
5e16ddc
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jan 11, 2023
768e721
Merge branch 'master' into weight_scale
andrewgait Jan 11, 2023
94f97a9
pylint is now more strict
andrewgait Jan 12, 2023
7ed6b66
Merge branch 'weight_scale' of https://github.com/SpiNNakerManchester…
andrewgait Jan 12, 2023
a430559
Merge branch 'master' into weight_scale
andrewgait Jan 12, 2023
e73f796
Merge branch 'master' into weight_scale
andrewgait Jan 24, 2023
8308d03
Merge branch 'master' into weight_scale
andrewgait Jan 27, 2023
e8f49fb
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 10, 2023
d3e4fe5
pylint fix exception
andrewgait Feb 10, 2023
bff3186
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 20, 2023
9ee5037
Merge branch 'master' into weight_scale
andrewgait Mar 1, 2023
5d26f57
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Apr 11, 2023
f9720f6
Fix doc error
andrewgait Apr 11, 2023
badb25e
Merge branch 'master' into weight_scale
andrewgait Apr 21, 2023
19df82d
Remove debug print statements
andrewgait Apr 21, 2023
62f68bb
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait May 17, 2023
fac0eba
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jun 23, 2023
3a71b6e
DataType is now in FrontEndCommon
andrewgait Jun 23, 2023
9ac6bb8
Upgrade actions OS (to use a newer compiler)
andrewgait Jun 23, 2023
7460fb8
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 6, 2023
92d0434
Merge branch 'master' into weight_scale
andrewgait Jul 17, 2023
a93fa13
Merge branch 'master' into weight_scale
andrewgait Jul 18, 2023
023c68e
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 21, 2023
7d4dd15
Merge branch 'master' into weight_scale
andrewgait Aug 2, 2023
12144b7
flake8
andrewgait Aug 2, 2023
3890ee6
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 12, 2023
6d8cd64
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 26, 2023
d009719
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ APP = $(notdir $(CURDIR))
NEURON_MODEL = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.c
NEURON_MODEL_H = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.h
INPUT_TYPE_H = $(NEURON_DIR)/neuron/input_types/input_type_conductance.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_stepnoisy_impl.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_step_only_impl.h
NEURON_IMPL_H = $(NEURON_DIR)/neuron/implementations/neuron_impl_standard.h
THRESHOLD_TYPE_H = $(NEURON_DIR)/neuron/threshold_types/threshold_type_static.h
SYNAPSE_TYPE_H = $(NEURON_DIR)/neuron/synapse_types/synapse_types_exponential_impl.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ APP = $(notdir $(CURDIR))
NEURON_MODEL = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.c
NEURON_MODEL_H = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.h
INPUT_TYPE_H = $(NEURON_DIR)/neuron/input_types/input_type_conductance.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_ac_only_impl.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_step_only_impl.h
NEURON_IMPL_H = $(NEURON_DIR)/neuron/implementations/neuron_impl_standard.h
THRESHOLD_TYPE_H = $(NEURON_DIR)/neuron/threshold_types/threshold_type_static.h
SYNAPSE_TYPE_H = $(NEURON_DIR)/neuron/synapse_types/synapse_types_exponential_impl.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ APP = $(notdir $(CURDIR))
NEURON_MODEL = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.c
NEURON_MODEL_H = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.h
INPUT_TYPE_H = $(NEURON_DIR)/neuron/input_types/input_type_conductance.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_dc_only_impl.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_step_only_impl.h
NEURON_IMPL_H = $(NEURON_DIR)/neuron/implementations/neuron_impl_standard.h
THRESHOLD_TYPE_H = $(NEURON_DIR)/neuron/threshold_types/threshold_type_static.h
SYNAPSE_TYPE_H = $(NEURON_DIR)/neuron/synapse_types/synapse_types_exponential_impl.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ APP = $(notdir $(CURDIR))
NEURON_MODEL = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.c
NEURON_MODEL_H = $(NEURON_DIR)/neuron/models/neuron_model_lif_impl.h
INPUT_TYPE_H = $(NEURON_DIR)/neuron/input_types/input_type_current.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_noisy_only_impl.h
CURRENT_SOURCE_H = $(NEURON_DIR)/neuron/current_sources/current_source_dc_only_impl.h
NEURON_IMPL_H = $(NEURON_DIR)/neuron/implementations/neuron_impl_standard.h
THRESHOLD_TYPE_H = $(NEURON_DIR)/neuron/threshold_types/threshold_type_static.h
SYNAPSE_TYPE_H = $(NEURON_DIR)/neuron/synapse_types/synapse_types_exponential_impl.h
Expand Down
7 changes: 3 additions & 4 deletions neural_modelling/src/neuron/c_main_synapse_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,12 @@ static inline bool initialise_synapse_regions(
bool *clear_input_buffer_of_late_packets,
uint32_t *n_recording_regions_used) {
// Set up the synapses
uint32_t *ring_buffer_to_input_buffer_left_shifts;
REAL *min_weights;
uint32_t n_neurons;
uint32_t n_synapse_types;
if (!synapses_initialise(
data_specification_get_region(regions.synapse_params, ds_regions),
&n_neurons, &n_synapse_types, ring_buffers,
&ring_buffer_to_input_buffer_left_shifts,
&n_neurons, &n_synapse_types, ring_buffers, &min_weights,
clear_input_buffer_of_late_packets,
incoming_spike_buffer_size)) {
return false;
Expand All @@ -130,7 +129,7 @@ static inline bool initialise_synapse_regions(
// Set up the synapse dynamics
if (!synapse_dynamics_initialise(
data_specification_get_region(regions.synapse_dynamics, ds_regions),
n_neurons, n_synapse_types, ring_buffer_to_input_buffer_left_shifts)) {
n_neurons, n_synapse_types, min_weights)) {
return false;
}

Expand Down
29 changes: 15 additions & 14 deletions neural_modelling/src/neuron/neuron.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ static uint32_t n_neurons_peak;
//! The number of synapse types
static uint32_t n_synapse_types;

//! Amount to left shift the ring buffer by to make it an input
static uint32_t *ring_buffer_to_input_left_shifts;
////! Amount to left shift the ring buffer by to make it an input
//static uint32_t *ring_buffer_to_input_left_shifts;

//! Minimum weight value
static REAL *min_weights;

//! The address where the actual neuron parameters start
static address_t saved_params_address;
Expand All @@ -65,7 +68,7 @@ struct neuron_parameters {
uint32_t n_neurons_to_simulate;
uint32_t n_neurons_peak;
uint32_t n_synapse_types;
uint32_t ring_buffer_shifts[];
REAL min_weights[];
};

//! \brief does the memory copy for the neuron parameters
Expand Down Expand Up @@ -124,20 +127,18 @@ bool neuron_initialise(
n_synapse_types = params->n_synapse_types;

// Set up ring buffer left shifts
uint32_t ring_buffer_bytes = n_synapse_types * sizeof(uint32_t);
ring_buffer_to_input_left_shifts = spin1_malloc(ring_buffer_bytes);
if (ring_buffer_to_input_left_shifts == NULL) {
log_error("Not enough memory to allocate ring buffer");
uint32_t min_weights_bytes = n_synapse_types * sizeof(REAL);
min_weights = spin1_malloc(min_weights_bytes);
if (min_weights == NULL) {
log_error("Not enough memory to allocate min_weights");
return false;
}

// read in ring buffer to input left shifts
spin1_memcpy(
ring_buffer_to_input_left_shifts, params->ring_buffer_shifts,
ring_buffer_bytes);
// read in min_weights
spin1_memcpy(min_weights, params->min_weights, min_weights_bytes);

// Store where the actual neuron parameters start
saved_params_address = &params->ring_buffer_shifts[n_synapse_types];
saved_params_address = (address_t) &(params->min_weights[n_synapse_types]);
current_source_address = cs_address;

log_info("\t n_neurons = %u, peak %u, n_synapse_types %u",
Expand Down Expand Up @@ -198,7 +199,7 @@ void neuron_transfer(weight_t *syns) { // EXPORTED
uint32_t synapse_index = 0;
uint32_t ring_buffer_index = 0;
for (uint32_t s_i = n_synapse_types; s_i > 0; s_i--) {
uint32_t rb_shift = ring_buffer_to_input_left_shifts[synapse_index];
REAL min_weight = min_weights[synapse_index];
uint32_t neuron_index = 0;
for (uint32_t n_i = n_neurons_peak; n_i > 0; n_i--) {
weight_t value = syns[ring_buffer_index];
Expand All @@ -208,7 +209,7 @@ void neuron_transfer(weight_t *syns) { // EXPORTED
rt_error(RTE_SWERR);
}
input_t val_to_add = synapse_row_convert_weight_to_input(
value, rb_shift);
value, min_weight);
neuron_impl_add_inputs(synapse_index, neuron_index, val_to_add);
}
syns[ring_buffer_index] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static uint32_t plastic_saturation_count = 0;

static inline bool synapse_dynamics_stdp_init(
address_t *address, stdp_params *params, uint32_t n_synapse_types,
uint32_t *ring_buffer_to_input_buffer_left_shifts) {
REAL *min_weights) {

// Load parameters
stdp_params *sdram_params = (stdp_params *) *address;
Expand All @@ -128,8 +128,7 @@ static inline bool synapse_dynamics_stdp_init(

// Load weight dependence data
address_t weight_result = weight_initialise(
weight_region_address, n_synapse_types,
ring_buffer_to_input_buffer_left_shifts);
weight_region_address, n_synapse_types, min_weights);
if (weight_result == NULL) {
return false;
}
Expand All @@ -145,10 +144,10 @@ static inline bool synapse_dynamics_stdp_init(
void synapse_dynamics_print_plastic_synapses(
synapse_row_plastic_data_t *plastic_region_data,
synapse_row_fixed_part_t *fixed_region,
uint32_t *ring_buffer_to_input_buffer_left_shifts) {
accum *min_weights) {
__use(plastic_region_data);
__use(fixed_region);
__use(ring_buffer_to_input_buffer_left_shifts);
__use(min_weights);

#if LOG_LEVEL >= LOG_DEBUG
// Extract separate arrays of weights (from plastic region),
Expand All @@ -175,7 +174,7 @@ void synapse_dynamics_print_plastic_synapses(

log_debug("%08x [%3d: (w: %5u (=", control_word, i, weight);
synapses_print_weight(
weight, ring_buffer_to_input_buffer_left_shifts[synapse_type]);
weight, min_weights[synapse_type]);
log_debug("nA) d: %2u, %s, n = %3u)] - {%08x %08x}\n",
synapse_row_sparse_delay(control_word, synapse_type_index_bits, synapse_delay_mask),
synapse_types_get_type_char(synapse_type),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef struct neuromodulated_synapse_t {

typedef struct nm_update_state_t {
accum weight;
uint32_t weight_shift;
REAL min_weight;
update_state_t eligibility_state;
} nm_update_state_t;

Expand Down Expand Up @@ -75,7 +75,7 @@ static int16_lut *tau_c_lookup;

static int16_lut *tau_d_lookup;

static uint32_t *nm_weight_shift;
static REAL *nm_min_weight;

#define DECAY_LOOKUP_TAU_C(time) \
maths_lut_exponential_decay(time, tau_c_lookup)
Expand All @@ -84,10 +84,13 @@ static uint32_t *nm_weight_shift;

static inline nm_update_state_t get_nm_update_state(
neuromodulated_synapse_t synapse, index_t synapse_type) {
accum s1615_weight = kbits(synapse.weight << nm_weight_shift[synapse_type]);
uint64_t mw = (uint64_t) bitsk(nm_min_weight[synapse_type]);
uint64_t w = (uint64_t) (synapse.weight);

accum s1615_weight = kbits((int_k_t) mw * w);
nm_update_state_t update_state = {
.weight=s1615_weight,
.weight_shift=nm_weight_shift[synapse_type],
.min_weight=nm_min_weight[synapse_type],
.eligibility_state=synapse_structure_get_update_state(
synapse.eligibility_synapse, synapse_type)
};
Expand All @@ -101,7 +104,7 @@ static inline nm_final_state_t get_nm_final_state(
update_state.weight = kbits(MIN(bitsk(update_state.weight),
bitsk(nm_params.max_weight)));
nm_final_state_t final_state = {
.weight=(weight_t) (bitsk(update_state.weight) >> update_state.weight_shift),
.weight=(weight_t) (bitsk(update_state.weight) / bitsk(update_state.min_weight)),
.final_state=synapse_structure_get_final_state(
update_state.eligibility_state)
};
Expand Down Expand Up @@ -274,10 +277,10 @@ static inline nm_final_state_t izhikevich_neuromodulation_plasticity_update_syna

bool synapse_dynamics_initialise(
address_t address, uint32_t n_neurons, uint32_t n_synapse_types,
uint32_t *ring_buffer_to_input_buffer_left_shifts) {
REAL *min_weights) {

if (!synapse_dynamics_stdp_init(&address, &params, n_synapse_types,
ring_buffer_to_input_buffer_left_shifts)) {
if (!synapse_dynamics_stdp_init(
&address, &params, n_synapse_types, min_weights)) {
return false;
}

Expand All @@ -299,15 +302,15 @@ bool synapse_dynamics_initialise(
tau_c_lookup = maths_copy_int16_lut(&lut_address);
tau_d_lookup = maths_copy_int16_lut(&lut_address);

// Store weight shifts
nm_weight_shift = spin1_malloc(sizeof(uint32_t) * n_synapse_types);
if (nm_weight_shift == NULL) {
log_error("Could not initialise weight region data");
// Store min weights
nm_min_weight = spin1_malloc(sizeof(REAL) * n_synapse_types);
if (nm_min_weight == NULL) {
log_error("Could not initialise min weight region data");
return NULL;
}
for (uint32_t s = 0; s < n_synapse_types; s++) {
nm_weight_shift[s] = ring_buffer_to_input_buffer_left_shifts[s];
log_info("Weight shift %u = %u", s, nm_weight_shift[s]);
nm_min_weight[s] = min_weights[s];
log_info("Min weight %u = %k", s, nm_min_weight[s]);
}

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ static inline final_state_t plasticity_update_synapse(

bool synapse_dynamics_initialise(
address_t address, uint32_t n_neurons, uint32_t n_synapse_types,
uint32_t *ring_buffer_to_input_buffer_left_shifts) {
REAL *min_weights) {

if (!synapse_dynamics_stdp_init(&address, &params, n_synapse_types,
ring_buffer_to_input_buffer_left_shifts)) {
if (!synapse_dynamics_stdp_init(
&address, &params, n_synapse_types, min_weights)) {
return false;
}

Expand All @@ -132,7 +132,6 @@ static inline index_t sparse_axonal_delay(uint32_t x) {
#endif
}

//---------------------------------------
void synapse_dynamics_process_post_synaptic_event(
uint32_t time, index_t neuron_index) {
log_debug("Adding post-synaptic event to trace at time:%u", time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@
* \param[in] address: the absolute address in SRAM where the weight parameters
* are stored.
* \param[in] n_synapse_types: The number of synapse types
* \param[in] ring_buffer_to_input_buffer_left_shifts: how much a value needs
* to be shifted in the left direction to support comprises with fixed
* point arithmetic
* \param[in] min_weights: The value of the weight of the LSB of the weight
* \return the end of the weight region as an absolute SDRAM memory address.
*/
address_t weight_initialise(
address_t address, uint32_t n_synapse_types,
uint32_t *ring_buffer_to_input_buffer_left_shifts);
address_t address, uint32_t n_synapse_types, REAL *min_weights);

/*!
* \brief Gets the initial weight state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
//! Global plasticity parameter data
plasticity_weight_region_data_t *plasticity_weight_region_data;

//! Plasticity multiply shift array, in DTCM
uint32_t *weight_shift;
//! Plasticity min_weight array, in DTCM
REAL *min_weight;

//! \brief How the configuration data for additive_one_term is laid out in
//! SDRAM. The layout is an array of these.
Expand All @@ -41,8 +41,7 @@ typedef struct {
// Functions
//---------------------------------------
address_t weight_initialise(
address_t address, uint32_t n_synapse_types,
UNUSED uint32_t *ring_buffer_to_input_buffer_left_shifts) {
address_t address, uint32_t n_synapse_types, REAL *min_weights) {
log_debug("weight_initialise: starting");
log_debug("\tSTDP additive one-term weight dependence");

Expand All @@ -57,8 +56,8 @@ address_t weight_initialise(
return NULL;
}

weight_shift = spin1_malloc(sizeof(uint32_t) * n_synapse_types);
if (weight_shift == NULL) {
min_weight = spin1_malloc(sizeof(REAL) * n_synapse_types);
if (min_weight == NULL) {
log_error("Could not initialise weight region data");
return NULL;
}
Expand All @@ -69,12 +68,11 @@ address_t weight_initialise(
dtcm_copy[s].a2_plus = config->a2_plus;
dtcm_copy[s].a2_minus = config->a2_minus;

// Copy weight shift
weight_shift[s] = ring_buffer_to_input_buffer_left_shifts[s];
min_weight[s] = min_weights[s];

log_debug("\tSynapse type %u: Min weight:%k, Max weight:%k, A2+:%k, A2-:%k",
log_info("\tSynapse type %u: Min weight:%k, Max weight:%k, A2+:%k, A2-:%k min_weight %k",
s, dtcm_copy[s].min_weight, dtcm_copy[s].max_weight,
dtcm_copy[s].a2_plus, dtcm_copy[s].a2_minus);
dtcm_copy[s].a2_plus, dtcm_copy[s].a2_minus, min_weight[s]);
}
log_debug("weight_initialise: completed successfully");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct {
typedef struct {
accum weight; //!< The starting weight

uint32_t weight_shift; //!< Weight shift to S1615 version
REAL min_weight; //!< Min weight

//! Reference to the configuration data
const plasticity_weight_region_data_t *weight_region;
Expand All @@ -60,15 +60,18 @@ typedef struct {
* \param[in] synapse_type: The type of synapse involved
* \return The initial weight state.
*/
static inline weight_state_t weight_get_initial(
weight_t weight, index_t synapse_type) {
static inline weight_state_t weight_get_initial(weight_t weight, index_t synapse_type) {
extern plasticity_weight_region_data_t *plasticity_weight_region_data;
extern uint32_t *weight_shift;
extern REAL *min_weight;

uint64_t mw = (uint64_t) bitsk(min_weight[synapse_type]);
uint64_t w = (uint64_t) (weight);

accum s1615_weight = kbits((int_k_t) mw * w);

accum s1615_weight = kbits(weight << weight_shift[synapse_type]);
return (weight_state_t) {
.weight = s1615_weight,
.weight_shift = weight_shift[synapse_type],
.min_weight = min_weight[synapse_type],
.weight_region = &plasticity_weight_region_data[synapse_type]
};
}
Expand Down Expand Up @@ -104,7 +107,7 @@ static inline weight_state_t weight_one_term_apply_potentiation(
* \return The new weight.
*/
static inline weight_t weight_get_final(weight_state_t state) {
return (weight_t) (bitsk(state.weight) >> state.weight_shift);
return (weight_t) (bitsk(state.weight) / bitsk(state.min_weight));
}

static inline void weight_decay(weight_state_t *state, int32_t decay) {
Expand Down
Loading