43 uint32_t n_neurons_per_group;
65 params->n_neurons_per_group = params_sdram->n_values;
66 if (params_sdram->has_weights) {
67 uint32_t n_per_group =
params->n_neurons_per_group;
68 uint32_t weight_size = n_per_group * (n_per_group - 1) *
sizeof(accum);
69 params->weights = spin1_malloc(weight_size);
72 params->weights = ¶ms_sdram->weights[0];
76 *
region = ¶ms_sdram->weights[n_per_group * (n_per_group - 1)];
79 *
region = ¶ms_sdram->weights[0];
82 log_info(
"allButMe connector, n_values = %u, has_weights = %u",
params->n_neurons_per_group,
83 params_sdram->has_weights);
96static inline bool make_all_but_me_conn(accum weight,
98 uint32_t pre, uint32_t post,
unsigned long accum weight_scale,
99 accum timestep_per_delay) {
103 weight, delay, weight_scale)) {
104 log_error(
"Matrix not sized correctly!");
110static inline void div_mod(uint32_t dividend, uint32_t divisor, uint32_t *div,
112 uint32_t remainder = dividend;
114 while (remainder >= divisor) {
115 remainder -= divisor;
126 param_generator_t weight_generator, uint32_t pre_value,
127 uint32_t post_value) {
132 uint32_t post_pos = post_value;
133 if (post_value >= pre_value) {
136 if (obj->weights !=
NULL) {
137 uint32_t weight_index = (pre_value * (obj->n_neurons_per_group - 1)) + post_pos;
138 return obj->weights[weight_index];
157 void *generator, uint32_t pre_lo, uint32_t pre_hi,
158 uint32_t post_lo, uint32_t post_hi, UNUSED uint32_t post_index,
159 uint32_t post_slice_start, uint32_t post_slice_count,
160 unsigned long accum weight_scale, accum timestep_per_delay,
161 param_generator_t weight_generator, param_generator_t delay_generator,
166 uint32_t post_start = max(post_slice_start, post_lo);
167 uint32_t post_end =
min(post_slice_start + post_slice_count - 1, post_hi);
177 div_mod(post_start, obj->n_neurons_per_group, &post_group, &post_value);
182 uint32_t pre_start = pre_lo + post_group * obj->n_neurons_per_group;
183 uint32_t pre_end =
min(pre_start + obj->n_neurons_per_group, pre_hi + 1);
184 uint32_t n_values = pre_end - pre_start;
187 for (uint32_t post = post_start; post <= post_end; post++) {
188 uint32_t local_post = post - post_slice_start;
192 for (uint32_t pre_value = 0; pre_value < n_values; pre_value++) {
193 if (pre_value != post_value) {
194 uint32_t pre = pre_start + pre_value;
195 accum weight =
get_weight(obj, weight_generator, pre_value, post_value);
196 if (!make_all_but_me_conn(weight, delay_generator,
198 timestep_per_delay)) {
207 if (post_value == obj->n_neurons_per_group) {
209 pre_start += obj->n_neurons_per_group;
210 pre_end =
min(pre_start + obj->n_neurons_per_group, pre_hi + 1);
211 if (pre_start >= pre_hi) {
214 n_values = pre_end - pre_start;
static void connection_generator_all_but_me_free(void *generator)
Free the All But Me connection generator.
static void * connection_generator_all_but_me_initialise(void **region)
Initialise the all but me connection generator.
static accum get_weight(struct all_but_me *obj, param_generator_t weight_generator, uint32_t pre_value, uint32_t post_value)
static bool connection_generator_all_but_me_generate(void *generator, uint32_t pre_lo, uint32_t pre_hi, uint32_t post_lo, uint32_t post_hi, uint32_t post_index, uint32_t post_slice_start, uint32_t post_slice_count, unsigned long accum weight_scale, accum timestep_per_delay, param_generator_t weight_generator, param_generator_t delay_generator, matrix_generator_t matrix_generator)
Generate connections with the all but me connection generator.
The parameters to be passed around for this connector.
The parameters to be passed around for this connector.
void log_error(const char *message,...)
void log_info(const char *message,...)
General types associated with generators.
static uint16_t rescale_delay(accum delay, accum timestep_per_delay)
Rescales a delay to account for timesteps and type-converts it.
bool matrix_generator_write_synapse(matrix_generator_t generator, uint32_t pre_index, uint16_t post_index, accum weight, uint16_t delay, unsigned long accum weight_scale)
Write a synapse with a matrix generator.
The data for a matrix generator.
accum param_generator_generate(param_generator_t generator)
Generate value with a parameter generator.
void sark_free(void *ptr)
region
spike source array region IDs in human readable form
void spin1_memcpy(void *dst, void const *src, uint len)
static stdp_params params
Configuration parameters.