sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
connection_generator_one_to_one.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 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
23
31
32 log_debug("One to one connector");
33
34 return NULL;
35}
36
41static void connection_generator_one_to_one_free(UNUSED void *generator) {
42 // Nothing to do
43}
44
65 UNUSED void *generator, uint32_t pre_lo, uint32_t pre_hi,
66 uint32_t post_lo, uint32_t post_hi, UNUSED uint32_t post_index,
67 uint32_t post_slice_start, uint32_t post_slice_count,
68 unsigned long accum weight_scale, accum timestep_per_delay,
69 param_generator_t weight_generator, param_generator_t delay_generator,
70 matrix_generator_t matrix_generator) {
71
72 // First check if any of the range to generate is on this slice
73 uint32_t post_slice_end = post_slice_start + post_slice_count - 1;
74 if (post_lo > post_slice_end || post_hi < post_slice_start) {
75 return true;
76 }
77
78 // Find the start and end on the current slice
79 uint32_t post_start = max(post_slice_start, post_lo);
80 uint32_t post_end = min(post_slice_end, post_hi);
81
82 // Find the offset and length on the current slice
83 uint32_t offset = post_start - post_lo;
84 uint32_t length = post_end - post_start;
85
86 // Work out the pre start and end to be generated
87 uint32_t pre_start = pre_lo + offset;
88 uint32_t pre_end = min(pre_start + length, pre_hi);
89
90 for (uint32_t pre = pre_start, post = post_start; pre <= pre_end; pre++, post++) {
91 uint32_t local_post = post - post_slice_start;
92 accum weight = param_generator_generate(weight_generator);
93 uint16_t delay = rescale_delay(
94 param_generator_generate(delay_generator), timestep_per_delay);
96 weight, delay, weight_scale)) {
97 log_error("Matrix size is wrong!");
98 return false;
99 }
100 }
101 return true;
102}
static bool connection_generator_one_to_one_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 one-to-one connection generator.
static void connection_generator_one_to_one_free(void *generator)
Free the one-to-one connection generator.
static void * connection_generator_one_to_one_initialise(void **region)
Initialise the one-to-one connection generator.
void log_error(const char *message,...)
void log_debug(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.
region
spike source array region IDs in human readable form
#define NULL
#define min(a, b)