103 uint32_t hash,
void **in_region) {
109 if (hash == type->hash) {
113 if (generator ==
NULL) {
119 generator->type = type;
122 generator->data = type->initialize(in_region);
126 log_error(
"Connection generator with hash %u not found", hash);
131 connection_generator_t generator, uint32_t pre_lo, uint32_t pre_hi,
132 uint32_t post_lo, uint32_t post_hi, uint32_t post_index,
133 uint32_t post_slice_start, uint32_t post_slice_count,
134 unsigned long accum weight_scale, accum timestep_per_delay,
135 param_generator_t weight_generator, param_generator_t delay_generator,
137 return generator->type->generate(
138 generator->data, pre_lo, pre_hi, post_lo, post_hi, post_index,
139 post_slice_start, post_slice_count, weight_scale, timestep_per_delay,
144 generator->type->free(generator->data);
initialize_connector_func * initialize
Initialises the generator.
connection_generator_t connection_generator_init(uint32_t hash, void **in_region)
Initialise a specific connection generator.
bool connection_generator_generate(connection_generator_t 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 a connection generator.
@ ALL_TO_ALL
All-to-all connection generator.
@ KERNEL
Convolution kernel connection generator.
@ FIXED_TOTAL
Fixed total connections connection generator.
@ FIXED_PROBABILITY
Fixed probability connection generator.
@ FIXED_POST
Fixed post-size connection generator.
@ FIXED_PRE
Fixed pre-size connection generator.
@ N_CONNECTION_GENERATORS
The number of known generators.
@ ONE_TO_ONE
One-to-one connection generator.
static const connection_generator_info connection_generators[]
An Array of known generators.
free_func * free
Frees any data for the generator.
void connection_generator_free(connection_generator_t generator)
Finish with a connection generator.
generate_connection_func * generate
Generate connections.
generator_hash_t hash
The hash of the generator.
The data for a connection generator.
A "class" for connection generators.
Connection Generator interface.
All-to-All connection generator implementation.
static void * connection_generator_all_to_all_initialise(void **region)
Initialise the all-to-all connection generator.
static void connection_generator_all_to_all_free(void *generator)
Free the all-to-all connection generator.
static bool connection_generator_all_to_all_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-to-all connection generator.
Fixed-Number-Post (fan-out) Connection generator implementation.
static void * connection_generator_fixed_post_initialise(void **region)
Initialise the fixed-post connection generator.
static bool connection_generator_fixed_post_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 fixed-post connection generator.
static void connection_generator_fixed_post_free(void *generator)
Free the fixed-post connection generator.
Fixed-Number-Pre (fan-in) Connection generator implementation.
static void * connection_generator_fixed_pre_initialise(void **region)
Initialise the fixed-pre connection generator.
bool connection_generator_fixed_pre_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 fixed-pre connection generator.
void connection_generator_fixed_pre_free(void *generator)
Free the fixed-pre connection generator.
Fixed-Probability Connection generator implementation.
static void * connection_generator_fixed_prob_initialise(void **region)
Initialise the fixed-probability connection generator.
static bool connection_generator_fixed_prob_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 fixed-probability connection generator.
static void connection_generator_fixed_prob_free(void *generator)
Free the fixed-probability connection generator.
Fixed-Total-Number (Multapse) Connection generator implementation.
static void connection_generator_fixed_total_free(void *generator)
Free the fixed-total connection generator.
static void * connection_generator_fixed_total_initialise(void **region)
Draw from a binomial distribution i.e. with replacement.
static bool connection_generator_fixed_total_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 fixed-total connection generator.
Kernel connection generator implementation.
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.
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.
One-to-One Connection generator implementation.
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,...)
General types associated with generators.
void *() initialize_connector_func(void **region)
How to initialise the connection generator.
uint32_t generator_hash_t
The type of values used to indicate the subtype of generator to create. Must match the constants on t...
void() free_func(void *data)
How to free any data for the generator; all generator types use the same signature of free func.
bool() generate_connection_func(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)
How to generate connections with a connection generator.
The data for a matrix generator.
void sark_free(void *ptr)