sPyNNaker neural_modelling 7.2.2
Loading...
Searching...
No Matches
weight_additive_one_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_ONE_TERM_IMPL_H_
20#define _WEIGHT_ADDITIVE_ONE_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 {
34 accum min_weight;
35 accum max_weight;
36
37 accum a2_plus;
38 accum a2_minus;
40
50
51#include "weight_one_term.h"
52
53//---------------------------------------
54// STDP weight dependence functions
55//---------------------------------------
63 weight_t weight, index_t synapse_type) {
65 extern uint32_t *weight_shift;
66
67 accum s1615_weight = kbits(weight << weight_shift[synapse_type]);
68 return (weight_state_t) {
69 .weight = s1615_weight,
70 .weight_shift = weight_shift[synapse_type],
71 .weight_region = &plasticity_weight_region_data[synapse_type]
72 };
73}
74
75//---------------------------------------
81 weight_state_t state, int32_t a2_minus) {
82 state.weight -= mul_accum_fixed(state.weight_region->a2_minus, a2_minus);
83 state.weight = kbits(MAX(bitsk(state.weight), bitsk(state.weight_region->min_weight)));
84 return state;
85}
86
87//---------------------------------------
93 weight_state_t state, int32_t a2_plus) {
94 state.weight += mul_accum_fixed(state.weight_region->a2_plus, a2_plus);
95 state.weight = kbits(MIN(bitsk(state.weight), bitsk(state.weight_region->max_weight)));
96 return state;
97}
98
99//---------------------------------------
105static inline weight_t weight_get_final(weight_state_t state) {
106 return (weight_t) (bitsk(state.weight) >> state.weight_shift);
107}
108
109static inline void weight_decay(weight_state_t *state, int32_t decay) {
110 state->weight = mul_accum_fixed(state->weight, decay);
111}
112
113static inline accum weight_get_update(weight_state_t state) {
114 return state.weight;
115}
116
117#endif // _WEIGHT_ADDITIVE_ONE_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_one_term_apply_depression(weight_state_t state, int32_t a2_minus)
Apply the depression rule to the weight state.
static weight_state_t weight_one_term_apply_potentiation(weight_state_t state, int32_t a2_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 a2_plus
Scaling factor for weight delta on potentiation.
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 single-term weight dependence rules.