sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
weight_additive_two_term_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
19#ifndef _WEIGHT_ADDITIVE_TWO_TERM_IMPL_H_
20#define _WEIGHT_ADDITIVE_TWO_TERM_IMPL_H_
21
22// Include generic plasticity maths functions
25#include <neuron/synapse_row.h>
26
27#include <debug.h>
28
29//---------------------------------------
30// Structures
31//---------------------------------------
33typedef struct plasticity_weight_region_data_two_term_t {
34 accum min_weight;
35 accum max_weight;
36
37 accum a2_plus;
38 accum a2_minus;
39 accum a3_plus;
40 accum a3_minus;
42
44typedef struct weight_state_t {
45 accum weight;
46 uint32_t weight_shift;
47
51
52#include "weight_two_term.h"
53
54//---------------------------------------
55// STDP weight dependence functions
56//---------------------------------------
64 weight_t weight, index_t synapse_type) {
66 extern uint32_t *weight_shift;
67
68 accum s1615_weight = kbits(weight << weight_shift[synapse_type]);
69
70 return (weight_state_t) {
71 .weight = s1615_weight,
72 .weight_shift = weight_shift[synapse_type],
73 .weight_region = &plasticity_weight_region_data[synapse_type]
74 };
75}
76
77//---------------------------------------
84 weight_state_t state, int32_t a2_minus, int32_t a3_minus) {
85 state.weight -= mul_accum_fixed(state.weight_region->a2_minus, a2_minus);
86 state.weight -= mul_accum_fixed(state.weight_region->a3_minus, a3_minus);
87 state.weight = kbits(MAX(bitsk(state.weight), bitsk(state.weight_region->min_weight)));
88 return state;
89}
90
91//---------------------------------------
98 weight_state_t state, int32_t a2_plus, int32_t a3_plus) {
99 state.weight += mul_accum_fixed(state.weight_region->a2_plus, a2_plus);
100 state.weight += mul_accum_fixed(state.weight_region->a3_plus, a3_plus);
101 state.weight = kbits(MIN(bitsk(state.weight), bitsk(state.weight_region->max_weight)));
102 return state;
103}
104
105//---------------------------------------
111static inline weight_t weight_get_final(weight_state_t state) {
112 return (weight_t) (bitsk(state.weight) >> state.weight_shift);
113}
114
115static inline void weight_decay(weight_state_t *state, int32_t decay) {
116 state->weight = mul_accum_fixed(state->weight, decay);
117}
118
119static inline accum weight_get_update(weight_state_t state) {
120 return state.weight;
121}
122
123#endif // _WEIGHT_ADDITIVE_TWO_TERM_IMPL_H_
uint32_t index_t
#define decay(x, d)
This is a type-generic decay "function".
Definition decay.h:118
Support functions for STDP.
#define MIN(X, Y)
Minimum. Evaluates arguments twice.
Definition maths.h:34
#define MAX(X, Y)
Maximum. Evaluates arguments twice.
Definition maths.h:39
Basic definitions for STDP.
static accum mul_accum_fixed(accum a, int32_t stdp_fixed)
Multiply an accum by an STDP fixed point and return an accum.
implementation for handling the processing of synapse rows.
uint32_t * weight_shift
Plasticity multiply shift array, in DTCM.
plasticity_weight_region_data_t * plasticity_weight_region_data
Global plasticity parameter data.
static weight_state_t weight_get_initial(weight_t weight, index_t synapse_type)
Gets the initial weight state.
static weight_state_t weight_two_term_apply_depression(weight_state_t state, int32_t a2_minus, int32_t a3_minus)
Apply the depression rule to the weight state.
static weight_state_t weight_two_term_apply_potentiation(weight_state_t state, int32_t a2_plus, int32_t a3_plus)
Apply the potentiation rule to the weight state.
static weight_t weight_get_final(weight_state_t state)
Gets the final weight.
const plasticity_weight_region_data_t * weight_region
Reference to the configuration data.
accum a3_plus
Scaling factor for weight delta on potentiation.
accum a2_plus
Scaling factor for weight delta on potentiation.
accum a3_minus
Scaling factor for weight delta on depression.
accum a2_minus
Scaling factor for weight delta on depression.
accum weight
The starting weight.
uint32_t weight_shift
Weight shift to S1615 version.
The current state data for the rule.
API for dual-term weight dependence rules.