33 uint16_t commonHeight;
89 uint32_t size =
sizeof(
struct kernel);
92 size += kernelSize *
sizeof(accum);
96 size += kernelSize *
sizeof(accum);
99 struct kernel *obj = spin1_malloc(size);
105 log_debug(
"Kernel connector, m_kernelWidth, m_kernelHeight = %u %u",
139 void *generator, uint32_t pre_lo, uint32_t pre_hi,
140 uint32_t post_lo, uint32_t post_hi, UNUSED uint32_t post_index,
141 uint32_t post_slice_start, uint32_t post_slice_count,
142 unsigned long accum weight_scale, accum timestep_per_delay,
143 param_generator_t weight_generator, param_generator_t delay_generator,
146 struct kernel *obj = generator;
153 uint32_t post_start = max(post_slice_start, post_lo);
154 uint32_t post_end =
min(post_slice_start + post_slice_count - 1, post_hi);
157 for (uint32_t pre = pre_lo; pre <= pre_hi; pre++) {
160 for (uint32_t post = post_start; post <= post_end; post++) {
161 uint16_t post_r, post_c;
162 uint16_t pac_r, pac_c;
163 int16_t pap_r, pap_c;
176 int16_t r_diff = (int16_t) pap_r - (int16_t) pre_r;
177 int16_t c_diff = (int16_t) pap_c - (int16_t) pre_c;
179 k_r = hlf_kh - r_diff;
180 k_c = hlf_kw - c_diff;
182 if ((0 <= k_r) && (k_r < obj->
kernelHeight) && (0 <= k_c)
184 uint32_t local_post = post - post_slice_start;
void pre_in_post_world(uint16_t in_row, uint16_t in_col, uint16_t start_row, uint16_t start_col, uint16_t step_row, uint16_t step_col, int16_t *out_row, int16_t *out_col)
Get the pre's coordinates in the post's coordinate system.
uint16_t uidiv(uint32_t dividend, uint16_t divider, uint16_t *remainder)
Unsigned integer division.
void post_in_pre_world(uint16_t in_row, uint16_t in_col, uint16_t start_row, uint16_t start_col, uint16_t step_row, uint16_t step_col, uint16_t *out_row, uint16_t *out_col)
Get the post's coordinates in the pre's coordinate system.
Common functions for kernel generation.
Utility functions for working with memory.
uint16_t startPostWidth
Postpopulation grid X offset.
static void connection_generator_kernel_free(void *generator)
Free the convolution-kernel connection generator.
static void * connection_generator_kernel_initialise(void **region)
Initialise the convolution-kernel connection generator.
uint16_t preWidth
Prepopulation grid width.
uint16_t startPostHeight
Postpopulation grid Y offset.
uint16_t stepPostHeight
Postpopulation grid Y step.
uint16_t startPreWidth
Prepopulation grid X offset.
uint16_t startPreHeight
Prepopulation grid Y offset.
uint16_t delaysPresent
True if delays are present in the array below.
uint16_t kernelHeight
Convolution kernel grid height.
uint16_t weightsPresent
True if weights are present in the array below.
uint16_t stepPreHeight
Prepopulation grid Y step.
uint16_t stepPreWidth
Prepopulation grid X step.
uint16_t preHeight
Prepopulation grid height.
uint16_t postWidth
Postpopulation grid width.
static bool connection_generator_kernel_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 convolution-kernel connection generator.
uint16_t stepPostWidth
Postpopulation grid X step.
uint16_t kernelWidth
Convolution kernel grid width.
uint16_t postHeight
Postpopulation grid height.
accum kernelWeightsAndDelays[]
The parameters to be passed around for this connector.
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.
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)